gradle-nexus / publish-plugin

Gradle plugin for publishing to Nexus repositories
Apache License 2.0
407 stars 29 forks source link

Error when publishing release version (not SNAPSHOT) to free (not PRO) Nexes server #149

Open ComBatVision opened 2 years ago

ComBatVision commented 2 years ago

Hi,

Is it possible to disable Nexus PRO staging profiles feature somehow? Plugin fails when attempt to publish release version with following error:

Failed to load staging profiles, server at https://nexus.server/repository/maven-public/ responded with status code 404, body:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>404 - Nexus Repository Manager</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <!--[if lt IE 9]>
  <script>(new Image).src="../../../favicon.ico?3.39.0-01"</script>
  <![endif]-->
  <link rel="icon" type="image/png" href="../../../favicon-32x32.png?3.39.0-01" sizes="32x32">
  <link rel="mask-icon" href="../../../safari-pinned-tab.svg?3.39.0-01" color="#5bbad5">
  <link rel="icon" type="image/png" href="../../../favicon-16x16.png?3.39.0-01" sizes="16x16">
  <link rel="shortcut icon" href="../../../favicon.ico?3.39.0-01">
  <meta name="msapplication-TileImage" content="../../../mstile-144x144.png?3.39.0-01">
  <meta name="msapplication-TileColor" content="#00a300">

  <link rel="stylesheet" type="text/css" href="../../../static/css/nexus-content.css?3.39.0-01"/>
</head>
<body>
<div class="nexus-header">
        Nexus Repository Manager
        OSS 3.39.0-01
</div>

<div class="nexus-body">
  <div class="content-header">
    <img src="../../../static/rapture/resources/icons/x32/exclamation.png?3.39.0-01" alt="Exclamation point" aria-role="presentation"/>
    <span class="title">Error 404</span>
    <span class="description">Not Found</span>
  </div>
  <div class="content-body">
    <div class="content-section">
      Not Found
    </div>
  </div>
</div>
</body>
</html>

My configuration looks like:

plugins {
    kotlin("multiplatform") version "1.7.10" apply false
    id("com.android.library") apply false
    id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}

allprojects {
    group = "com.example"
    version = "1.0"

    repositories {
        mavenCentral()
    }
}

nexusPublishing {
    repositories {
        create("myNexus") {
            nexusUrl.set(uri("https://nexus.server/repository/maven-public/"))
            snapshotRepositoryUrl.set(uri("https://nexus.server/repository/maven-snapshots/"))
            username.set("maven")
            password.set(System.getProperty("maven_password"))
        }
    }
}
szpak commented 2 years ago

Why do you need gradle-nexus-publish-plugin for publishing to Nexus OSS? The built-in maven-publish should be enough.

vlsi commented 2 years ago

Technically speaking, you can disable staging behavior via extension property: https://github.com/gradle-nexus/publish-plugin/blob/0aea95597e2eeaf9275a286254894bad29b3d1e1/src/main/kotlin/io/github/gradlenexus/publishplugin/NexusPublishExtension.kt#L33

ComBatVision commented 2 years ago

Why do you need gradle-nexus-publish-plugin for publishing to Nexus OSS? The built-in maven-publish should be enough.

Good question which I also asked to my team DevOps. Probably I will use maven-publish. I just wanted to understand if it is possible to configure nexus plug-in to work in my case.

Technically speaking, you can disable staging behavior via extension property:

https://github.com/gradle-nexus/publish-plugin/blob/0aea95597e2eeaf9275a286254894bad29b3d1e1/src/main/kotlin/io/github/gradlenexus/publishplugin/NexusPublishExtension.kt#L33

It is a final variable and it can not be assigned in build.gradle.

vlsi commented 2 years ago

@ComBatVision , you could use useStaging.set(true)

ComBatVision commented 2 years ago

@vlsi Thanks. If I put useStaging.set(false) then I receive another error: Could not PUT 'https://nexus.server/repository/maven-snapshots/com.examople/lib-js/1.0/lib-js-1.0.jar'. Received status code 400 from server: Repository version policy: SNAPSHOT does not allow version: 1.0

vlsi commented 2 years ago

@szpak , it looks like it is worth fixing code at https://github.com/gradle-nexus/publish-plugin/blob/0aea95597e2eeaf9275a286254894bad29b3d1e1/src/main/kotlin/io/github/gradlenexus/publishplugin/NexusPublishPlugin.kt#L208-L213

In other words, the current code uses useStaging for snapshot vs release decision, however, I would suggest that useStaging should be separate from deploy to SNAPSHOT vs deploy to non-snapshot.

WDYT?