I ran into a strange problem..
I work on a project that use the ProcessBuilder Class.
On my local machine (Java6 and Java7 tested) I can easily mvn clean install & mvn assembly:single the project without any errors. Now I want to let the project build by travis-ci and ran into to following error
error: no suitable constructor found for ProcessBuilder(String)
full log file here..
but the Javadoc for ProcessBuilder show me that constructor.
My .travis.yml looks like this
language: java
jdk:
- oraclejdk7
- openjdk6
- openjdk7
after_success:
- mvn assembly:single
Any ideas why the build fails on travis-ci?
Thanks, F481
Edit:
Locally I'm using Maven 3, like travis-ci too (travis doc: "Travis Java builder will use Maven 3 to build it.")
My pom.xml: https://github.com/MultiServerControl/MineControl/blob/master/pom.xml
And the java code of the first error: this.processBuilder = new ProcessBuilder("");
The full class is available here
Edit2:
I specified a source and target version for the maven compilation like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Now the build is working for JDK7: https://travis-ci.org/MultiServerControl/MineControl/jobs/5963859
But I don't get the reason for that behavior.. and I want to build the project for JDK 5,6 too.
How can I do that?
I specified the version of the maven compiler plugin and the source and target version for the compilation like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
Now the build is working! Much thanks to NilsH who pushed me in the right direction.
Related
It has been few weeks since I build anything in maven, and I just tried to build one of the projects and it gives me this error. I try with multiple project and they are throwing same error:
Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.8:compile failed: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.8 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:15.0.2 at specified path /usr/local/Cellar/openjdk/15.0.2/libexec/openjdk.jdk/Contents/Home/../lib/tools.jar -> [Help 1]
How can I resolve this error? I can't even run mvn install -DskipTests or mvn package.
I am on JDK version 8.
Edit: here is my plugin from pom:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>${aspectj-maven-plugin.version}</version>
<configuration>
<complianceLevel>${java.version}</complianceLevel>
<source>${java.version}</source>
<target>${java.version}</target>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<aspectLibraries>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-aspects</artifactId>
</dependency>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
java version = 1.8
aspectj-maven-plugin.version = 1.8
EDIT: I pull this project from the repo, which means it works on other people's computer/on jenkins. I believe this is something to do with my local computer. It also gives me same error if I use terminal.
I found the answer after more research. As #Michael Katt mentioned in the comment, my JAVA_HOME wasn't properly set up. When I did which java, it gave me /usr/bin/java, but when I did echo $JAVA_HOME, it gave me nothing.
So with help of other colleague, I did vi ~/.bash_profile and added export JAVA_HOME=$(/usr/libexec/java_home). Not exactly sure why, but it is something to do with matching it with my jdk in my project structure which has /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk...
I opened new shell and typed echo $JAVA_HOME and it gives me /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home. My project build/compiles now.
I am still not sure how $(/usr/libexec/java_home) translated to /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk...
I'm having difficulty trying to add an argument to the jvm. It looks like using surefire is the only way to do this. My current code in the pom.xml is
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<argLine>-Xmx512m</argLine>
<systemPropertyVariables>
<all.clusters>${all.clusters}</all.clusters>
<branding.token>${brandingToken}</branding.token>
</systemPropertyVariables>
</configuration>
</plugin>
Maven is new to me so perhaps I'm missing something simple.
Running in a Netbeans 8.1 environment.
Turns out that what I needed to do was not to get surefire to run with special arguments, because that only covers tests. The trick to getting it working was the fact that this project is a NetBeans application which uses the
nbm-maven-plugin.
The following blog post describes how to modify the arguments.
Blogpost
Im facing the following problem. I have set up my checkstyle with the following configuration:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<inherited/>
<configuration>
<configLocation>${basedir}/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
</plugins>
</reporting>
This runs fine when I run mvn site. However, when I run checkstyle through mvn checkstyle:checkstyle in order to get the XML report much more efficiently, the checkstyle plugin fails back to use the default configuration. When I move the plugin to <build> the XML is generated properly, but now the checkstyle report is not included in the generated site anymore.
What is the (current) way of setting up report plugins as Checkstyle, while perserving the ability to run the plugin separately under the same configuration?
Is it really the preferred way to defined your plugins and configuration twice?
Okay, apparently you should add the plugin with configuration to both <build> and <reporting>.
I am using maven2 to build the java project, when i issue the command mvn clean install i am getting the error could not parse error message: (use -source 5 or higher to enable generics).
In my eclipse environment i am using jdk 1.7 and the project is working fine. when i want to build the project i am unable to do that, think maven is taking java version 1.3 as default.
Any one please help me how to set the jdk versio to 1.7 in maven, to build the project successfully..
Apart from the jars mentioned in pom.xml i want to add add my own jar, how can i specify that in pom xml?
Thanks in advance..
In your pom.xml configure the maven-compiler-plugin to use 1.6:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
I've created a project in eclipse and added maven dependencies. In Eclipse, it says that I am using JRE 1.5. Everything works fine in Eclipse, for instance, I can run my tests.
When I try to run mvn clean install from the terminal, it gives me the following error.
...generics are not supported in -source 1.3 (use -source 5 or higher to enable generics)...
Its seems that Maven thinks I'm using JRE 1.3 and cannot recognize generics or for-each loops.
How can I:
Validate my assumption that maven is using the wrong version.
Get Maven to compile my project.
Specify the correct version of your JRE in the Maven compiler plugin, by default your pom.xml file will inherit the compiler-plugin from the Maven super pom.xml which targets the 1.3 JRE.
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>