Getting Maven to install a .jar in a sub-folder of plugins

maven
imagej

#21

Hi all,
I notice that there was work regarding this aspect and now that I have moved to pom-scijava 21.0.0 I see that there is an imagej.app.subdirectory Woo! :tada:

Now I have experienced a couple of issues with it, because I get a NullPointerException when using Execution copy-jars of goal net.imagej:imagej-maven-plugin:0.7.0:copy-jar

First hint to the problem might be that we have our git repos in https, which might explain this error at the beginning of executing Maven build

[INFO] --- buildnumber-maven-plugin:1.4:create (default) @ DEVILS_ ---
[WARNING] Cannot get the revision information from the scm repository, proceeding with revision of UNKNOWN : 
No such provider: 's'.
[INFO] Storing buildNumber: UNKNOWN at timestamp: 1525178717480
[WARNING] Cannot get the branch information from the git repository: 
No such provider: 's'.
[WARNING] Cannot get the branch information from the scm repository, proceeding with UNKNOWN_BRANCH : 
No such provider: 's'.
[INFO] Storing buildScmBranch: UNKNOWN_BRANCH

Now the stack trace of the error is here

[ERROR] Failed to execute goal net.imagej:imagej-maven-plugin:0.7.0:copy-jars (copy-jars) on project DEVILS_: Execution copy-jars of goal net.imagej:imagej-maven-plugin:0.7.0:copy-jars failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal net.imagej:imagej-maven-plugin:0.7.0:copy-jars (copy-jars) on project DEVILS_: Execution copy-jars of goal net.imagej:imagej-maven-plugin:0.7.0:copy-jars failed.
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution copy-jars of goal net.imagej:imagej-maven-plugin:0.7.0:copy-jars failed.
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	... 20 more
Caused by: java.lang.NullPointerException
	at net.imagej.maven.AbstractCopyJarsMojo.installArtifact(AbstractCopyJarsMojo.java:183)
	at net.imagej.maven.AbstractCopyJarsMojo.installArtifact(AbstractCopyJarsMojo.java:139)
	at net.imagej.maven.CopyJarsMojo.execute(CopyJarsMojo.java:188)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	... 21 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

And the culprit line seems to be https://github.com/imagej/imagej-maven-plugin/blob/caba6b33172a93b71f9d68536228c644bd79519f/src/main/java/net/imagej/maven/AbstractCopyJarsMojo.java#L183

So is there a way to just use the artifact version from our pom.xml rather than infer it from SCM? Or am I missing the shot completely!

All the best


#22

I haven’t investigated this in-depth, @oburri, but I think we are looking at to separate issues.

Let’s first investigate the NullPointerException: is there another version of the DEVILS_ artifact already in the ImageJ/Fiji instance defined by imagej.app.directory? If so, what exactly is the filename?


Which Java version is Maven using (mvn -version should tell you)?


#23

Hi,
@stelfrich, thanks for looking into this

There is no other version right now, the filename producdeb by the muild in my Maven folder is DEVILS_-1.0.1.jar

Maven is currently running JDK 1.8.0_144

I would finally like to point out that in version 19.0.0 of the pom-scijava everything works, though.


#24

How exactly did you call Maven to generate the NullPointerException?


#25

I called Build > Run As > Maven Build… with the default options from Eclipse


#26

Sorry to ask the obvious, but where do you set imagej.app.directory and imagej.app.subdirectory? Do you also experience the issue when you start Maven from the command line?