You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by tbee <tb...@tbee.org> on 2010/06/01 16:17:20 UTC

extending WAR

I'm in the process of migrating some ANT build scripts to Maven by creating
mojo's that will provided the same functionality. One of the processes I
need to migrate is a customized WAR creation; I need to copy in some
additional files and I also need to create a second zip containing all
static content.

I figured I reused the maven-war-plugin, so I wrote a class that extends
WarMojo (2.0) and aside from just writing a log statement in the
buildExplodedWebapp it didn't do anything. This caused a
NullPointerException (NPE). Then I started on several permutations of this
approach and all end in a NPE. So I googled to see if anyone had done this
before and found a few that had (a.o. Seam). I tried copying their code, but
the NPE still came along. Even copying the source of WarMojo.java to my
class causes the NPE. 

All the NPEs revolve around not having null directories, in this case
"outputDirectory" is null. What I do not get is why the behavior is
different if I put the WarMojo code in my own class (and thus causes a NPE);
these setting should be initialized by Maven...

java.lang.NullPointerException
        at java.io.File.<init>(File.java:222)
        at org.apache.maven.plugin.war.WarMojo.execute(WarMojo.java:129)
        at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:490)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:694)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
fecycle(DefaultLifecycleExecutor.java:556)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:535)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:387)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:348)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at
org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:6
0)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

http://svn.apache.org/viewvc/maven/plugins/tags/maven-war-plugin-2.0/src/main/java/org/apache/maven/plugin/war/WarMojo.java?revision=406221&view=markup

Aside from the technical issue; what would be the correct way to extend the
WAR plugin? I'm still believe I should be extending WarMojo and override &
enhance the buildExplodedWebapp method. The WarMojo can then finish up
creating the War, after I copied in the extra files, and I can also create
the additional zip at that time.
-- 
View this message in context: http://old.nabble.com/extending-WAR-tp28742485p28742485.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: extending WAR

Posted by Stephen Connolly <st...@gmail.com>.
I have not used it.  if you can guarantee that m3 only then in theory you'd
be fine... but just don't do it

On 2 June 2010 13:05, tbee <tb...@tbee.org> wrote:

>
> What about this one?
>
> http://www.jfrog.org/sites/mvn-anno-mojo/latest/
>
> --
> View this message in context:
> http://old.nabble.com/extending-WAR-tp28742485p28753463.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: extending WAR

Posted by tbee <tb...@tbee.org>.
What about this one?

http://www.jfrog.org/sites/mvn-anno-mojo/latest/

-- 
View this message in context: http://old.nabble.com/extending-WAR-tp28742485p28753463.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: extending WAR

Posted by tbee <tb...@tbee.org>.


Stephen Connolly-2 wrote:
> 
> Nope. you will still have the issue of the plugin metadata being
> incorrect.
> 
> Short answer: [image: donny_dont_22.jpg] Don't do what Donny Don't Does
> 

Ahh, ofcourse, this make it clear: "when you extend a maven-plugin artifact,
the maven-plugin-plugin cannot see the javadoc annotations of the parent
mojo classes (because they are javadoc annotations and it only has access to
the .class files)". I'm so used to Java annotations that this slipped me.

So code (plugin) reusage simply is a no-no. I could copy all properties +
javadoc annotations in my own class and forward them to the parent. Hm. What
will be the gain...

Thanks!
-- 
View this message in context: http://old.nabble.com/extending-WAR-tp28742485p28753414.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: extending WAR

Posted by Stephen Connolly <st...@gmail.com>.
Nope. you will still have the issue of the plugin metadata being incorrect.

It will only be less bad (because plugin versions are not based on first
version seen in the reactor in M3)

Short answer: [image: donny_dont_22.jpg] Don't do what Donny Don't Does

-Stephen

On 2 June 2010 08:21, tbee <tb...@tbee.org> wrote:

>
> This will work for M3? Because we're still introducing Maven, so I could
> require that. (Although the last version of M3 does not seem to handle -U
> correctly.)
> --
> View this message in context:
> http://old.nabble.com/extending-WAR-tp28742485p28750984.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: extending WAR

Posted by tbee <tb...@tbee.org>.
This will work for M3? Because we're still introducing Maven, so I could
require that. (Although the last version of M3 does not seem to handle -U 
correctly.)
-- 
View this message in context: http://old.nabble.com/extending-WAR-tp28742485p28750984.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: extending WAR

Posted by tbee <tb...@tbee.org>.


Wayne Fay wrote:
> 
> Before working any more on extending plugins, you should read the
> following thread from last week:
> from: Lachlan Deck
> to: Maven Users List
> date: Mon, May 24, 2010 at 8:54 PM
> subject: mojo help
> 

OMH, "the maven-plugin-plugin not merging plugin metadata design issue"?

This the third mojo I'm developing and it (Maven) keeps being complex.

Thanks for the pointer!
-- 
View this message in context: http://old.nabble.com/extending-WAR-tp28742485p28750648.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: extending WAR

Posted by Wayne Fay <wa...@gmail.com>.
> I figured I reused the maven-war-plugin, so I wrote a class that extends
> WarMojo (2.0) and aside from just writing a log statement in the
>
> Aside from the technical issue; what would be the correct way to extend the
> WAR plugin? I'm still believe I should be extending WarMojo and override &

Before working any more on extending plugins, you should read the
following thread from last week:
from: Lachlan Deck
to: Maven Users List
date: Mon, May 24, 2010 at 8:54 PM
subject: mojo help

Wayne

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