# Release plugin + publish - not publishing released artifacts

**URL:** <https://discuss.gradle.org/t/release-plugin-publish-not-publishing-released-artifacts/46088>\
**Category:** Help/Discuss\
**Created:** [July 21, 2023, 6:52pm UTC](https://discuss.gradle.org/t/release-plugin-publish-not-publishing-released-artifacts/46088 "2023-07-21T18:52:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hedley](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@Hedley](https://discuss.gradle.org/u/Hedley)\
**Post date:** [July 21, 2023, 6:52pm UTC](https://discuss.gradle.org/t/release-plugin-publish-not-publishing-released-artifacts/46088/1 "2023-07-21T18:52:27Z")

</div>

I’m trying to set up two projects with Gradle to perform releases and publish the results to a Nexus repository server. Both are failing with a similar problem - the release step is working, and the “SNAPSHOT” version is replaced by the released version, and committed and pushed to git, but the publish step is not doing anything / not running.

The setup I’m trying to achieve is:

- Local (snapshot) builds should be published to local Maven cache.
- Release (CI) builds should be published to our Nexus repository server.

My build.gradle:

```gradle
plugins {
  id 'java'
  id 'net.researchgate.release' version '2.8.1'
  id 'maven-publish'
}

group 'com.something'

repositories {
  mavenLocal()
  mavenCentral()
  maven {
      url = uri('http://nexus:8080/repository/myrepo/')
      allowInsecureProtocol = true
  }
}

java {
  withSourcesJar()
}

publishing {
  publications {
    maven(MavenPublication) {
        from components.java
    }
  }
}

// publish every build to local maven, to enable local testing
publishToMavenLocal.dependsOn(check)
build.dependsOn(publishToMavenLocal)
// publish release builds to Nexus
afterReleaseBuild.dependsOn publish

```

Sample log output:

```gradle
Task :release
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:check
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:generateMetadataFileForMavenPublication
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:generatePomFileForMavenPublication
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:publishMavenPublicationToMavenLocal
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:publishToMavenLocal
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:build
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:publish UP-TO-DATE
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:afterReleaseBuild UP-TO-DATE
Task :CPA-GJAP-JOB1:runBuildTasks
Task :CPA-GJAP-JOB1:preTagCommit
Task :CPA-GJAP-JOB1:createReleaseTag
Task :CPA-GJAP-JOB1:checkoutMergeFromReleaseBranch SKIPPED
Task :CPA-GJAP-JOB1:updateVersion
Task :CPA-GJAP-JOB1:commitNewVersion
Task :compileJava UP-TO-DATE
Task :processResources NO-SOURCE
Task :classes UP-TO-DATE
Task :jar
Task :sourcesJar
Task :assemble
Task :compileTestJava UP-TO-DATE
Task :processTestResources UP-TO-DATE
Task :testClasses UP-TO-DATE
Task :test UP-TO-DATE
Task :check UP-TO-DATE
Task :generateMetadataFileForMavenPublication
Task :generatePomFileForMavenPublication
Task :publishMavenPublicationToMavenLocal
Task :publishToMavenLocal
Task :build

```

The publish task appears to show as UP-TO-DATE. What am I missing?

Gradle version: 7.4

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [July 25, 2023, 7:55pm UTC](https://discuss.gradle.org/t/release-plugin-publish-not-publishing-released-artifacts/46088/2 "2023-07-25T19:55:27Z")

</div>

The `publish` task is a lifecycle task. It typically does not do any action itself, it is just there to depend on the `publish<publication>To<repository>Repository` tasks. The problem is, that you defined a publication, but no repositories where to publish to, so there are no according tasks created and wired to the `publish` task.

---

<div class="post-metadata">

**Author:** ![Hedley](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@Hedley](https://discuss.gradle.org/u/Hedley)\
**Post date:** [July 26, 2023, 12:10am UTC](https://discuss.gradle.org/t/release-plugin-publish-not-publishing-released-artifacts/46088/3 "2023-07-26T00:10:07Z")

</div>

Thanks for replying. I’m confused though. I thought that the publish plugin would automatically create a task for each repository in my list. Is that not right? If not, how do i configure it to create a task to publish to my main maven repo? In this case our Nexus repository server.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [July 26, 2023, 9:47pm UTC](https://discuss.gradle.org/t/release-plugin-publish-not-publishing-released-artifacts/46088/4 "2023-07-26T21:47:34Z")

</div>

It does, but not for the repositories you configured for dependency resolution. The repositories for publication are separately defined in the `publishing` block. Have a look at the documentation of the `maven-publish` plugin.

---

<div class="post-metadata">

**Author:** ![Hedley](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@Hedley](https://discuss.gradle.org/u/Hedley)\
**Post date:** [July 27, 2023, 10:25pm UTC](https://discuss.gradle.org/t/release-plugin-publish-not-publishing-released-artifacts/46088/5 "2023-07-27T22:25:00Z")

</div>

Ahhh… I had not noticed the repositories for publication are inside the publishing block! I will make that change, and add the logic to choose release or snapshot url. Thanks for all the help.
