This message was deleted.
# community-support
s
This message was deleted.
v
That's actually not a message from Nexus, but from Gradle. You could for example do a
publishToMavenLocal
on CI to capture that.
r
Yeah I'd prefer to not have to search through logs
With a next gradle release that could be broken again
and run as part of the
check
task
v
Oh, it's just a warning? Then I guess you would need to add an own task that checks it somehow. For example with a shared build service that you then use in the
PublishToMavenLocal
tasks that records the published coordinates and fails if a second one publishes the same coordinates or something like that.
a
failing the build would be a nice feature @Remco Mokveld, if you added it to https://github.com/gradle/gradle/issues I’d give a šŸ‘
r
b
We always just checked Nexus ourselves... Fairly simply to do, since the path structure is well-known. Your requirements might alter some based on a few variables (auth, etc), but this works for
./gradlew checkVersion
Copy code
tasks.register("checkVersion") {
    doLast {
        var id = version.replace("-SNAPSHOT", "")
        var groupPath = project.group.replace(".", "/")
        var url = "$releaseRepoUrl/$groupPath/$artifactId/${id}/$artifactId-${id}.pom"
        println "Verifying: $url"
        var auth = "${nexusUserName}:${nexusPassword}"

        def baseUrl = new URL(url)
        HttpURLConnection connection = (HttpURLConnection) baseUrl.openConnection()
        connection.addRequestProperty("Authorization", "Basic ${auth.bytes.encodeBase64().toString()}")
        connection.with {
            doOutput = true
            requestMethod = "GET"
            println "Result: " + it.responseCode

            if (it.responseCode == 200)
                throw new GradleException("*********************\n  Version must be updated for release: [$id].\n  Artifact already exists: $url")
        }
    }
}
v
@Benjamin Hoogterp that was not the point though. The question was if one build publishes the same artifact twice from different publications / subprojects, you get a warning from Gradle and if Nexus does not allow overwrite a failure on the second publish try, while this situation should be caught without publishing to Nexus earlier in some CI run.
šŸ‘ 1
b
Appologies. I misunderstood.