Reputation: 16029
What is Gradle's equivalent of Maven's:
<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>
I have tried:
apply plugin: 'maven'
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file:///tmp/mvn-repo")
}
}
}
but it throws:
[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)
The project that I am working on is git://github.com/SpringSource/spring-data-rest.git
branch 1.0.0.RELEASE
, project's build.gradle.
Complete Gradle output:
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
I use Gradle 1.12.
Upvotes: 7
Views: 13190
Reputation: 660
If you are trying to deploy locally (e.g. to ~/.m2/repository) then: 1.mavenLocal() method in gradle checks for localRepository in settings.xml ,if it is not present
<localRepository>${user.home}/.m2/repository</localRepository>
2.add the following to build.gradle file
apply plugin: 'maven'
uploadArchives {
repositories {
mavenDeployer {
repository(url: mavenLocal().url)
}
}
}
Upvotes: 3
Reputation: 654
This error also occurs when you're filtering the artifacts that you're publishing, for example, if you're using the following filter in uploadArchives to upload war files, the error will be shown for all other archives such as war and zip :
uploadArchives {
repositories.mavenDeployer {
addFilter('war') {artifact, file ->
artifact.ext == 'war'
}
}
}
You need to add a filter explicitly for every artifact that you need to publish :
addFilter('jar') {artifact, file ->
artifact.ext == 'jar'
}
addFilter('zip') {artifact, file ->
artifact.ext == 'zip'
}
Upvotes: 2
Reputation: 16029
Found the cause of the problem. The project I am building is a multi module project, here I have found this information:
52.6.4.1. Multiple artifacts per project
Maven can only deal with one artifact per project. This is reflected in the structure of the Maven POM. We think there are many situations where it makes sense to have more than one artifact per project. In such a case you need to generate multiple POMs. In such a case you have to explicitly declare each artifact you want to publish to a Maven repository.
So I have moved uploadArchives
from the root level build.gradle
to a project level build.gradle
and this fixed the issue.
I think the error message regarding maven's setting.xml is very misleading and should be fixed by the Gradle team.
Upvotes: 5
Reputation: 6667
If you are trying to deploy locally (e.g. to ~/.m2) then you need:
apply plugin: 'maven'
uploadArchives {
repositories {
mavenDeployer {
mavenLocal()
}
}
}
I haven't tried using a repository in anything other than the default but I believe you can either set the repository location in ~/.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>
or you can set the url in the gradle build file:
maven {
url uri('/tmp/mvn_repo')
}
Upvotes: 5