Gradle没有发布自定义jar工件

时间:2017-01-06 20:07:47

标签: gradle

我有一个gradle构建,必须将预先构建的jar文件作为工件发布。由于某种原因,它没有被接收。这是一个简化版本来重现它:

文件夹内容:

settings.gradle
build.gradle
some.jar

settings.gradle:

rootProject.name = 'some'

的build.gradle:

apply plugin: 'base'
apply plugin: 'maven-publish'

group = 'foo.bar'
version = '1.0'

task copyPrebuilt(type: Copy) {
  from(projectDir) {
    include 'some.jar'
    rename 'some', "some-$version"
  }
  into distsDir
}

artifacts {
  // should be 'archives'?
  // http://stackoverflow.com/questions/39068090/gradle-archives-artifacts-not-populated-to-default-configuration
  'default' (file("$distsDir/some-${version}.jar")) {
    name 'some'
    type 'jar'
    builtBy copyPrebuilt
  }
}

some-1.0.jar未被~/.m2/repository/foo/bar/some/1.0

复制到gradle publishToMavenLocal

任何线索?

1 个答案:

答案 0 :(得分:2)

发布内容的最简单方法是定义发布对象:

publishToMavenLocal

此代码使<div role="tabpanel" class="tab-pane if(!empty($status2)) echo $status2; ?>" id="tab2"> 任务将some-1.0.jar安装到本地maven存储库。