Grails 2.2.0应用程序的Maven构建失败,出现JDK 1.7:无法找到工件com.sun:tools:jar:1.6 [英] Maven build for Grails 2.2.0 app fails with JDK 1.7: Could not find artifact com.sun:tools:jar:1.6
问题描述
(由于更新的问题/问题而更新了问题标题,请在底部查看我的更新注释!):
Grails 2.2.0项目,通过' grails create-pom com.mycompany
'为其创建了pom.xml。pom.xml:
(Updated question title due to updated question/problem, please see my update notes at the bottom!):
I have a Grails 2.2.0 project, created the pom.xml for it via 'grails create-pom com.mycompany
'.
pom.xml: http://pastebin.com/AVahZjZF
Without modifications to the pom.xml, I run 'mvn package
' with JDK 1.7 and getting the error below, while with JDK 1.6 it would work fine.
$ java -version
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
$ mvn -version
Apache Maven 3.0.3 (r1075438; 2011-03-01 01:31:09+0800)
Maven home: /usr/share/maven
Java version: 1.7.0_11, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.7.4", arch: "x86_64", family: "mac"
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home
$ mvn package
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.company:company-projectname:0.1 (/Users/myuser/Projects/com.company.web/pom.xml) has 2 errors
[ERROR] Unresolveable build extension: Plugin org.grails:grails-maven-plugin:2.2.0 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:1.6 at specified path /Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/jre/bundle/Classes/classes.jar -> [Help 2]
[ERROR] Unknown packaging: grails-app @ line 8, column 16
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
I see that the java version is set to 1.6 in grails-maven-plugin-2.2.0.pom, thus my question now: how to make the maven build for my grails project work with JDK 1.7? It looks as if the correct source and target level is set in maven-compiler-plugin (set to 1.6).
Folder ~/.m2/repository/grails-maven-plugin:
My environment:
- Maven 3.0.3
- Grails 2.2.0
- GRAILS_HOME set to my Grails directory
- JAVA_HOME set to my JDK 1.7 folder
- JDK 1.7.0_11
Relevant java tools section in my pom.xml:
<profiles>
<profile>
<id>tools</id>
<activation>
<property>
<name>java.vendor</name>
<value>Sun Microsystems Inc.</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>${java.version}</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
It seems to be a known issue and reportedly still happening in Grails 2.2.0 on Mac OS X.
http://jira.grails.org/browse/MAVEN-186
这篇关于Grails 2.2.0应用程序的Maven构建失败,出现JDK 1.7:无法找到工件com.sun:tools:jar:1.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!