使用gradle发布到maven时,删除附加到工件名称的默认date.time

时间:2016-11-22 15:01:01

标签: maven datetime gradle sbt publish

我正在使用gradle with maven-publish插件将工件发布到我们当地的maven repo。

我的build.gradle看起来像(摘录):

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/'
        }
    }
}

运行publish后输出如下:

$ 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

文件存在,一切“很好”。并不是的。 pom等文件附加了date.time个。有没有办法不附加它们?

我遇到的问题是当我尝试使用sbt向这个新库添加依赖时,由于这个附加的日期和时间,它无法获取它。

谢谢!

1 个答案:

答案 0 :(得分:3)

这是预期的行为。发布快照时,maven会在后台重命名该文件,以便始终通过Parent*引用最新文件

如果您尝试释放广告文件,那么只需删除-SNAPSHOT,您就会看到上传的广告名称为-SNAPSHOT

另一方面,如果您想将jar引用为快照,那么您只需要确保已将快照存储库添加到您的gradle中

"$project.name-$project.version"