I'm using gradle with maven-publish plugin to publish artifacts to our local maven repo.
My build.gradle
looks like (snippet):
apply plugin: 'java'
apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication) {
groupId 'org.myorg'
artifactId 'myapp'
version '0.0.1-SNAPSHOT'
from components.java
}
}
repositories {
maven {
credentials {
username 'myUsername'
password 'myPassword'
}
url 'https://my.repo/snapshots/'
}
}
}
And after running publish
output looks like:
$ gradle publish
:generatePomFileForMavenJavaPublication
:processResources UP-TO-DATE
:compileJava UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:publishMavenJavaPublicationToMavenRepository
Upload https://my.repo/snapshots/org/myorg/myapp/0.0.1-SNAPSHOT/myapp-0.0.1-20161122.144856-2.jar
Upload https://my.repo/snapshots/org/myorg/myapp/0.0.1-SNAPSHOT/myapp-0.0.1-20161122.144856-2.jar.sha1
Upload https://my.repo/snapshots/org/myorg/myapp/0.0.1-SNAPSHOT/myapp-0.0.1-20161122.144856-2.jar.md5
Upload https://my.repo/snapshots/org/myorg/myapp/0.0.1-SNAPSHOT/myapp-0.0.1-20161122.144856-2.pom
Upload https://my.repo/snapshots/org/myorg/myapp/0.0.1-SNAPSHOT/myapp-0.0.1-20161122.144856-2.pom.sha1
Upload https://my.repo/snapshots/org/myorg/myapp/0.0.1-SNAPSHOT/myapp-0.0.1-20161122.144856-2.pom.md5
Upload https://my.repo/snapshots/org/myorg/myapp/0.0.1-SNAPSHOT/maven-metadata.xml
Upload https://my.repo/snapshots/org/myorg/myapp/0.0.1-SNAPSHOT/maven-metadata.xml.sha1
Upload https://my.repo/snapshots/org/myorg/myapp/0.0.1-SNAPSHOT/maven-metadata.xml.md5
Upload https://my.repo/snapshots/org/myorg/myapp/maven-metadata.xml
Upload https://my.repo/snapshots/org/myorg/myapp/maven-metadata.xml.sha1
Upload https://my.repo/snapshots/org/myorg/myapp/maven-metadata.xml.md5
:publish
BUILD SUCCESSFUL
Total time: 8.147 secs
Files exist and everything "is fine". Not really. Files like pom
and others have date.time
appended. Is there a way to not having them appended?
The problems I have is when I'm trying to use sbt
to add dependency to this new library it fails to fetch it due to this appended date and time.
Thanks!
This is the expected behavior. When you publish a snapshot then maven will in the background rename the file so the latest can always be referenced via -SNAPSHOT
If your trying to release your jar then just remove the -SNAPSHOT
and you will see it upload with the name being "$project.name-$project.version"
as is.
On the other hand if you would like to reference the jar as a snapshot then you just need to be sure you have added the snapshot repository to your gradle
repositories {
jcenter()
url 'https://my.repo/snapshots/'
}
dependencies {
compile "some.thing:blah:1.0-SNAPSHOT"
}