Skip to content

Instantly share code, notes, and snippets.

  • Save hugithordarson/3c269a3196d0c4f2da486f1109c16d42 to your computer and use it in GitHub Desktop.
Save hugithordarson/3c269a3196d0c4f2da486f1109c16d42 to your computer and use it in GitHub Desktop.
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.

5. Still have problems? (FAQ)

Before proceeding, make sure of the following

  • You're using the most recent version of the WO maven plugin (wolifecycle). As of now, that's 2.6-SNAPSHOT.
  • You're using the most recent version of Project Wonder. As of now, that's 7.3-SNAPSHOT.
  • In WOLips Preferences -> Build, you've got 'generate bundles' checked
  • You've deleted the old Eclipse launch configuration for your application and re-created it (an old launch configuration will still be referencing the classpath from the ant project).
  • You've rebuilt your project cleanly by:
    • Disabling 'Project -> Build Automatically'
    • Going to 'Project -> Clean...' to rebuild your project
    • Re-enabling 'Project -> Build Automatically'

My components are in subfolders inside src/main/components and are not copied to the WOA

Set the configuration option flattenComponents in the configuration for wolifecycle-maven-plugin.

<plugin>
	<groupId>org.wocommunity</groupId>
	<artifactId>wolifecycle-maven-plugin</artifactId>
	<version>2.6-SNAPSHOT</version>
	<extensions>true</extensions>
	<configuration>
		<flattenComponents>true</flattenComponents>
	</configuration>
</plugin>

My application doesn't find the session class, an exception is thrown "Class 'Session' exists ([...]) but is not a subclass of WOSession"

Override _sessionClass() in your Application class to return your actual session class.

@Override
protected Class<Session> _sessionClass() {
	return my.very.own.Session.class;
}

My application doesn't find the Main class, an exception is thrown "Class 'Main' exists but is not a subclass of WOComponent"

Install the correct class for the name 'Main' by using ERXPatcher, you do this in the installPatches method in your Application class.

@Override
public void installPatches() {
	super.installPatches();
	ERXPatcher.setClassForName(my.own.Main.class, "Main");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment