gpt4 book ai didi

maven - Gradle 将 Artifact 部署到本地目录中的 Maven 存储库

转载 作者:行者123 更新时间:2023-12-04 13:50:19 28 4
gpt4 key购买 nike

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分公司 1.0.0.RELEASE , project's build.gradle .

完整的 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')
}

关于maven - Gradle 将 Artifact 部署到本地目录中的 Maven 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24010626/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com