Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task 'publishToSonatype' not found #219

Closed
YovanggaAnandhika opened this issue May 1, 2023 · 5 comments
Closed

Task 'publishToSonatype' not found #219

YovanggaAnandhika opened this issue May 1, 2023 · 5 comments
Labels
question Further information is requested

Comments

@YovanggaAnandhika
Copy link

gradlew tasks

Publishing tasks
----------------
closeAndReleaseSonatypeStagingRepository - Closes and releases open staging repository in 'sonatype' Nexus instance.
closeAndReleaseStagingRepository - Closes and releases open staging repositories in all configured Nexus instances.
closeSonatypeStagingRepository - Closes open staging repository in 'sonatype' Nexus instance.
generateMetadataFileForReleasePublication - Generates the Gradle metadata file for publication 'release'.
generatePomFileForReleasePublication - Generates the Maven POM file for publication 'release'.
publish - Publishes all publications produced by this project.
publishReleasePublicationToMavenLocal - Publishes Maven publication 'release' to the local Maven repository.
publishToMavenLocal - Publishes all Maven publications produced by this project to the local Maven cache.
releaseSonatypeStagingRepository - Releases closed staging repository in 'sonatype' Nexus instance.

Where Task name for Create Repository to nexus manager ?

@szpak
Copy link
Contributor

szpak commented May 3, 2023

I would be easier having more information about your (publishing) configuration.

@szpak szpak added the question Further information is requested label May 3, 2023
@XuNeal
Copy link

XuNeal commented May 5, 2023

same problem, below is my config:
root build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

plugins {
    id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

maven-publish.gradle

apply plugin: 'maven-publish'


Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

def NEXUS_USER = properties.getProperty('NEXUS_USER')
def NEXUS_PASSWORD = properties.getProperty('NEXUS_PASSWORD')
def VERSION = properties.getProperty('VERSION')

version VERSION
group 'io.packages'

afterEvaluate {
    publishing {
        publications {
            Production(MavenPublication) {
                artifact("aar-xxx-beta4.aar")

                groupId this.group
                artifactId 'aar'
                version this.version

                pom.withXml {
                    def dependenciesNode = asNode().appendNode('dependencies')

                    configurations.implementation.allDependencies.each {
                        if (it.name != 'unspecified') {
                            def dependencyNode = dependenciesNode.appendNode('dependency')
                            dependencyNode.appendNode('groupId', it.group)
                            dependencyNode.appendNode('artifactId', it.name)
                            dependencyNode.appendNode('version', it.version)
                        }
                    }
                }
            }
        }
//        repositories {
//            maven {
//                name 'MavenCentral'
//                url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
//                credentials {
//                    username NEXUS_USER
//                    password NEXUS_PASSWORD
//                }
//            }
//        }

    }
    nexusPublishing {
        repositories {
            sonatype {  //only for users registered in Sonatype after 24 Feb 2021
                nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
                snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
                username = NEXUS_USER // defaults to project.properties["myNexusUsername"]
                password = NEXUS_PASSWORD // defaults to project.properties["myNexusPassword"]
            }
        }
    }

}

./gradlew tasks


Android tasks
-------------
androidDependencies - Displays the Android dependencies of the project.
signingReport - Displays the signing info for the base and test modules
sourceSets - Prints out all the source sets defined in this project.

Build tasks
-----------
assemble - Assemble main outputs for all the variants.
assembleAndroidTest - Assembles all the Test applications.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
clean - Deletes the build directory.
cleanBuildCache - Deletes the build cache directory.
compileDebugAndroidTestSources
compileDebugSources
compileDebugUnitTestSources
compileReleaseSources
compileReleaseUnitTestSources
extractDebugAnnotations - Extracts Android annotations for the debug variant into the archive file
extractReleaseAnnotations - Extracts Android annotations for the release variant into the archive file

Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.

Cleanup tasks
-------------
lintFix - Runs lint on all variants and applies any safe suggestions to the source code.

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'TokenCore'.
dependencies - Displays all dependencies declared in root project 'TokenCore'.
dependencyInsight - Displays the insight into a specific dependency in root project 'TokenCore'.
help - Displays a help message.
javaToolchains - Displays the detected java toolchains.
outgoingVariants - Displays the outgoing variants of root project 'TokenCore'.
projects - Displays the sub-projects of root project 'TokenCore'.
properties - Displays the properties of root project 'TokenCore'.
tasks - Displays the tasks runnable from root project 'TokenCore' (some of the displayed tasks may belong to subprojects).

Install tasks
-------------
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
uninstallAll - Uninstall all applications.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.

Publishing tasks
----------------
closeAndReleaseSonatypeStagingRepository - Closes and releases open staging repository in 'sonatype' Nexus instance.
closeAndReleaseStagingRepository - Closes and releases open staging repositories in all configured Nexus instances.
closeSonatypeStagingRepository - Closes open staging repository in 'sonatype' Nexus instance.
generateMetadataFileForProductionPublication - Generates the Gradle metadata file for publication 'Production'.
generatePomFileForProductionPublication - Generates the Maven POM file for publication 'Production'.
publish - Publishes all publications produced by this project.
publishProductionPublicationToMavenLocal - Publishes Maven publication 'Production' to the local Maven repository.
publishToMavenLocal - Publishes all Maven publications produced by this project to the local Maven cache.
releaseSonatypeStagingRepository - Releases closed staging repository in 'sonatype' Nexus instance.

Verification tasks
------------------
check - Runs all checks.
connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices.
connectedCheck - Runs all device checks on currently connected devices.
connectedDebugAndroidTest - Installs and runs the tests for debug on connected devices.
deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.
deviceCheck - Runs all device checks using Device Providers and Test Servers.
lint - Runs lint on all variants.
lintDebug - Runs lint on the Debug build.
lintRelease - Runs lint on the Release build.
test - Run unit tests for all variants.
testDebugUnitTest - Run unit tests for the debug build.
testReleaseUnitTest - Run unit tests for the release build.

@YovanggaAnandhika
Copy link
Author

YovanggaAnandhika commented May 5, 2023

I would be easier having more information about your (publishing) configuration.

this is my example module gradle
and this the gradle root
but my Jira Ticket File Not Uploded

i am used android studio ide. the file build successfully created publication file. but the file not uploaded

image

@YovanggaAnandhika
Copy link
Author

I would be easier having more information about your (publishing) configuration.

this is my example module gradle and this the gradle root but my Jira Ticket File Not Uploded

i am used android studio ide. the file build successfully created publication file. but the file not uploaded

image

i solved for my issues !!

i just need to add nexusPublishing { }
in the gradle root not in the gradle module or move the nexus publishing command on top of other commands. right after the application of the plugin

Like this

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.4.1' apply false
    id 'com.android.library' version '7.4.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.21' apply false
    id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
}

