Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin - java

I'm trying compile using mvn install but I'm getting this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project test: Compilation failure: Compilation failure:
pom.xml file:
<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>com.mycompany</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.mycompany.test.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
How to fix it?

Your issue is most likely the <scope> of the dependency. When inside of the IDE, all scopes are added to the build path of the project. However, when running mvn only the appropriate scopes are added to the classpath for the javac command. For example, if you had a class in /src/main/java that imported a class from one of your dependencies scoped to <scope>test</scope>, the IDE would be able to build the project, but mvn would fail in the manner you are experiencing.

I encountered a similar error when trying to download and compile the aws kinesis consumer library (kcl)
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) # amazon-kinesis-client ---
[INFO] Compiling 81 source files to /opt/speedshiftmedia/aws.kcl/1.1.0/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.822s
[INFO] Finished at: Tue Jul 22 12:31:39 PDT 2014
[INFO] Final Memory: 4M/56M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project amazon-kinesis-client: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] javac: invalid target release: 1.7
It turns out that while I had updated my version of Java from 1.6 to 1.7, I had not updated Javac from 1.6 to 1.7.
To do so I used the following command on ubuntu
sudo update-alternatives --config javac
And then choose the desired version at the prompt.
There are 2 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/bin/javac 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/bin/javac 1061 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/bin/javac 1051 manual mode
Press enter to keep the current choice[*], or type selection number:
I hope this helps someone else.

Related

Fatal error compiling: invalid target release: 11 during pushing to heroku

im trying to deploy my back end application to heroku
bun when I run this command
git push --force heroku-be-app splitting-staging-be:master
im getting this error
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/2.0-M9/qdox-2.0-M9.jar (317 kB at 7.6 MB/s)
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 24 source files to /tmp/build_4e875976/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.593 s
[INFO] Finished at: 2020-12-21T15:28:14Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project backend: Fatal error compiling: invalid target release: 11 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/MojoExecutionException
! ERROR: Failed to build app with Maven
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/
! Push rejected, failed to compile Java app.
! Push failed
This is my pom 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>vs</groupId>
<artifactId>backend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>backend</name>
<description>Main server voor van streek project</description>
<properties>
<java.version>15</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>5.4.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>5.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>15</source> <!-- maven.compiler.source -->
<target>15</target> <!-- maven.compiler.target -->
</configuration>
</plugin>
</plugins>
</build>
</project>
I solved this problem by adding a new file system.properties and the content added to the file is java.runtime.version=11 (For me I am using JDK 11).
java.runtime.version=11
I would try focusing on why maven complains about invalid release 11 (Fatal error compiling: invalid target release: 11).
As seen in your pom.xml config you clearly intend to use version 15, so I would suggest to investigate why there is a problem with version 11.
Check $JAVA_HOME environment variable, system.properties file, etc.
Also try debug route suggested in official docs or a Q&A on a similar topic.
You must use the specific version of Java supported by Heroku. The following versions supported are:
Java 7 - 1.7.0_292
Java 8 - 1.8.0_282
Java 11 - 11.0.10
Java 13 - 13.0.6
Java 15 - 15.0.2
Set a java.runtime.version property of the system.properties file, create a system.properties file if one does not already exist.
java.runtime.version = SUPPORTED_VERSION
Read more in heroku-java-support
This is what I have experienced today.
I have been using jdk 1.8, and then have to install jdk 1.11.
But, after running mvnw through my shell script file dep.sh, it failed to build jar.
#!/bin/bash
MVN=$(pwd)/mvnw
echo "[1/2] Building app.jar ..."
$MVN clean package -Dmaven.test.skip=true
dep.sh calls mvnw script file with goal clan package
Error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile
(default-compile) on project dictation:
Fatal error compiling: invalid target release: 11 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/MojoExecutionException
My pom.xml is configured with jdk 1.11. But it does not solve the build error.
<project ...>
<properties>
<java.version>11</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source><!-- 1.11 not working -->
<target>11</target><!-- 1.11 not working -->
</configuration>
</plugin>
</plugins>
</build>
</project>
build failure
When I installed jdk 1.8, JAVA_HOME was set to /my/jdk/1.8/dir, which is used for bundling jar.
I set JAVA_HOME to /my/jdk/1.111/dir in dep.sh, it works without error.
#!/bin/bash
JAVA_HOME="/C/Program Files/Java/jdk-11.0.9"
MVN=$(pwd)/mvnw
echo "[1/2] Building app.jar ..."
$MVN clean package -Dmaven.test.skip=true
create system.properties file and Add java.runtime.version=11

