'nebula.release cannot find the task "release"

I have a gradle project that I need to do some automated releasing in and I am supposed to use the nebula-release-plugin. I have not tried to release with gradle before, so I am following this approach. When I try to add the nebula plugin, I get a Task with name 'release' not found in root project 'my-project-name'. The documentation does not say anything about specifying a release task, so I don't know how to make one. I get that I need to specify a way to deploy the app, but it has been hard to find a way that works and is compatible with nebula.

My build.gradle:

plugins {
    id 'org.springframework.boot' version '2.5.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
    id 'com.github.bjornvester.wsdl2java' version '1.1'
    id 'com.github.johnrengelman.shadow' version '7.0.0'
    id 'maven-publish'
    id 'nebula.release' version '13.2.1' // https://github.com/nebula-plugins/nebula-release-plugin
}

group = 'dk.dxc'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

task unpack(type: Copy) {
    dependsOn bootJar
    from(zipTree(tasks.bootJar.outputs.files.singleFile))
    into('build/dependency')
}

test {
    useJUnitPlatform()
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifactId = Project.getName()
            from components.java
            versionMapping {
                usage('java-api') {
                    fromResolutionOf('runtimeClasspath')
                }
                usage('java-runtime') {
                    fromResolutionResult()
                }
            }
            pom {
                name = 'soap-demo-gradle'
                description = 'A template for soap services using gradle'
                scm {
                    connection = 'scm:git:url/to/my/git/repo'
                    developerConnection = 'scm:git:url/to/my/git/repo'
                    url = 'scm:git:url/to/my/git/repo'
                }
            }
        }
    }
    repositories {
        maven {
            def releasesRepoUrl = "url/to/my/nexus/repo"
            def snapshotsRepoUrl = "url/to/my/nexus/repo"
            url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
        }
    }
}


Solution 1:[1]

There's no need to specify a release task because it comes within the nebula-release plugin. This error may occur if the plugin couldn't start properly for some reason and the tasks provided by it aren't available. So if you try to run some task that depends on the release task the build will fail.

In my case, the problem was that I hadn't started a git repository on my project.

Git repository not found at <project-path> -- nebula-release tasks will not be available. Use the git.root Gradle property to specify a different directory.

After initiating a git repository with git init the tasks of the plugin became available.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kaue