Configure Gradle to publish sources and javadoc

后端 未结 4 537
南方客
南方客 2021-02-05 04:55

How do I configure Gradle to publish sources and javadoc jars to a repository?

4条回答
  •  礼貌的吻别
    2021-02-05 05:11

    Add the following code to the build script:

    task packageJavadoc(type: Jar, dependsOn: 'javadoc') {
        from javadoc.destinationDir
        classifier = 'javadoc'
    }
    task packageSources(type: Jar, dependsOn: 'classes') {
        from sourceSets.main.allSource
        classifier = 'sources'
    }
    artifacts {
        archives packageJavadoc
        archives packageSources
    }
    

    Tested with Gradle 1.10

提交回复
热议问题