публикация gradle с kotlin dsl с artifactId! = имя_проекта для spring-cloud-contract 3.0.0.M1 Milestone - PullRequest
0 голосов
/ 28 апреля 2020

У меня есть Gradle kotlin Многопроектная настройка DSL, где archivesBaseName и, следовательно, artifactId не равно подпрограмме project.name.

Я борюсь с публикацией (здесь publishToMavenLocal ) поскольку artifact(verifierStubsJar) жалуется на

Cannot convert the provided notation to an object of type MavenArtifact: task ':microservice:verifierStubsJar'.
The following types/formats are supported:
  - Instances of MavenArtifact.
  - Instances of AbstractArchiveTask, for example jar.
  - Instances of PublishArtifact
  - Maps containing a 'source' entry, for example [source: '/path/to/file', extension: 'zip'].
  - Anything that can be converted to a file, as per Project.file()

, а configurations { ... provider.get().outgoing.artifact(bootJar) ... }

жалуется на:

   > Artifact minimal_microservice-0.1.0.NIGHTLY.jar wasn't produced by this build.

публикацию для моего ученика kotlin dsl выглядит так:

// Starting from Gradle 6.2, Gradle performs a sanity check before uploading, to make sure you don’t
// upload stale files (files produced by another build). This introduces a problem with Spring Boot
// applications which are uploaded using the components.java component:
// Artifact my-application-0.0.1-SNAPSHOT.jar wasn't produced by this build.
// This is caused by the fact that the main jar task is disabled by the Spring Boot application, and the
// component expects it to be present. Because the bootJar task uses the same file as the main jar task by default,
configurations {
    val jar by tasks.existing
    val bootJar by tasks.existing
    listOf(apiElements, runtimeElements).forEach { provider ->
        provider.get().outgoing.artifacts.removeIf {
            it.buildDependencies.getDependencies(null).contains(jar)
        }
//        provider.get().outgoing.artifact(bootJar)        // <-- why does this not work???
        println(String.format("%s/libs/%s-%s.jar", project.buildDir, archivesBaseName, version))
        provider.get().outgoing.artifact(File(String.format("%s/libs/%s-%s.jar", project.buildDir, archivesBaseName, version)))
    }
}
configure<org.gradle.api.publish.PublishingExtension> {
    publications {
        val archivesBaseName: String by project.extra
        val theVersion = version as String
        create<MavenPublication>("maven") {
            groupId = project.rootProject.group as String?
//            artifactId = archivesBaseName
            version = theVersion
            from(components["java"])
            afterEvaluate {
                artifactId = tasks.bootJar.get().archiveBaseName.get()
            }
        }
        create<MavenPublication>("stubs") {
            groupId = project.rootProject.group as String?
//            artifactId = archivesBaseName
            version = theVersion
            val verifierStubsJar by tasks.existing
            artifact(verifierStubsJar)               // <-- this line gives me the above error
            afterEvaluate {
                artifactId = tasks.bootJar.get().archiveBaseName.get()
            }
        }
    }
}

есть идеи как (с gradle kotlin dsl)?

a) настроить configurations { ... } part for a custom archivesBaseName`

b) получить MavenPublication "stubs" artifact from generated verifyierStubsJar`


edit:

, поэтому я понял, б), который просто должен быть: артефакт (verifyierStubsJar .get())

...