You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mark Eggers <it...@yahoo.com> on 2013/11/25 23:06:52 UTC

WAR plugin versus archiveClasses versus finalName

Folks,

Environment: Maven 3.1.1, JDK 1.7.0_45

I'm having some challenges with the Maven WAR plugin (2.4), 
archiveClasses, and finalName. In addition, I am using the Freemarker 
preprocessor plugin (FMPP plugin) to generate some output.

Here's what I've tried (without the FMPP plugin).

1. Default name (artifactId-version.extension)

All resources and classes get placed into artifactId-version.JAR as 
expected. The WAR file is also named artifactId-version.WAR.

2. finalName as ${project.artifactId}

No classes get placed into artifactId-version.JAR. Resources are added 
into artifactId-version.JAR. The WAR file is named artifactId.war

3. finalName as ${project.artifactId} with explicit outputFileMapping

<outputFileNameMapping>
   @{artifactId}@-@{version}@.@{extension}@
</outputFileNameMapping>

No classes get placed into artifactId-version.JAR. Resources are added 
into artifactId-version.JAR. The WAR file is named artifactId.war

4. finalName as ${project.artifactId} with explicit outputFileMapping

<outputFileNameMapping>
   @{artifactId}@.@{version}@.@{extension}@
</outputFileNameMapping>

Note the '.' instead of the dash between artifactId and version.

All resources and classes are placed into artifactId.version.JAR. All 
other dependent JARs are also renamed. The WAR file is named artifactId.war

To add confusion to the mix, I'm using the FMPP plugin. I've bound this 
to the compile phase (rather than the default generate-sources phase), 
and placed the output in target/classes. I'm doing this since I am 
preprocessing some files that should get included into the JAR.

Now, if I rerun the above four scenarios, I get the following results.

1. The preprocessed file is not placed in the JAR file, even though it's 
in target/classes in the proper place.

2. Only the resources get placed into the JAR file (as before).

3. Only the resources get placed into the JAR file (as before).

4. All resources, preprocessed files, and classes get placed into the 
JAR file.

In short, scenario 4 works with the downside that it renames all other 
dependent JARs to fit the outputFileNameMapping designation.

I don't understand why 3 doesn't work.

The desired end result is to have a version-less WAR file, and all of 
the project resources bundled up into the standard 
artifactId-version.extension naming format.

The only way I've found to accomplish this is to make a module with the 
resources / source code and have the parent depend on this module. That 
certainly feels like a hack to get around a packaging problem.

What is my vision problem (other than my requirements, which are sadly 
not subject to change at the moment)?

Thanks,
Mark
/mde/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: WAR plugin versus archiveClasses versus finalName

Posted by Wayne Fay <wa...@gmail.com>.
> The only way I've found to accomplish this is to make a module with the
> resources / source code and have the parent depend on this module. That
> certainly feels like a hack to get around a packaging problem.

To me, this is not a hack. Maven does not really want you to have
source code in WAR projects. The problems you are experiencing are
related to that.

You should move the source code to JAR projects and depend on them.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org