Closed hohwille closed 8 years ago
As I can not see build.log
in travis I am quite clueless. After all for travis it is a bad idea to report problems to external log files.
Any chance to make maven invoker outout the build.log to the regular maven log? https://maven.apache.org/plugins/maven-invoker-plugin/run-mojo.html
Or any chance to get build.log from travis (directly or via configuring travis.yml)? https://docs.travis-ci.com/user/notifications/
Did you try to set invoker.streamLogs
to true? Then the output of invoker
should be shown in the console.
@hohwille, take a look at https://github.com/1and1/foss-parent/blob/master/pom.xml#L1072. The profile foss-parent-enable-invoker-log-output-on-travis
will turn on invoker.streamLogs
and invoker.showErrors
when running in Travis.
@mfriedenhagen thanks for the hint.
So the actual error is this one:
Caused by: java.lang.ClassNotFoundException: org.codehaus.mojo.servicedocgen.it.jaxrs.json.simple.DemoRestService
[INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
[INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[INFO] at java.security.AccessController.doPrivileged(Native Method)
[INFO] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
[INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
[INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
In other words the dynamic classloader behaves differently on the platform where travis runs than on my windows machine. I need to test on different machines as well. Maybe it does not work on windows in general. In this MOJO I am doing this (taken from hints for MOJO development on the web):
@Parameter( defaultValue = "${project.runtimeClasspathElements}", readonly = true )
private List<String> runtimeClasspathElements;
private ClassLoader getProjectClassloader() throws MojoExecutionException {
if ( this.projectClassloader == null ) {
this.projectClassloader = new URLClassLoader( buildClasspathUrls(), this.getClass().getClassLoader() );
}
return this.projectClassloader;
}
private URL[] buildClasspathUrls() throws MojoExecutionException {
List<URL> urls = new ArrayList<URL>( this.runtimeClasspathElements.size() );
for ( String element : this.runtimeClasspathElements ) {
try {
urls.add( new File( element ).toURI().toURL() );
} catch ( MalformedURLException e ) {
throw new MojoExecutionException( "Unable to access project dependency: " + element, e );
}
}
return urls.toArray( new URL[urls.size()] );
}
Is there something wrong with this approach?
Very strange. I added more debug output to the classloader setup and before the error I get this:
[INFO] [INFO] Generating "Service Documentation" report --- servicedocgen-maven-plugin:1.0.0-beta-2-SNAPSHOT
[INFO] [DEBUG] Class matches: DemoRestService
[INFO] [INFO] Found service: DemoRestService
[INFO] [DEBUG] Adding to classloader: file:/home/travis/build/mojohaus/servicedocgen-maven-plugin/target/it/jaxrs-json-simple/target/classes
[INFO] [DEBUG] Adding to classloader: file:/home/travis/build/mojohaus/servicedocgen-maven-plugin/target/local-repo/javax/ws/rs/javax.ws.rs-api/2.0/javax.ws.rs-api-2.0.jar
[INFO] [DEBUG] Adding to classloader: file:/home/travis/build/mojohaus/servicedocgen-maven-plugin/target/local-repo/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar
[INFO] [INFO] Analyzing DemoRestService
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD FAILURE
So DemoRestService.java is found bout the DemoRestService.class is missing in classpath. What could be the reason for this error that can not be reproduced on my windows machine???
Seems to be done in the same way also by other MOJOs:
Interesting to mention is that this also used to work in travis and failed exactly when the MOJO has been converted to a report.
Just speculating: do you use the same Maven version? See mojo-parent .travis.yml for how to enforce specific Maven versions (default on Travis is 3.2.5 if I remember correctly).
Just for the record:
mvn clean install
using:Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.2", arch: "x86_64", family: "mac"
When I change the following:
diff --git a/src/it/projects/jaxrs-json-simple/invoker.properties b/src/it/projects/jaxrs-json-simple/invoker.properties
index f0316ef..f18eaf7 100644
--- a/src/it/projects/jaxrs-json-simple/invoker.properties
+++ b/src/it/projects/jaxrs-json-simple/invoker.properties
@@ -1 +1 @@
-invoker.goals=site
\ No newline at end of file
+invoker.goals=verify site
\ No newline at end of file
it runs on my machine.
OMG - stupid me!
Indeed site does not triger compilation. It only worked on my machines as I once executed mvn install
directly in src/it/projects/jaxrs-json-simple
and theerfore the target folder was containing the compiled class files in src
and these where copied to target/it/
so it worked.
I was really blind to find this one. @mfriedenhagen thank you so much :+1: you saved my day!
https://travis-ci.org/mojohaus/servicedocgen-maven-plugin/jobs/96928943