I am trying to build an existing maven project on a fresh install of the latest netbeans but am getting the following error, any help is much appreciated:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project com.rory.ngp.test: Compilation failure
Failure executing javac, but could not parse the error:
javac: invalid target release: 1.7
I think it has something to do with paths but am not sure exactly. Here is the contents of my /usr/lib/jvm directory;
bash-4.1$ pwd
/usr/lib/jvm
bash-4.1$ ls
java java-openjdk jre-1.6.0-openjdk.x86_64
java-1.5.0-gcj-1.5.0.0 jre jre-gcj
java-1.6.0 jre-1.5.0 jre-openjdk
java-1.6.0-openjdk-1.6.0.0.x86_64 jre-1.5.0-gcj
java-1.6.0-openjdk.x86_64 jre-1.6.0
Thanks oers, you were right.
I needed to install JDK 1.7/Java 7, and then edit the netbeans config file in the netbeans install directory /etc/netbeans.conf to point to where I installed the new version of Java:
# Default location of JDK, can be overridden by using --jdkhome <dir>:
netbeans_jdkhome="/users/rory/Documents/jdk1.7.0_02"
Add the following to your pom under build and plugins it should target 1.6
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
If Platform or Source/Binary Format in project properties is not same with this configuration it gives error
Related
Over the last few years, for our Parent POM project in Eclipse, I've had to employ slightly different tweaks to Eclipse's configuration, to avoid having Eclipse give errors like:
...target/classes/META-INF/MANIFEST.MF (No such file or directory) pom.xml
I know I can manually rid these errors, by right-clicking the parent project and doing
Maven > Update Project
but that only works until the next build when I do another "clean install".
In the past, I got Eclipse to stop complaining by making these 2 Eclipse tweaks:
Preferences > Maven > check "Automatically update Maven projects configuration (experimental)"
Preferences > Maven > Java EE Integration > uncheck "Maven Archiver generates files under the build directory".
But, this no longer work, with the latest versions of Eclipse (e.g., Version: 2021-03).
Why does Eclipse do this and how can I rid myself of this annoyance, once and for all?
I found a solution.
The problem is caused by the standard maven-compiler-plugin. When it generates a JAR file, it deletes target/classes/META-INF/MANIFEST.MF.
Eventually (but not right away), Eclipse notices this and complains that the manifest file is missing.
Cleaning the project (as often recommended in related Stack Overflow questions) is not a solution. Although it makes the errors go away temporarily, the errors will soon return, the next time maven-compiler-plugin generates another JAR file.
A permanent solution is to include this additional plugin to my POM, which not just generates a manifest file, but KEEPS it at target/classes/META-INF/MANIFEST.MF:
...
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>compile</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<index>true</index>
<manifest>
<addDefaultSpecificationEntries>false</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>false</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
...
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
...
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
...
</plugin>
</plugins>
...
</build>
...
I'm using scala-maven-plugin to build a Scala project using Maven. My project depends on some libraries from Java 8. I would like to specify in my pom that the project requires Java 8 (using something akin to -target=jdk-1.8, which appears not to exist) so that it will fail a little more elegantly/informatively when someone tries to compile using Java version < 8. Currently it just fails to find the packages I'm trying to import.
I tried adding maven-compiler-plugin with source and target set to 1.8, and this didn't work, presumably because scala-maven-plugin is handling compilation instead of maven-compiler-plugin.
Is this possible?
You can use Maven Enforcer Plugin to enforce some rules to be asserted when running your Maven build.
Here you want to make sure that the Java version used is at least 8. You can achieve this by adding the following to your pom.xml file:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.8,)</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I am trying to rebuild Hibernate configuration but i got Wrong Compiler Settings error, please find below screenshots of my App configuration and a of the error:
The problem was because Eclipse ran on a different JVM than the one specified in my project (I have two installed JDK on my machine), to resolve that i just modified the file eclipse.init in a way to ensure Eclipse will run the appropriate JVM.
This is what i added to eclipse.init (you need to use your exact path to javaw.exe):
-vm
C:\Program Files\Java\jdk1.6.0_45\bin\javaw.exe
Further informations regarding the eclipse.init file, could be found here.
It seems that you are using maven so you need to adjust it in the compile plugin it your POM
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
for more details check this example
I'm developing a Java web project in Eclipse (STS version 2.8.1.RELEASE) with Maven (version 2.2.1) and unit tests written in Groovy. The unit tests are located under src/test/groovy. Furthermore I'm using the m2eclipse plugin for Eclipse (version 1.0) and the Gmaven plugin in Maven (version 1.3).
Building in Maven works without problems: the groovy files are compiled and executed as tests. For the unit tests to work in Eclipse I added the Groovy nature to the project, added the folder src/test/groovy under Configure Build Path... and set the output folder to target/test-classes.
This works until I do an update of the project configuration under Maven -> Update Project Configuration.... After I do this every time the directory src/test/groovy gets removed from the source folders in Eclipse and I have to add it again and set the output directory.
Is there something I am missing or why is Eclipse deleting my source folder configuration every time I do an update of the project configuration?
My GMaven configuration looks as follows:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.3</version>
<configuration>
<providerSelection>1.7</providerSelection>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Using the builder-helper-maven-plugin helped. Eclipse adds the source folder and sets the output folder correctly. I used the following configuration:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/groovy</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
I had a similar issue, mine was that eclipse was preventing me from writing groovy files into java folder. But you could try the same configuration out, or check out my whole pom at github
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<additionalProjectnatures>
<projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
</additionalProjectnatures>
<!-- Source includes is necessary to allow groovy files in the java
folder, else eclipse will throw a filtering exception -->
<sourceIncludes>
<sourceInclude>**/*.groovy</sourceInclude>
</sourceIncludes>
<!-- Download sources will make maven download and attach source files
where available -->
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
After I put in this configuration in the pom, the .classpath got generated properly.
Check out this issue on SoF here. You need to add the build-helper-maven-plugin to get the resources added.
You need to install the groovy-eclipse configurator for m2eclipse. It is available from this update site:
http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.7/
If you are using m2eclipse v1.0 or later, then choose to install from here:
m2e Configurator for Groovy-Eclipse (Optional)
If you are using an older version of m2eclipse, then install from here:
Groovy-Eclipse m2eclipse integration pre v1.0 (deprecated)
Try by adding your Groovy source directory.
I have a library of JavaScript in dependency globalmentor-core.jar, and I use maven-dependency in another project to transfer the JavaScript to a web directory:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>unpack</id>
<phase>process-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.globalmentor</groupId>
<artifactId>globalmentor-core</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.outputDirectory}/com/guiseframework/assets/javascript</outputDirectory>
<includes>**/*.js</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
That works wonderfully on the command-line. In Eclipse using m2eclipse I get:
2/4/11 5:26:53 AM PST: Build errors for guiseframework; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:unpack (unpack) on project guiseframework: Error unpacking file: R:\java\trunk\globalmentor-core\target\classes to: R:\java\trunk\guiseframework\target\classes\com\guiseframework\assets\javascript
org.codehaus.plexus.archiver.ArchiverException: The source must not be a directory.
The closest thing I can find is http://jira.codehaus.org/browse/MDEP-187, where someone claims they will "provide trivial patch shortly. That was in 2008.
Is there a fix for this, or am I stuck?
I've found a solution/workaround for this problem.
My configuration: Windows XP SP 3, Maven 3, JDK 1.6.0_24, Maven repository under "C:\Documents and Settings\<YOUR_ID>\.m2" folder.
Follow these steps:
Run ‘dir c:\ /X’ and look for the string with ~ in it
08/01/2011 04:53 PM DOCUME~1 Documents and Settings
Open your settings.xml file and under the <settings> tag add a localRepository tag:
<localRepository>C:/DOCUME~1/<YOUR_ID>/.m2/repository<\localRepository>
This should make the plugin work. Apparently, maven-dependency-plugin (up to version 2.3) has problems with paths including spaces in it.
Regards,
Cutberto.