Shippable "Failed to execute goal org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument"

I am currently doing a software engineering module where we learn about CI and TDD. As an assignment we must create a Java project using maven, JUnit, and Shippable. My files include three java classes (Student, Course, and Module classes) and a simple test for each that tests getters and setters.
I am using:
Apache NetBeans 12.0
Maven (default is 3.6.3 but I added a plugin for 3.8)
Openjdk11
My pom 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>com.nuig</groupId>
<artifactId>assignment1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<name>assignment1</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release> <!--or <release>10</release>-->
</configuration>
</plugin>
</plugins>
</build>
</project>
And shippable.yml file:
language: java
jdk:
- openjdk11
after_success:
- mvn clean verify
- mvn clean cobertura:cobertura
- mvn test
When I build the code in netbeans, it builds and passes the tests fine. But once I push and go to shippable console, it keeps failing at mvn clean cobertura:cobertura with the following error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.165 s
[INFO] Finished at: 2020-10-11T00:26:35Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument (default-cli) on project assignment1: Execution default-cli of goal org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument failed: Plugin org.codehaus.mojo:cobertura-maven-plugin:2.7 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:0 at specified path /usr/lib/jvm/java-11-openjdk-amd64/../lib/tools.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/PluginResolutionException
I am really unfamiliar with all these technologies and I have already tried several suggestions from answers to similar questions but to no vail.
Would anyone be able to help with this issue? Much appreciated.

maven-plugin-plugin:3.3:descriptor failed.: RuntimeException when updating maven-core

I am in the process of upgrading maven and some maven dependencies that used to work but im getting a RuntimeException after upgrading.
I have removed the logic from my maven plugin, so its pure apache maven code and none of my own:
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
#Mojo(name = "hello", requiresProject = true, defaultPhase = LifecyclePhase.PROCESS_RESOURCES)
public class HelloMojo extends AbstractMojo {
public void execute() throws MojoExecutionException {
System.out.println("Hello There!");
}
}
I currently have the following pom file which works fine:
<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>org.example</groupId>
<artifactId>hello-maven-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<!-- Changing this to 3.5.4 works -->
<version>3.6.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.3</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
</plugin>
</plugins>
</build>
</project>
But after doing a mvn versions:use-latest-versions it updates maven-core and everything from version 3.6.0+ is causing the following error when doing a mvn install:
[INFO] --- maven-plugin-plugin:3.3:descriptor (default-descriptor) # hello-maven-plugin ---
[WARNING] Using platform encoding (Cp1252 actually) to read mojo metadata, i.e. build is platform dependent!
[INFO] Applying mojo extractor for language: java
[INFO] Mojo extractor for language: java found 0 mojo descriptors.
[INFO] Applying mojo extractor for language: bsh
[INFO] Mojo extractor for language: bsh found 0 mojo descriptors.
[INFO] Applying mojo extractor for language: java-annotations
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.110 s
[INFO] Finished at: 2020-03-16T16:30:04-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.3:descriptor (default-descriptor) on project hello-maven-plugin: Execution default-descriptor of goal org.apache.maven.plugins:maven-plugin-plugin:3.3:descriptor failed.: RuntimeException -> [Help 1]
Is there anything else that I need to change when upgrading to maven core 3.6.3?

Maven Failed to execute goal com.jayway.maven.plugins.android.generation2

