【发布时间】:2017-08-11 13:19:07
【问题描述】:
我在 build.xml 中构建了一个 maven 项目 A,包括使用另一个 pom 导入的所有测试依赖项。 当我试图将 maven 项目 A 包含到 gradle 项目 B 中时 它给出了错误。
我首先尝试使用 [--info],它会尝试正确的存储库 url 并更新 jar [缓存资源是最新的]。但最后它会尝试其他人并抛出错误。
如何从 gradle 构建文件中传递配置文件名称?
感谢您的帮助。
项目 A -> Maven 构建 - pom.xml
<groupId>com.spring.test</groupId>
<artifactId>Rest</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Project</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<JUnitBOM.version.number>1.0.0</JUnitBOM.version.number>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<!-- Components -->
<dependency>
<groupId>com.test</groupId>
<artifactId>JUnitBOM</artifactId>
<version>${JUnitBOM.version.number}-${project.qualifier}
</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<profile>
<id>AUAT</id>
<properties>
<env>uat</env>
<project.qualifier>SNAPSHOT</project.qualifier>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
项目 B -> gradle build - build.gradle
apply plugin: 'java'
apply plugin: 'maven'
group = "com.spring.integration"
status = 'integration'
version = '1.0.0'
sourceCompatibility = 1.7
repositories {
maven { url "http://repo1" }
maven { url "http://maven.springframework.org/release" }
maven { url "http://maven.restlet.org" } }
dependencies {
compile group:'com.spring.test', name:'Rest', version:'1.0.0-SNAPSHOT', classifier: 'AUAT'
compile group:'org.restlet.jee', name:'org.restlet', version:'2.2'
compile group:'org.restlet.jee', name:'org.restlet.ext.servlet',version:'1.1'
compile group:'org.springframework', name:'spring-web', version:'3.2.1.RELEASE'
compile group:'org.slf4j', name:'slf4j-api', version:'1.7.2'
compile group:'ch.qos.logback', name:'logback-core', version:'1.0.9'
testCompile group:'junit', name:'junit', version:'4.11'
}
错误信息
Could not resolve all dependencies for configuration ':compile'.
> Could not resolve com.spring.test:Rest:1.0.0-SNAPSHOT.
Required by:
com.spring.test:0.1.0-SNAPSHOT
> Could not resolve com.test:JUnitBOM:1.0.0-${project.qualifier}.
> java.lang.IllegalArgumentException (no error message)
> java.lang.IllegalArgumentException (no error message)
> java.lang.IllegalArgumentException (no error message)
> Could not HEAD 'http://maven.restlet.org/com/spring/test/Rest/1.0.0-SNAPSHOT/Rest-1.0.0-SNAPSHOT.pom'. Received status code 409 from server: Conflict
【问题讨论】:
-
属性 project.qualifier 似乎未定义。
-
compile group:'com.spring.test', name:'Rest', version:'1.0.0-SNAPSHOT', classifier: 'AUAT'表示com.spring.test:Rest:1.0.0-SNAPSHOT:AUAT,我没有看到它是如何连接到您在POM.xml 中的profile -
com.spring.test:Rest:1.0.0-SNAPSHOT:AUAT -> 它不能作为 profile = AUAT 工作吗?我该如何解决这个问题?
-
为什么配置文件未定义我从 {project.qualifier} 生成第一个 jar 分类器。
-
AUAT是分类器而不是 profile.qualifier,如 jar 或 war
标签: java maven gradle maven-2 maven-plugin