Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven build problem #273

Open
BarchSteel opened this issue Dec 16, 2020 · 8 comments
Open

Maven build problem #273

BarchSteel opened this issue Dec 16, 2020 · 8 comments

Comments

@BarchSteel
Copy link

Hello,
I set up Eclipse, JDK8, cloned imagej/imagej, imported the project -> everything OK.
I can also start & debug ImageJ 2.1.1-snapshot from with Eclipse. (go to net.imagej->main.java and Run As->Java App)

But I can't get the maven build to succeed to build the package or do an install.
It will fail during the tests.
What can I do to skip the tests? What is my mistake, so that I can build the package, or do a maven install?
My goal is to create and test a stand-alone version for testing my modifications.

[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 4.614 s <<< FAILURE! - in net.imagej.app.MainTest
[ERROR] testMains(net.imagej.app.MainTest)  Time elapsed: 3.787 s  <<< ERROR!
org.scijava.NoSuchServiceException: Service net.imagej.app.MainTest$LitmusService not found.
	at net.imagej.app.MainTest.testMains(MainTest.java:60)

[ERROR] testHeadless(net.imagej.app.MainTest)  Time elapsed: 0.719 s  <<< ERROR!
org.scijava.NoSuchServiceException: Service net.imagej.app.MainTest$LitmusService not found.
	at net.imagej.app.MainTest.testHeadless(MainTest.java:75)

[INFO] Running net.imagej.app.ServiceCompletenessTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.073 s - in net.imagej.app.ServiceCompletenessTest
[INFO] Running net.imagej.app.ToplevelImageJAppTest
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.071 s <<< FAILURE! - in net.imagej.app.ToplevelImageJAppTest
[ERROR] testApp(net.imagej.app.ToplevelImageJAppTest)  Time elapsed: 0.07 s  <<< FAILURE!
java.lang.AssertionError
	at net.imagej.app.ToplevelImageJAppTest.testApp(ToplevelImageJAppTest.java:71)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   ToplevelImageJAppTest.testApp:71
[ERROR] Errors: 
[ERROR]   MainTest.testHeadless:75 » NoSuchService Service net.imagej.app.MainTest$Litmu...
[ERROR]   MainTest.testMains:60 » NoSuchService Service net.imagej.app.MainTest$LitmusSe...
[INFO] 
[ERROR] Tests run: 5, Failures: 1, Errors: 2, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  19.141 s
[INFO] Finished at: 2020-12-16T21:04:18+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project imagej: There are test failures.
[ERROR] 
@imagejan
Copy link
Member

Thanks for reporting, @BarchSteel!

I cannot reproduce with my local clone, building with Maven 3.3.9 and Java 1.8.0_271 on Mac OSX, using:

mvn clean install

You can skip tests by running:

mvn -DskipTests

Please note however that it shouldn't be necessary at all for you to build this project. If you want to test modifications in any specific component (such as scifio), just build that component only and put the built jar file into your up-to-date Fiji installation.

You can have Maven copy the jars and all dependencies by using:

mvn -Dscijava.app.directory=/path/to/your/Fiji.app

@BarchSteel
Copy link
Author

BarchSteel commented Dec 16, 2020

Thank you for the answer.

The problem is reproducible for me. I also tested on a different PC (also Windows 10, x64, same Eclipse Version), and the error is identical.

But your trick: -DskipTests worked! I created the .jar. (I entered it as "goal" in the menu for Run As->"2 Maven build..." and it seemed to work.)

I wanted to debug my changes in scifio, but I could not get the debugger to work correctly on my setup, unless I had both ImageJ and SCIFIO as projects set up. I also needed to disable the default SCIFIO dependency in the ImageJ project and manually add my scifio project to the class-path.

The reason that I could not copy over the sicfio.jar was, because building scifio.jar using the maven build process, also fails during the test, but of course with different code lines (I made a forum post for this, in case others struggle in the same way: https://forum.image.sc/t/trouble-compiling-scifio-from-git-repository/46695)

@frauzufall
Copy link
Member

frauzufall commented Dec 16, 2020

Looks like in both cases the services are not discovered (based on the forum post, the SCIFIO NullPointerException during the tests is thrown here). Running mvn test on both repos (imagej/imagej and scifio/scifio) should work and it looks like in your case it doesn't. Maybe @tomburke-rse can help, he is a Windows user.

@BarchSteel
Copy link
Author

I set up a test build using the GitHub actions workflow to compile imagej on windows-latest and there it works without problems:
https://github.com/BarchSteel/imagej/runs/1575995959?check_suite_focus=true

So the problem lies on my PC, either with Eclipse, or the JDK.

@ctrueden
Copy link
Member

ctrueden commented Dec 18, 2020

There is a longstanding bug in the EclipseHelper code which runs the SciJava plugin indexer. Under some circumstances, the EclipseHelper ends up writing the indexed plugins to target/META-INF/json/org.scijava.plugin.Plugin, instead of the needed target/classes/META-INF/json/org.scijava.plugin.Plugin. You can work around it by running mvn manually on the CLI, then doing a refresh in Eclipse. I keep meaning to dig deeply into this bug and fix it, but haven't had time.

@BarchSteel I'm not certain your problem is the same as this, but I am quite suspicious. 😉

It is unfortunate that we need this EclipseHelper thing, but unfortunately Eclipse does not run annotation processors otherwise. (Yes, you can configure it to run individual ones on a per project basis, but it's clunky at best and requires special files committed to every repository. Whereas the EclipseHelper solution—in theory at least—avoids community projects needing to care about this arcana.)

@BarchSteel
Copy link
Author

BarchSteel commented Dec 20, 2020

I installed the apache-maven-3.6.3 and used it on the command line in the ImageJ source directory.
mvn
Unfortunately, at first, the error message stayed the same.
For me, there were two different files.
\target\META-INF\json\org.scijava.plugin.Plugin <-- does contain a reference to LitmusTest
\target\classes\META-INF\json\org.scijava.plugin.Plugin <-- is missing the LitmusTest

The solution was to delete the complete target folder and re-create it by running mvn.
Now the test passed!

So this is not a maven problem, but an Eclipse IDE problem.
If this could be fixed, it would it easier for newcomers to contribute to the project (I prefer Eclipse GUI over the CLI).

I was looking around to find this EclipseHelper : maybe it's in here: https://github.com/scijava/scijava-maven-plugin

Just out of curiosity: How is scijava-maven-plugin referenced from imagej pom.xml? It seems the dependency goes like this:
imagej->scijava-common -> scijava-base ->scijava-maven-plugin

@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/trouble-compiling-scifio-from-git-repository/46695/2

@imagejan
Copy link
Member

How is scijava-maven-plugin referenced from imagej pom.xml?

The pom.xml in imagej directly inherits from its parent POM, pom-scijava, which serves as a "bill of materials" (BOM) and itself has pom-scijava-base as a parent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants