Unable to compile an ImageJ plugin code in Netbeans/maven

netbeans
maven
plugin
Tags: #<Tag:0x00007fd542a51b48> #<Tag:0x00007fd542a51a08> #<Tag:0x00007fd542a518c8>

#1

I’ve imported a maven project in Netbeans 7.3.1 (to implement an ImageJ plugin) by reading the following pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>


        <groupId>eu.marbilab.imagej</groupId>
        <artifactId>Steerable3D_</artifactId>
        <version>0.7.0-SNAPSHOT</version>

        <name>Steerable3D</name>
        <description>
          A steerable filter based on 3D Gaussian derivatives.
        </description>
        <url>http://www.marbilab.eu/imagej/s3d</url>
        <inceptionYear>2018</inceptionYear>
        <organization>
                <name>MARBILab</name>
                <url>http://www.marbilab.eu</url>
        </organization>
        <licenses>
                <license>
                        <name>GNU General Public License v3+</name>
                       <url>http://www.gnu.org/licenses/gpl.html</url>
                       <distribution>repo</distribution>
                </license>
        </licenses>

        <developers>
                <developer>
                        <id>pam66</id>
                        <name>Paolo Miocchi</name>
                        <url>http://imagej.net/User:Pam66</url>
                        <roles>
                                <role>founder</role>
                                <role>lead</role>
                                <role>developer</role>
                                <role>debugger</role>
                                <role>reviewer</role>
                                <role>support</role>
                                <role>maintainer</role>
                        </roles>
                </developer>
        </developers>
        <contributors>
                <contributor>
                        <name>Paolo Miocchi</name>
                        <url>http://imagej.net/User:Pam66</url>
                        <roles>
                                <role>founder</role>
                                <role>lead</role>
                                <role>developer</role>
                                <role>debugger</role>
                                <role>reviewer</role>
                                <role>support</role>
                                <role>maintainer</role>
                        </roles>
                        <properties><id>pam66</id></properties>
                </contributor>
        </contributors>
        <mailingLists>
                <mailingList>
                        <name>ImageJ Forum</name>
                        <archive>http://forum.imagej.net/</archive>
                </mailingList>
        </mailingLists>

        <scm>       
             <connection>
               scm:git:git://github.com/pam66/steerable3D
             </connection>
             <developerConnection>
               scm:git:git@github.com:pam66/steerable3D
             </developerConnection>
                <tag>HEAD</tag>
                <url>https://github.com/pam66/steerable3D</url>
        </scm>
        <issueManagement>
                <system>GitHub Issues</system>
                <url>https://github.com/pam66/steerable3D/issues</url>
        </issueManagement>
        <ciManagement>
                <system>None</system>
        </ciManagement>

        <properties>
                <license.licenseName>gpl_v3</license.licenseName>
                <license.copyrightOwners>
                    Paolo Miocchi
                </license.copyrightOwners>
        </properties>

        <dependencies>
        <dependency>
          <groupId>gov.nih.imagej</groupId>
          <artifactId>imagej</artifactId>
          <version>1.47</version>
          <type>pom</type>
        </dependency>
        <dependency>
          <!-- NB: For ImageJ 1.x overlay visualization. -->
          <groupId>net.imagej</groupId>
          <artifactId>imagej-legacy</artifactId>
           <version>0.29.0</version>
        </dependency>

        </dependencies>
        <repositories>
           <repository>
              <id>imagej.public</id>
              <url>
                 http://maven.imagej.net/content/groups/public
              </url>
           </repository>
        </repositories>
</project>

I put just one java source code file within the following path
src/main/java/eu/marbilab/imagej/Steerable3D_.java

Doing “Clean and Build” all seems to work fine and the jar file target/Steerable3D_-0.7.0-SNAPSHOT.jar is successfully produced.
Here it is the Netbeans output:

cd /home/miocchi/Sources/FIJI/Steerable3D; JAVA_HOME=/usr/lib/jvm/default-java /home/miocchi/netbeans-7.3.1/java/maven/bin/mvn clean install
Scanning for projects...
                                                                        
------------------------------------------------------------------------
Building Steerable3D 0.7.0-SNAPSHOT
------------------------------------------------------------------------

[clean:clean]
Deleting /home/miocchi/Sources/FIJI/Steerable3D/target

[resources:resources]
[debug] execute contextualize
Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
Copying 1 resource

[compiler:compile]
File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
Compiling 1 source file to /home/miocchi/Sources/FIJI/Steerable3D/target/classes

[resources:testResources]
[debug] execute contextualize
Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
skip non existing resourceDirectory /home/miocchi/Sources/FIJI/Steerable3D/src/test/resources

[compiler:testCompile]
No sources to compile

[surefire:test]
No tests to run.
Surefire report directory: /home/miocchi/Sources/FIJI/Steerable3D/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0


[jar:jar]
Building jar: /home/miocchi/Sources/FIJI/Steerable3D/target/Steerable3D_-0.7.0-SNAPSHOT.jar

[install:install]
Installing /home/miocchi/Sources/FIJI/Steerable3D/target/Steerable3D_-0.7.0-SNAPSHOT.jar to /home/miocchi/.m2/repository/eu/marbilab/imagej/Steerable3D_/0.7.0-SNAPSHOT/Steerable3D_-0.7.0-SNAPSHOT.jar
Installing /home/miocchi/Sources/FIJI/Steerable3D/pom.xml to /home/miocchi/.m2/repository/eu/marbilab/imagej/Steerable3D_/0.7.0-SNAPSHOT/Steerable3D_-0.7.0-SNAPSHOT.pom
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 16.553s
Finished at: Mon Feb 12 11:15:13 CET 2018
Final Memory: 19M/124M
------------------------------------------------------------------------

The problem is that the java source file is “ignored”, it is not compiled at all and no corresponding .class file is generated.

Here it is the content of the resulting jar file

     jar tvf target/Steerable3D_-0.7.0-SNAPSHOT.jar 
     0 Mon Feb 12 12:33:28 CET 2018 META-INF/
   127 Mon Feb 12 12:33:26 CET 2018 META-INF/MANIFEST.MF
   332 Mon Feb 12 12:33:22 CET 2018 plugins.config
     0 Mon Feb 12 12:33:28 CET 2018 META-INF/maven/
     0 Mon Feb 12 12:33:28 CET 2018 META-INF/maven/eu.marbilab.imagej/
     0 Mon Feb 12 12:33:28 CET 2018 META-INF/maven/eu.marbilab.imagej/Steerable3D_/
  4228 Mon Feb 12 11:45:28 CET 2018 META-INF/maven/eu.marbilab.imagej/Steerable3D_/pom.xml
   124 Mon Feb 12 12:33:28 CET 2018 META-INF/maven/eu.marbilab.imagej/Steerable3D_/pom.properties

Does anyone could help me, please?
Thanks in advance!


#2

You should define pom-scijava as a parent in your pom.xml:

<parent>
		<groupId>org.scijava</groupId>
		<artifactId>pom-scijava</artifactId>
		<version>19.2.0</version>
		<relativePath />
</parent>

See here for an example plugin and some explanations how to use it in an IDE:


#3

OK, now it works!
Thanks,
However, it’s strange that if there are unsatisfied dependencies netbeans tells me nothing.


#4

Glad that it works for you. Note that in order to be able to build from the command line (and from continuous integration tools like Travis CI), you should stick to the standard Maven project structure.

I opened a pull request on your repository to fix that: