发布从Gradle中的任务构建的自定义工件 [英] Publishing custom artifact built from task in gradle

查看:175
本文介绍了发布从Gradle中的任务构建的自定义工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



下面是一个简化版本:

  apply plugin:'maven-publish'

任务myTask {
ext.destination = file('myfile ')
doLast {
//这里它应该创建文件
}
}

发布{
版本库{
maven {
name'ArtifactoryDe​​vDirectory'
url'http:// artifactory / artifactory / repo-dev'
credentials {
username'username'
password'password'



$ b出版物
MyJar(MavenPublication){
artifactIdtest
version1.0
groupIdorg.example
artifact myTask.destination
}
}
}

这有效,但 gradle publish 不运行myTask。我尝试添加

  publishMyJarPublicationToArtifactoryDe​​vDirectoryRepository.dependsOn myTask 

但我只是得到:

 无法找到属性'publishMyJarPublicationToArtifactoryDe​​vDirectoryRepository'on root project'测试'。 

我尝试了一下工件,添加了自定义工件和配置,然后发布了它,



任何帮助将不胜感激。

p $ p> afterEvaluate {
publishMyJarPublicationToArtifactoryDe​​vDirectoryRepository.dependsOn my myTask
}

完成我想要的。


I am having some issues trying to create a task that build a special file which is then uploaded to artifactory.

Heres a simplified version:

apply plugin: 'maven-publish'

task myTask {
    ext.destination = file('myfile')
    doLast {
        // Here it should build the file
    }
}

publishing {
    repositories {
        maven {
            name 'ArtifactoryDevDirectory'
            url 'http://artifactory/artifactory/repo-dev'
            credentials {
                username 'username'
                password 'password'
            }
        }
    }

    publications {
        MyJar(MavenPublication) {
            artifactId "test"
            version "1.0"
            groupId "org.example"
            artifact myTask.destination
        }
    }
}

This works, except that gradle publish does not run myTask. I tried adding

publishMyJarPublicationToArtifactoryDevDirectoryRepository.dependsOn myTask

but i just get:

Could not find property 'publishMyJarPublicationToArtifactoryDevDirectoryRepository' on root project 'test'.

I tried messing about with the artifact, adding a custom artifact and configuration and publishing that instead but that did not work either.

Any help would be greatly appreciated.

解决方案

afterEvaluate {
    publishMyJarPublicationToArtifactoryDevDirectoryRepository.dependsOn myTask
}

Accomplishes what I want.

这篇关于发布从Gradle中的任务构建的自定义工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