当前位置: 首页 > 知识库问答 >
问题:

Gradle 依赖项解决了配置文件问题

储志业
2023-03-14

我已经在build.xml中构建了一个maven项目A,包括使用另一个pom导入所有测试依赖项。当我试图将maven项目A包含到gradle项目B中时,它给出了错误。

我尝试使用[--info]首先尝试正确的存储库URL并更新jar [缓存的资源是最新的]。但最终它会尝试其他人并抛出错误。

如何从gradle构建文件中传递配置文件名?

感谢您的帮助。

项目A-

<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-

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

共有1个答案

傅星光
2023-03-14

您可以使用Gradle maven设置插件https://plugins.gradle.org/plugin/net.linguica.maven-settings.使用maven设置插件,您可以传递activeProfiles,自定义maven设置文件。

 类似资料:
  • 我无法按配置名称检索预期的依赖项。我有一个共享库,我将使用以下 ivy 文件发布到本地存储库: 到目前为止,一切都很好。我发布了jar,如果我尝试通过配置检索它的依赖项,我会得到我期望的结果,运行时配置中有两个依赖项,提供的和测试配置中各有六个依赖项。当我试图检索依赖于的依赖项时,问题就开始了。我使用这个常春藤文件: 现在,如果我尝试检索配置,而不是获取jar、 0.05 my module,我会

  • TL;DR两个gradle插件使用相同依赖项的不同版本,在调用其中一个插件时会导致编译错误。 > 我有一个使用Gradle4编译的Java项目。十、 该项目依赖于两个插件:gradle-jaxb-plugin和serenity-gradle-plugin。 两个插件共享一个依赖项,guice。 我需要升级一个插件(serenety)。升级会导致调用jaxb插件时发生冲突。 我做了一些调查和谷歌搜索

  • 我试图解决依赖在配置阶段与工件gradle插件。 它给了我 无法解析配置“: compile”的所有依赖项。无法解析外部依赖项Commons-lang: Commons-lang:,因为没有定义存储库。 它在执行阶段是一种魅力 或者当我使用mavenCentral()时

  • 我的结构如下: 项目A- 项目B- 编译项目B一切正常: 项目B/build.gradle: ProjectB/settings.gradle: 然而,在编译ProjectA时,它表示找不到ProjectC ProjectA/build.gradle: ProjectA/settings.gradle: 这将显示以下错误: 其中:构建文件ProjectB\build.gradle 出了什么问题:

  • 我的应用程序的build.gradle如下所示:应用插件:'com.android.application' 我尝试过更改存储库(jcenter()、mavenCentral()等)、重新安装Android Studio、JDK(7和8)、更改Gradle版本和Android SDK版本,这些都没有奏效。运行./gradlew build时,我得到: 这是我在其他情况下也会遇到的错误,例如,当尝试

  • 我定义了一个定制的gradle插件,它的输出是MyPlugin。罐子我将jar放在build_libs dir中。以下是我使用它的方式:1)在项目构建中。格拉德尔 2)在app模块build.gradle 3)当我运行。/gradlew组装 > 错误:配置根项目“MyApp”时出现问题。 无法解决配置: classpath的所有依赖项。找不到com.wonbin.myplugin: MyPlugi