Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Draft walk-through for manually converting a Fluffy Bunny project to Maven layout.

Preparing

To prepare, turn off automatic builds in Eclipse (otherwise, Eclipse is going to be really, really "helpful" by creating folders, modifying .classpath etc.). Keep automatic builds off until you've at least finished step 2 (changing your configuration files.

Once you've changed the configuration files, close the project and open it again, then turn on the Eclipse builds again.

1. Creating folders and moving stuff around

Here are the modifications you have to do to your project's layout, expressed in bash (as if your working directory is your project's root).

mkdir -p src/main 
mkdir -p src/test/resources
git mv Components src/main/components
git mv Sources src/main/java
git mv Resources src/main/resources
git mv WebServerResources src/main/webserver-resources
git mv Tests src/test/java

If the project does not have a Tests folder, you can substitute:

mkdir -p src/test/java

For any directories that are empty, you can add an empty .gitkeep file so that the structure is preserved in the repository:

touch src/test/resources/.gitkeep
touch src/test/java/.gitkeep

2. Updating Eclipse project files

2.1 .classpath

Just copy in this file:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="src" output="target/classes" path="src/main/java">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="output" path="target/classes"/>
</classpath>

2.2 .project

Just copy in this file, but replace [Your Project Name] with your Eclipse project name.

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
   <name>[Your Project Name]</name>
   <comment></comment>
   <projects>
   </projects>
   <buildSpec>
   	<buildCommand>
   		<name>org.eclipse.jdt.core.javabuilder</name>
   		<arguments>
   		</arguments>
   	</buildCommand>
   	<buildCommand>
   		<name>org.objectstyle.wolips.incrementalbuilder</name>
   		<arguments>
   		</arguments>
   	</buildCommand>
   	<buildCommand>
   		<name>org.eclipse.m2e.core.maven2Builder</name>
   		<arguments>
   		</arguments>
   	</buildCommand>
   </buildSpec>
   <natures>
   	<nature>org.eclipse.m2e.core.maven2Nature</nature>
   	<nature>org.maven.ide.eclipse.maven2Nature</nature>
   	<nature>org.eclipse.jdt.core.javanature</nature>
   	<nature>org.objectstyle.wolips.incrementalapplicationnature</nature>
   </natures>
</projectDescription>

2.3 build.properties

Make sure the classes.dir property is target/classes. Example file:

classes.dir=target/classes
component.inlineBindingPrefix=$
component.inlineBindingSuffix=
component.wellFormedTemplateRequired=false
customInfoPListContent=
eoAdaptorClassName=
principalClass=app.Application
project.name=Hugi
project.name.lowercase=hugi
project.type=application
webXML=false
webXML_CustomContent=

2.4 woproject

If convenient, copy over the .patternset files from a pristine Maven project. Otherwise, classes.exclude.patternset:

build.properties

classes.include.patternset:

**/*.class
*.properties

resources.exclude.patternset:

**/*.woa/**
**/*.framework/**
**/Info.plist

resources.include.patternset:

src/main/components/**/*.wo/**/*
src/main/components/**/*.api
src/main/resources/**/*

wsresources.exclude.patternset:

**/*.woa/**
**/*.framework/**
**/*.eomodeld~/**

wsresources.include.patternset:

src/main/webserver-resources/**/*

3. Manually add your project's dependencies

If you have any depenencies outside of WO and Wonder, go into your pom.xml and add the missing dependencies from your Libraries folder. You can then delete the Libraries folder.

4. Update any resource references in any .eogen files

These will all need to be manually updated to find the resources in the new project structure. If you're using per-project custom generator templates, move these to src/main/resources/templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment