Maven2 eclipse plugin and custom or pom packages.

Update: This approach will also work with “ear” projects and only requires adding plugin definition without changes to eclipse maven plugin.

Recently I had to create maven project which was producing war file and then packaging it into tar before deploying to maven repository without deploying the war itself. This forced me to declare my pom package as “pom”. Everything was fine until I tried to run “mvn eclipse:eclipse” which gave me error that it does not support “pom” packages.
After googling I stumble upon this ticket

which suggested to specify “war” (or “jar”) packaging in eclipse plugin configuration like so



This got me passed the “pom” package error and created the .project file but I still could not get .classpath file.

After some more googling I found this blog:

which unfortunately did not provide the modification details.

But this post

gave me necessary clue that eclipse plugin was not generating .classpath because of my pom not being a Java project (war and jar are java projects for eclipse).

Unfortunately I could not find a way to override the project type in pom.xml and had to fix it in eclipse plugin code.

Just checkout latest eclipse plugin releases, for me it was 2.8:

svn checkout

and modify org.apache.maven.plugin.eclipse.EclipsePlugin class by replacing the last line:

public final boolean setup()
throws MojoExecutionException

boolean ready = true;

setProjectNameTemplate( IdeUtils.calculateProjectNameTemplate( getProjectNameTemplate(),
isAddGroupIdToProjectName(), getLog() ) );
ajdt = enableAjdt( executedProject ) && !ajdtVersion.equals( "none" );
ready = validate();

// TODO: Why are we using project in some places, and executedProject in others??
ArtifactHandler artifactHandler = project.getArtifact().getArtifactHandler();

// ear projects don't contain java sources
// pde projects are always java projects
isJavaProject =
|| ( Constants.LANGUAGE_JAVA.equals( artifactHandler.getLanguage() ) && !Constants.PROJECT_PACKAGING_EAR.equals( packaging ) );



Finally, to use your modified plugin make sure you delete everything under

/your path to/repository/org/apache/maven/plugins/maven-eclipse-plugin/

directory and then build your updated plugin by running “mvn install” on it.
This though can accidentally be overwritten by newer eclipse plugin but can be fixed by changing version of your custom plugin pom.xml from lets say 2.8 to 2.8-custom and then specifying it in plugin definition of your project like so



Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>