Gradle 将工件部署到本地目录内的 Maven 存储库

2024-04-22

Gradle 与 Maven 的等价物是什么:

<distributionManagement>
    <repository>
        <id>internal.repo</id>
        <name>Temporary Staging Repository</name>
        <url>file://${project.build.directory}/mvn-repo</url>
    </repository>
</distributionManagement>

<build>
 <plugins>
    <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.8.1</version>
        <configuration>
               <altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository>
        </configuration>
    </plugin>
 </plugins>
</build>

我努力了:

apply plugin: 'maven'

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "file:///tmp/mvn-repo")
        }
    }
}

但它抛出:

[ant:null] Error reading settings file '/private/var/folders/KH/KH+cubLjEESWzOTqVrx-bU+++TI/-Tmp-/gradle_empty_settings7564764539012703872.xml' - ignoring. Error was: /private/var/folders/KH/KH+cubLjEESWzOTqVrx-bU+++TI/-Tmp-/gradle_empty_settings7564764539012703872.xml (No such file or directory)

我正在做的项目是git://github.com/SpringSource/spring-data-rest.git branch 1.0.0.RELEASE, 项目的build.gradle https://fisheye.springsource.org/browse/~br=1.0.0.RELEASE/datarest/build.gradle?r=316ac5d9424435f6c09c4baa4f3109f840f93cf1.

完整的 Gradle 输出:

gradle uploadArchives
The groovy configuration has been deprecated and is scheduled to be removed in Gradle 2.0. Typically, usages of 'groovy' can simply be replaced with 'compile'. In some cases, it may be necessary to additionally configure the 'groovyClasspath' property of GroovyCompile and Groovydoc tasks.
:uploadArchives
[ant:null] Error reading settings file '/private/var/folders/KH/KH+cubLjEESWzOTqVrx-bU+++TI/-Tmp-/gradle_empty_settings396071803108301794.xml' - ignoring. Error was: /private/var/folders/KH/KH+cubLjEESWzOTqVrx-bU+++TI/-Tmp-/gradle_empty_settings396071803108301794.xml (No such file or directory)
:spring-data-rest-core:compileJava UP-TO-DATE
:spring-data-rest-core:compileGroovy UP-TO-DATE
:spring-data-rest-core:processResources UP-TO-DATE
:spring-data-rest-core:classes UP-TO-DATE
:spring-data-rest-core:jar UP-TO-DATE
:spring-data-rest-core:javadoc UP-TO-DATE
:spring-data-rest-core:javadocJar UP-TO-DATE
:spring-data-rest-core:sourcesJar UP-TO-DATE
:spring-data-rest-core:uploadArchives
:spring-data-rest-repository:compileJava UP-TO-DATE
:spring-data-rest-repository:compileGroovy UP-TO-DATE
:spring-data-rest-repository:processResources UP-TO-DATE
:spring-data-rest-repository:classes UP-TO-DATE
:spring-data-rest-repository:jar UP-TO-DATE
:spring-data-rest-repository:javadoc UP-TO-DATE
:spring-data-rest-repository:javadocJar UP-TO-DATE
:spring-data-rest-repository:sourcesJar UP-TO-DATE
:spring-data-rest-repository:uploadArchives
:spring-data-rest-webmvc:compileJava UP-TO-DATE
:spring-data-rest-webmvc:compileGroovy UP-TO-DATE
:spring-data-rest-webmvc:processResources UP-TO-DATE
:spring-data-rest-webmvc:classes UP-TO-DATE
:spring-data-rest-webmvc:jar UP-TO-DATE
:spring-data-rest-webmvc:javadoc UP-TO-DATE
:spring-data-rest-webmvc:javadocJar UP-TO-DATE
:spring-data-rest-webmvc:sourcesJar UP-TO-DATE
:spring-data-rest-webmvc:uploadArchives

我使用 Gradle 1.12。


如果您尝试在本地部署(例如〜/.m2),那么您需要:

apply plugin: 'maven'

uploadArchives {
    repositories {
        mavenDeployer {
            mavenLocal()
        }
    }
}

我没有尝试过使用默认存储库以外的任何存储库,但我相信您可以在 ~/.m2/settings.xml 中设置存储库位置:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
  http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>/tmp/mvn_repo</localRepository>
  ...
</settings>

或者您可以在 gradle 构建文件中设置 url:

maven {
     url uri('/tmp/mvn_repo')
} 
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Gradle 将工件部署到本地目录内的 Maven 存储库 的相关文章

随机推荐