`mvn jgitflow:release-finish` 多模块构建中的错误(由于错误的编译顺序)
Posted
技术标签:
【中文标题】`mvn jgitflow:release-finish` 多模块构建中的错误(由于错误的编译顺序)【英文标题】:Error in `mvn jgitflow:release-finish` mutli-module build (due to wrong compilation order) 【发布时间】:2015-06-09 16:31:02 【问题描述】:我正在尝试使用 JGitflow 为我的项目创建一个版本。不幸的是,当我运行mvn jgitflow:release-finish
时,我收到以下错误:
Unable to find resource 'org.jorlib:jorlib-core:jar:1.0' in repository central (http://repo1.maven.org/maven2)
[WARNING] The dependency: org.jorlib:jorlib-core:jar:1.0 can't be resolved but has been found in the reactor.
我不确定如何解决这个问题。首先我跑了:mvn jgitflow:release-start
,它报告了“构建成功”。结果看起来是正确的:
jkinable@daedalus:~/workspace/javaIDEA/jORLib/jorlib$ git branch -avv
development 07e4c1f [origin/development: ahead 3] updating poms for 1.1-SNAPSHOT development
master f3240f9 [origin/master] Updated pom.xml
*release/1.0 f3240f9 Updated pom.xml
接下来我运行 mvn jgitflow:release-finish
失败了。它似乎试图下载jorlib-core-1.0.jar
,但这是它应该编译的文件。深入挖掘,我跑了mvn jgitflow:release-finish -e -X > ~/mygitflow.log
以下是部分结果:
[INFO] Building JORLib - Parent
[INFO] task-segment: [jgitflow:release-finish] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[DEBUG] org.jorlib:jorlib:pom:1.0-SNAPSHOT (selected for null)
[DEBUG] org.jorlib:jorlib-core:jar:1.0-SNAPSHOT (selected for null)
[DEBUG] junit:junit:jar:4.12:test (selected for test)
[DEBUG] Retrieving parent-POM: org.hamcrest:hamcrest-parent:pom:1.3 for project: null:hamcrest-core:jar:null from the repository.
[DEBUG] org.hamcrest:hamcrest-core:jar:1.3:test (selected for test)
[DEBUG] Retrieving parent-POM: org.jgrapht:jgrapht:pom:0.9.0 for project: null:jgrapht-core:jar:null from the repository.
[DEBUG] Adding managed dependencies for unknown:jgrapht-core
[DEBUG] org.jgrapht:jgrapht-core:jar:0.9.0
[DEBUG] org.jgrapht:jgrapht-ext:jar:0.9.0
[DEBUG] org.jgrapht:jgrapht-demo:jar:0.9.0
[DEBUG] xmlunit:xmlunit:jar:1.3:test
[DEBUG] junit:junit:jar:4.10:test
[DEBUG] org.jgrapht:jgrapht-core:jar:0.9.0:compile (selected for compile)
[DEBUG] Retrieving parent-POM: com.google.guava:guava-parent:pom:14.0.1 for project: null:guava:bundle:null from the repository.
[DEBUG] com.google.guava:guava:jar:14.0.1:compile (selected for compile)
[DEBUG] Retrieving parent-POM: ch.qos.logback:logback-parent:pom:0.9.28 for project: null:logback-classic:jar:null from the repository.
[DEBUG] Adding managed dependencies for unknown:logback-classic
[DEBUG] ch.qos.logback:logback-core:jar:0.9.28
[DEBUG] ch.qos.logback:logback-core:test-jar:tests:0.9.28
[DEBUG] ch.qos.logback:logback-classic:jar:0.9.28
[DEBUG] ch.qos.logback:logback-access:jar:0.9.28
[DEBUG] org.slf4j:slf4j-api:jar:1.6.1
[DEBUG] janino:janino:jar:2.5.10
[DEBUG] org.codehaus.groovy:groovy-all:jar:1.7.2
[DEBUG] javax.mail:mail:jar:1.4
[DEBUG] dom4j:dom4j:jar:1.6.1
[DEBUG] hsqldb:hsqldb:jar:1.8.0.7
[DEBUG] com.h2database:h2:jar:1.2.132
[DEBUG] postgresql:postgresql:jar:8.4-701.jdbc4
[DEBUG] mysql:mysql-connector-java:jar:5.1.9
[DEBUG] org.apache.tomcat:catalina:jar:6.0.20
[DEBUG] org.mortbay.jetty:jetty:jar:6.1.1
[DEBUG] org.eclipse.jetty:jetty-server:jar:7.0.1.v20091125
[DEBUG] org.mortbay.jetty:servlet-api-2.5:jar:6.1.1
[DEBUG] org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.0
[DEBUG] javax.servlet:servlet-api:jar:2.5
[DEBUG] org.scala-lang:scala-library:jar:2.7.7
[DEBUG] ch.qos.logback:logback-classic:jar:0.9.28:compile (selected for compile)
[DEBUG] Adding managed dependencies for unknown:logback-core
[DEBUG] ch.qos.logback:logback-core:jar:0.9.28
[DEBUG] ch.qos.logback:logback-core:test-jar:tests:0.9.28
[DEBUG] ch.qos.logback:logback-classic:jar:0.9.28
[DEBUG] ch.qos.logback:logback-access:jar:0.9.28
[DEBUG] org.slf4j:slf4j-api:jar:1.6.1
[DEBUG] janino:janino:jar:2.5.10
[DEBUG] org.codehaus.groovy:groovy-all:jar:1.7.2
[DEBUG] javax.mail:mail:jar:1.4
[DEBUG] dom4j:dom4j:jar:1.6.1
[DEBUG] hsqldb:hsqldb:jar:1.8.0.7
[DEBUG] com.h2database:h2:jar:1.2.132
[DEBUG] postgresql:postgresql:jar:8.4-701.jdbc4
[DEBUG] mysql:mysql-connector-java:jar:5.1.9
[DEBUG] org.apache.tomcat:catalina:jar:6.0.20
[DEBUG] org.mortbay.jetty:jetty:jar:6.1.1
[DEBUG] org.eclipse.jetty:jetty-server:jar:7.0.1.v20091125
[DEBUG] org.mortbay.jetty:servlet-api-2.5:jar:6.1.1
[DEBUG] org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.0
[DEBUG] javax.servlet:servlet-api:jar:2.5
[DEBUG] org.scala-lang:scala-library:jar:2.7.7
[DEBUG] ch.qos.logback:logback-core:jar:0.9.28:compile (selected for compile)
[DEBUG] Retrieving parent-POM: org.slf4j:slf4j-parent:pom:1.6.1 for project: org.slf4j:slf4j-api:jar:null from the repository.
[DEBUG] Adding managed dependencies for org.slf4j:slf4j-api
[DEBUG] org.slf4j:slf4j-api:jar:1.6.1
[DEBUG] org.slf4j:slf4j-jdk14:jar:1.6.1
[DEBUG] log4j:log4j:jar:1.2.16
[DEBUG] ch.qos.cal10n:cal10n-api:jar:0.7.4
[DEBUG] org.slf4j:slf4j-api:jar:1.6.1:compile (selected for compile)
[DEBUG] ch.qos.logback:logback-core:jar:0.9.28:compile (selected for compile)
[DEBUG] org.slf4j:slf4j-api:jar:1.6.1:compile (selected for compile)
[DEBUG] WARNING: A dependency of the current project (or of one the plugins used in its build) was found in the reactor,
but had not been built at the time it was requested. It will be resolved from the repository instead.
Current Project: JORLib - Demo
Requested Dependency: org.jorlib:jorlib-core:jar:1.0-SNAPSHOT
NOTE: You may need to run this build to the 'compile' lifecycle phase, or farther, in order to build the dependency artifact.
模块jorlib-demo
依赖于jorlib-core
,所以在编译jorlib-demo
之前必须先编译jorlib-core
。由于某种原因,这不会发生。结果,它在某个外部存储库中搜索jorlib-core
,最终因为找不到它而失败。
-
我的父母pom:parent pom
jorlib-core 中的 pom:pom jorlib-core
jorlib-demo 中的 pom:pom jorlib-demo
【问题讨论】:
【参考方案1】:原来这个问题是我的Maven版本引起的。我的系统运行 Java 1.8.0_45 和 Apache Maven 2.2.1 (rdebian-8)。在撰写本文时,最新的 Ubuntu LTS (14.04.2) 版本默认附带后一个 Maven 版本。我现在已经升级到 Apache Maven 3.2.1。升级到 Maven 3 后,我在执行 jgitflow:release-finish 时确实遇到了以下错误消息:
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/lib/jvm/java-8-oracle/bin/java/bin/java
这实际上禁止了代码被编译。注意奇怪的bin/java/bin/java
部分。我仔细检查了我的$JAVA_HOME
,它正确指向了/usr/lib/jvm/java-8-oracle/
。可以在此处找到此问题的解决方案:Having JAVA_HOME inconsistency issue with maven
我只是在我的主文件夹中创建了一个名为 .mavenrc 的文件,其中包含:export JAVA_HOME=/usr/lib/jvm/java-8-oracle
现在 Jgitflow 插件运行良好。
【讨论】:
以上是关于`mvn jgitflow:release-finish` 多模块构建中的错误(由于错误的编译顺序)的主要内容,如果未能解决你的问题,请参考以下文章
Apache Maven IDEA Plugin Usage(mvn idea:idea/mvn idea:clean/mvn idea:project)
“mvn clean install”与“mvn install”有何不同?