I want a simple android hello world program in with maven.here is my 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>appzoyfoo141</groupId>
<artifactId>ekanta</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>
<name>ekanta</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version>4.1.1.4</platform.version>
<android.plugin.version>3.1.1</android.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android.plugin.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>17</platform>
<path>${ANDROID_HOME}</path>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>
But while trying to run the pom.xml rightclick pom.xml->runas->maven test..getting this error
Failed to execute goal com.jayway.maven.plugins.android.generation2`..Can anybody plz help me..thanks i am getting this error in console`[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.613s
[INFO] Finished at: Thu Jan 09 14:47:46 IST 2014
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources (default-generate-sources) on project ekanta: No Android SDK path could be found. You may configure it in the plugin configuration section in the pom file using <sdk><path>...</path></sdk> or <properties><android.sdk.path>...</android.sdk.path></properties> or on command-line using -Dandroid.sdk.path=... or by setting environment variable ANDROID_HOME -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/MojoExecutionException`
I ran into the same problem with the com.jayway.maven plugin when trying to build Android Bootstrap project.
I was able to fix this by going into pom.xml properties section and adding my ANDROID sdk path.
<properties>
<abs.version>4.3.1</abs.version>
<dagger.version>1.0.1</dagger.version>
<otto.version>1.3.4</otto.version>
<gson.version>2.2.4</gson.version>
<menudrawer.version>3.0.2</menudrawer.version>
<android.sdk.path>C:\Android\adt-bundle-windows-x86_64-20131030\sdk</android.sdk.path>
</properties>
I originally had it pointing to my JAVA SDK which was causing it to fail -- you need to point this to your ANDROID sdk.
This path is not set: ANDROID_HOME and your SDK may be too low a version. And then after setting.xml set full path android sdk.

Why did maven suddenly start compiling with an older version of Java?

I've been developing in Java using maven for a few days now. Today I edited my pom.xml based on these instructions. Suddenly running mvn compile is giving me errors as if I was compiling with an older version of java. Stuff like:
error: generics are not supported in -source 1.3
Now I've paired my pom.xml back to its original content, and I'm still getting this error. I've done a mvn clean and deleted everything under target, and am still having this problem.
Here's a snippet of maven running the compilation phase:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building bahToBeh 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) # bahToBeh ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/doug/lucid/bah-bio-demo/bahToBeh/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) # bahToBeh ---
[INFO] Compiling 9 source files to /home/doug/lucid/bah-bio-demo/bahToBeh/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.880s
[INFO] Finished at: Thu Dec 20 13:52:06 EST 2012
[INFO] Final Memory: 7M/105M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project bahToBeh: Compilation failure: Compilation failure:
[ERROR] /home/doug/lucid/bah-bio-demo/bahToBeh/src/main/java/com/lucid/bahdemo/parsers/pm/MeshReader.java:[23,4] error: generics are not supported in -source 1.3
And my paired-down pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.lucid</groupId>
<artifactId>bahToBeh</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>bahToBeh</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.digitalpebble</groupId>
<artifactId>behemoth-core</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>marc4j</groupId>
<artifactId>marc4j</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
This had been working fine up until today. I'm not sure what setting I might have changed or how I could have munged up my project. I even double checked that the correct versions of java are installed:
doug#doug-VirtualBox:~/lucid/bah-bio-demo/bahToBeh$ java -version
java version "1.7.0_10"
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
doug#doug-VirtualBox:~/lucid/bah-bio-demo/bahToBeh$ javac -version
javac 1.7.0_10
Here is JAVA_HOME
doug#doug-VirtualBox:~/lucid/bah-bio-demo/bahToBeh$ echo $JAVA_HOME
/usr/lib/jvm/java-7-oracle
Maven IS using the pom.xml I think it is, if I run mvn -X compile I get:
DEBUG] (f) project = MavenProject: com.lucid:bahToBeh:1.0-SNAPSHOT # /home/doug/lucid/bah-bio-demo/bahToBeh/pom.xml
I've also deleted my maven repo rm -rf ~/.m2 and saw maven redownload everything same problem.
EDIT -- It suddenly works mysteriously
I have no idea what happened, but suddenly now its working. I thought that one thing I changed was I commented out a test. I went and uncommented out the test and then ran mvn compile and this time it compiled. Some state somewhere was out-of-sync and now things magically work?
I hate not knowing why my tools suddenly go wonky, so this is not an answer to the question, merely more information.
EDIT -- and it also just suddenly STOPPED working again
Looks like fully specifying the version to compile works though, so dingding thats the winner.
Set the source and target java versions explicitly. http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
<project>
[...]
<build>
[...]
<plugins>
<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>
</plugins>
[...]
</build>
[...]
</project>
As a workaround you can try this (given that it is very specific to an environment, this could help).
You can enforce the version of compilation using the plugin.
Maven compilation plugin.
Good luck!

Categories