如何将其他配置发布为SoftwareComponent?

时间:2019-04-05 18:36:16

标签: gradle kotlin gradle-kotlin-dsl

我还有以下附加组件和发布,但是我想将其发布为软件组件,并在注册时使用from方法而不是artifact,我该如何实现? (使用5.3.1)

sourceSets {
    val main by getting
    val tlib by creating {
        compileClasspath += main.output
        runtimeClasspath += main.output
    }
    val test by getting {
        compileClasspath += tlib.output
        runtimeClasspath += tlib.output
    }
}

configurations {
    val tlibCompile by getting {
        extendsFrom(configurations["implementation"])
    }
}

publishing {
    publications {
        val tlibJar by tasks.registering(Jar::class) {
            from(sourceSets["tlib"].output)
        }

        val tlibSourcesJar by tasks.registering(Jar::class) {
            archiveClassifier.set("sources")
            from(sourceSets["tlib"].allSource)
        }

        register("mavenTLib", MavenPublication::class) {
            artifactId = "phg-entity-tlib"
            artifact(tlibJar.get())
            artifact(tlibSourcesJar.get())
        }
    }
}

0 个答案:

没有答案