File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
    // Read local.properties file first if it exists
    Properties p = new Properties()
    new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
    p.each { name, value -> ext[name] = value }
}

nexusPublishing {
    repositories {
        sonatype {  //only for users registered in Sonatype after 24 Feb 2021
            nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
            snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
            username = ossrhUsername
            password = ossrhPassword
            stagingProfileId = rootProject.ext["sonatypeStagingProfileId"]
        }
    }
}

apply plugin: 'io.github.gradle-nexus.publish-plugin'

// evaluate and some code

test get a tasks

Publishing tasks
----------------
closeAndReleaseSonatypeStagingRepository - Closes and releases open staging repository in 'sonatype' Nexus instance.
closeAndReleaseStagingRepository - Closes and releases open staging repositories in the following Nexus instance: 'sonatype'
closeSonatypeStagingRepository - Closes open staging repository in 'sonatype' Nexus instance.
generateMetadataFileForReleasePublication - Generates the Gradle metadata file for publication 'release'.
generatePomFileForReleasePublication - Generates the Maven POM file for publication 'release'.
publish - Publishes all publications produced by this project.
publishAllPublicationsToSonatypeRepository - Publishes all Maven publications produced by this project to the sonatype repository.
publishReleasePublicationToMavenLocal - Publishes Maven publication 'release' to the local Maven repository.
publishReleasePublicationToSonatypeRepository - Publishes Maven publication 'release' to Maven repository 'sonatype'.
publishToMavenLocal - Publishes all Maven publications produced by this project to the local Maven cache.
publishToSonatype - Publishes all Maven publications produced by this project to the 'sonatype' Nexus repository.
releaseSonatypeStagingRepository - Releases closed staging repository in 'sonatype' Nexus instance.

@szpak
Copy link
Contributor

szpak commented May 5, 2023

@YovanggaAnandhika I'm glad you were able to fix your problem before I had a chance to analyze the files.

While you should get a clear error trying to apply the plugin on the non-root project:

Plugin must be applied to the root project but was applied to :someSubproject

I wonder, if we could easily detect the situation you had. Would you mind creating a feature request about that?

Btw, please keep in mind that the Android projects are not officially supported - #75, so unfortunately you might encounter also some other problems :-/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants