Git Product home page Git Product logo

gradle-nexus-plugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gradle-nexus-plugin's Issues

Plugin version 2.3 and missing dependencies

I just tried updating the plugin from version 2.1.1 to 2.3. The 2.3 version created a pom.xml without any dependencies. When I downgraded back to 2.1.1 the dependencies worked again.

Did something else change in 2.3?

Here is my build.gradle:

import org.gradle.internal.jvm.Jvm

plugins {
    id 'java'
    id 'checkstyle'
    id 'findbugs'
    id 'com.bmuschko.nexus' version '2.3'
}

group = 'com.imsweb'
version = '1.0-SNAPSHOT'
description = 'Java client library for staging calculations'

println "Starting build using ${Jvm.current()}"

// UTF-8 for all compilation tasks
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.fasterxml.jackson.core:jackson-core:2.4.4'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.4'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.4.4'

    // morphia annotations are needed to make it easier to use in SEER*API
    compile 'org.mongodb.morphia:morphia:0.108'

    compile 'com.google.guava:guava:18.0'

    testCompile 'junit:junit:4.11'
    testCompile 'org.unitils:unitils-core:3.4'
    testCompile 'us.monoid.web:resty:0.3.2'
}

jar {
    manifest {
        attributes('Implementation-Title': project.name,
                'Implementation-Version': version,
                'Implementation-Vendor': group,
                'Created-By': System.properties['java.vm.version'] + ' (' + System.properties['java.vm.vendor'] + ')',
                'Built-By': System.getProperty('user.name'),
                'Built-Date': new Date(),
                'Built-JDK': System.getProperty('java.version'),
        )
    }
}

checkstyle {
    ignoreFailures = true
    configFile = file('config/checkstyle/checkstyle.xml')
}

findbugs {
    toolVersion = '2.0.1'
    ignoreFailures = true
    effort = 'max'
    excludeFilter = file('config/findbugs/findbugs-exclude.xml')
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
}

// run the full CS integration test suite
task csIntegrationTest(type: JavaExec) {
    main = 'com.imsweb.staging.cs.CsIntegrationTest'
    classpath = sourceSets.test.runtimeClasspath
}

modifyPom {
    project {
        name 'Staging Java Client'
        description 'A cancer staging client library'
        url 'https://github.com/imsweb/staging-client-java'
        inceptionYear '2015'

        scm {
            url 'https://github.com/imsweb/staging-client-java'
            connection 'scm:https://github.com/imsweb/staging-client-java.git'
            developerConnection 'scm:[email protected]:imsweb/staging-client-java.git'
        }

        licenses {
            license {
                name 'A modified BSD License (BSD)'
                url 'https://github.com/imsweb/staging-client-java/blob/master/LICENSE'
                distribution 'repo'
            }
        }

        developers {
            developer {
                id 'ctmay4'
                name 'Chuck May'
                email '[email protected]'
            }
            developer {
                id 'depryf'
                name 'Fabian Depry'
                email '[email protected]'
            }
        }
    }
}

Interactive prompts don't work if Gradle JVM is forked

gradle-nexus-plugin's nice feature of asking for passwords or passphrases interactively (so that you don't have to put them in a plaintext file) unfortunately doesn't work if you have org.gradle.jvmargs set, or org.gradle.daemon enabled in gradle.properties. Instead you get an exception like this:

Cannot invoke method readPassword() on null object
java.lang.NullPointerException: Cannot invoke method readPassword() on null object
    at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.gradle.api.plugins.nexus.NexusPlugin.getPrivateKeyForSigning(NexusPlugin.groovy:162)
    at org.gradle.api.plugins.nexus.NexusPlugin.this$2$getPrivateKeyForSigning(NexusPlugin.groovy)
.......

This seems to be due to the fact that when the build is running as a forked process (in order to honor the JVM arguments) or as a daemon, Gradle doesn't attach stdin to the build process. Thus any attempt to ask for keyboard input fails.

This probably needs to be fixed in Gradle โ€” not sure we can do anything about it in this plugin. The problem has been reported at http://issues.gradle.org/browse/GRADLE-2357 but there doesn't seem to have been any move towards fixing it yet.

0.5 doesn't sign release POM

It seems that (starting with the 0.5 release) the release POM is no longer being signed. When I use 0.4, I don't see the issue. Thankfully, Sonatype's Maven Central Rules caught this before we pushed our new release.

Publish to Maven Central

Please can you publish to Maven Central as well as jcenter? Our release process (Nexus proxy setup) makes consuming jcenter hard, and we have to get the security wonks involved. :-(

Thank you!

Setting the artifact name

I need to be able to set the artifact name to something other than the directory the project/module lives in. I need the artifact names to match what maven has been producing and I'd rather not rename my project's directories to something dumb just to accommodate. e.g. in morphia, the subproject "guice-plug" should generate an artifact named "morphia-guice-plug"

Configure readLine message for authentification ?

I want change messages for authenification. I use you plugin with artifactory and it's run fine.

I propose to change the code from

String nexusUsername = project.hasProperty(NEXUS_USERNAME) ?
                                      project.property(NEXUS_USERNAME) :
                                      console.readLine('\nPlease specify Nexus username: ')

String nexusPassword = project.hasProperty(NEXUS_PASSWORD) ?
                                     project.property(NEXUS_PASSWORD) :
                                     new String(console.readPassword('\nPlease specify Nexus password: '))

to

String nexusUsername = project.hasProperty(NEXUS_USERNAME) ?
                                      project.property(NEXUS_USERNAME) :
                                      console.readLine("\n${extension.messageUser}: ")

String nexusPassword = project.hasProperty(NEXUS_PASSWORD) ?
                                     project.property(NEXUS_PASSWORD) :
                                     new String(console.readPassword("\n${extension.messagePassword}: "))

Encrypt credentials in properties file

Many organizations can not have passwords in the clear within a file. It is generally not a good security practice. The idea here is that the gradle.properties file would have the password encrypted and it would be descrypted at runtime before being used to authenticate to nexus.

Here are some possible help to implement this:

But I will leave the implementation choice to you :)

At the vary least, provide a "hook" so that the password could be provided by one of these solutions and let the user do the integration.

Authentication details from gradle.properties does not work

I tried with this in ~/.gradle/gradle.properties:

nexusUsername = 'user'
nexusPassword = 'password

As well as setting the properties on the project itself:

project.ext {
    nexusUsername = 'user'
    nexusPassword = 'password'
}

In both cases, I get a 401 Unauthorized when I invoke gradle uploadArchives. If I don't set any of those properties and let the plugin prompt me, everything gets uploaded fine.

I am using Gradle 1.10:

------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------

Build time:   2013-12-17 09:28:15 UTC
Build number: none
Revision:     36ced393628875ff15575fa03d16c1349ffe8bb6

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:          2.2.0
JVM:          1.7.0_09 (Oracle Corporation 23.5-b02)
OS:           Mac OS X 10.9.1 x86_64

Thanks for the awesome plugin! Kudos for taking all of the weird-ish Maven tricks and throwing it all in one place!

Q about uploading but ignoring sub projects

On my project (https://github.com/marceloverdijk/spring-appengine) I keep some samples in my /samples folder.
In gradle.settings I include them as follows:

rootProject.name = 'spring-appengine'

def samplesDirName = "samples"
def samplesDir = new File(rootDir, samplesDirName)
samplesDir.eachDir { sampleDir ->
    def moduleName = "samples/$sampleDir.name"
    include moduleName
    def project = findProject(":$moduleName")
    project.name = "spring-appengine-samples-$sampleDir.name"
}

I used this approach from some other open source project to easily run my samples with the 'main' project as dependency.

When I run uploadArchives to post my 'main' project to Sonatype OSS it's uploading not only my 'main' project but also all the sample projects.

Workaround for now I removed settings.gradle when I perform the uploadArchives task.

Is there a better solution?

Cycle detected

Hi, I am trying to use this plugin but running gradle uploadArchives does not work for me.

I hope this is a known problem or you have hints about the cause for this.

This is the output (using --debug or --info does not provide anything useful):

:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:javadoc UP-TO-DATE
:javadocJar UP-TO-DATE
:sourcesJar UP-TO-DATE
:signArchives UP-TO-DATE
:uploadArchives FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':uploadArchives'.
> Could not publish configuration 'archives'
   > org.codehaus.plexus.PlexusContainerException: Cycle detected in component graph in the system: 

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2.905 secs

I have a "parent" project with this build file:

apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'com.bmuschko.nexus'

buildscript {
  repositories {
    mavenCentral()
    jcenter()
    maven { url "http://repo.maven.apache.org/maven2" }
  }
  dependencies {
      classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
  }
}

allprojects  {
  apply plugin: 'maven'
  apply plugin: 'java'
  group = 'me.tomassetti'
  version = '0.2.0-SNAPSHOT'
}

subprojects {
  sourceCompatibility = 1.8
  targetCompatibility = 1.8
}

if (project.hasProperty('release')) {

  allprojects {

    if (JavaVersion.current().isJava8Compatible()) {
      allprojects {
        tasks.withType(Javadoc) {
          options.addStringOption('Xdoclint:none', '-quiet')
        }
      }
    }

  }
}

And these are the children:

description = ''
dependencies {
    compile group: 'com.github.javaparser', name: 'javaparser-core', version:'2.3.0'
    compile group: 'org.javassist', name: 'javassist', version:'3.19.0-GA'
    compile group: 'com.google.guava', name: 'guava', version:'18.0'
    compile project(':java-symbol-solver-model')
    compile project(':java-symbol-solver-logic')
    compile group: 'com.javaslang', name: 'javaslang', version:'2.0.0-beta'
    testCompile group: 'junit', name: 'junit', version:'4.12'
    testCompile group: 'org.easymock', name: 'easymock', version:'3.3.1'
}
description = ''
dependencies {
    compile group: 'com.github.javaparser', name: 'javaparser-core', version:'2.3.0'
    compile group: 'org.javassist', name: 'javassist', version:'3.19.0-GA'
    compile group: 'com.google.guava', name: 'guava', version:'18.0'
    compile project(':java-symbol-solver-core')
    testCompile group: 'junit', name: 'junit', version:'4.12'
    testCompile group: 'org.easymock', name: 'easymock', version:'3.3.1'
}
description = ''
dependencies {
    compile group: 'com.github.javaparser', name: 'javaparser-core', version:'2.3.0'
    compile group: 'org.javassist', name: 'javassist', version:'3.19.0-GA'
    compile group: 'com.google.guava', name: 'guava', version:'18.0'
    compile project(':java-symbol-solver-model')
    compile group: 'com.javaslang', name: 'javaslang', version:'2.0.0-beta'
    testCompile group: 'junit', name: 'junit', version:'4.12'
    testCompile group: 'org.easymock', name: 'easymock', version:'3.3.1'
}
description = ''
dependencies {
    compile group: 'com.github.javaparser', name: 'javaparser-core', version:'2.3.0'
    compile group: 'org.javassist', name: 'javassist', version:'3.19.0-GA'
    compile group: 'com.google.guava', name: 'guava', version:'18.0'
    compile group: 'com.javaslang', name: 'javaslang', version:'2.0.0-beta'
    testCompile group: 'junit', name: 'junit', version:'4.12'
    testCompile group: 'org.easymock', name: 'easymock', version:'3.3.1'
}

Plugin > 0.3 not available in the maven repo.

I am experiencing a problem supposedly fixed in #7. (using both 0.2 and 0.3)

However, the latest version is not available in the maven repo. I find it slightly ironic that a plugin designed to upload artifacts to maven, doesn't seem to be doing so.

Support for multiple repositories

If a project has multiple generated artifacts, all artifacts can currently only be uploaded to a single nexus repository URL.

Would that be possible to add support for multiple repositories, so that we can upload one artifact (eg. .jar file) to a configured URL and another artifact (eg. .zip file) to another URL ?

Could not find method modifyPom

Everything works fine for me with v0.3. I was trying out 0.6 and keep hitting this error:

FAILURE: Build failed with an exception.

* Where:
Build file '/urlshortener/build.gradle' line: 40

* What went wrong:
A problem occurred evaluating root project 'urlshortener'.
> Could not find method modifyPom() for arguments [build_3gjs2tkath1vk6re4mfisgsask$_run_closure4@6f7f0411] on root project 'urlshortener'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

The build file is available at https://github.com/maginatics/urlshortener/blob/master/build.gradle -- just switch to jcenter and bump plugin version to repro this failure.

Non-Java poject upload fails

I`m trying to upload to Nexus Flex library (swc file) build with GradleFx plugin.
Gradle-nexus-plugin fails with exception. The problem is that my project does not have java plugin applied (see this post).

I`ve added small change to gradle-nexus-plugin and will submit it as a PR.

Only sign artifacts if task graph has upload task

At the moment the signing task gets invoked on every run of the script. We should not require people to set the signing properties. Some stakeholder might only want to run the build without signing the artifacts.

Apply the required configuration element of the signing plugin to make it work. For some reason I had trouble it being evaluated correctly. I will need to dig deeper.

MissingMethodException: No signature of method: java.lang.Object.$()

Running a sample build with Groovy 1.8 and 1.7, the install tasks reports the following:

> Could not publish configuration 'archives'
   > Failed to notify action.
      > groovy.lang.MissingMethodException: No signature of method: java.lang.Object.$() is applicable for argument types: (java.util.Collections$EmptyMap, null) values: [[:], null]
Possible solutions: any(), is(java.lang.Object), wait(), find(), dump(), grep()

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

"Must specify a repository for deployment" error

upload tasks always fail with the following error:

Execution failed for task ':uploadArchives'.
> Could not publish configuration 'archives'
   > Must specify a repository for deployment

This config has worked in the past so I'm wondering if something's changed on the gradle/maven plugin side.

When I remove all nexus plugin code, the upload works.

// Gradle repositories and dependencies
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
    }
}

// Apply plugin
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.bmuschko.nexus'

// ...

uploadArchives.repositories.mavenDeployer {
    repository(url: "http://example.com/nexus/content/repositories/releases/")
    pom.version = "2.0-SNAPSHOT"
    pom.artifactId = "example"
    pom.groupId = "com.helion3"
}

extraArchive {
    sources = false
    tests = false
    javadoc = false
}

nexus {
    sign = false
    repositoryUrl = 'http://example.com/nexus/content/repositories/releases/'
    snapshotRepositoryUrl = 'http://example.com/nexus/content/repositories/snapshots/'
}

Gradle 2.10

Build time: 2015-12-21 21:15:04 UTC
Build number: none
Revision: 276bdcded730f53aa8c11b479986aafa58e124a6

Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_66 (Oracle Corporation 25.66-b17)
OS: Mac OS X 10.11.2 x86_64

Make ExtraArchivePlugin not use afterEvaluate

I'd like to use ExtraArchivePlugin, but in order to depend on its tasks in my project, I need them to be defined at apply-time, not in afterEvaluate. I claim there's no reason to define them in afterEvaluate, as I can paste the same code directly into my build.gradle and it works fine.

project.version is assumed to be a String which is wrong.

In

https://github.com/bmuschko/gradle-nexus-plugin/blob/master/src/main/groovy/com/bmuschko/gradle/nexus/NexusPlugin.groovy#L82

the NexusPlugin assumes that a project version is always a String. However Gradle defines the version as being an Object and always uses Object.toString() before working with the version. See documentation: http://www.gradle.org/docs/current/javadoc/org/gradle/api/Project.html#getVersion()

NexusPlugin should do the same because currently it is difficult to use the NexusPlugin with a release plugin (https://github.com/ajoberstar/gradle-git) which sets the version to a custom class (which is totally valid from a Gradle point of view). See issue: ajoberstar/gradle-git#92

-- J.

uploadArchives task fails with Gradle 2.3+ when distZip and distTar are not enabled

Here's the excerpt from my build.gradle

subprojects {
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'spring-boot'
    apply plugin: 'com.bmuschko.nexus'

    // these swallow disk space like a baleen whale swallows krill
    distTar.enabled = false
    distZip.enabled = false

    project.group = 'my-project-group'

    // disable fatjars too
    bootRepackage.enabled = false

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    extraArchive {
        sources = true
        tests = false
        javadoc = false
    }

    ext.nexusUsername = 'my-username'
    ext.nexusPassword = 'my-password'

    nexus {
        sign = false
        repositoryUrl = nexusUrl + '/nexus/content/repositories/releases'
        snapshotRepositoryUrl = nexusUrl + '/nexus/content/repositories/snapshots'
    }

    jar {
        baseName = project.name
        version =  currentVersion
    }

    springBoot {
        mainClass = 'my.main.class.Application'
    }

    modifyPom {
        project {
            name project.name
            description project.description
            url 'https://www.myurl.com/'
            inceptionYear '2015'

            groupId 'my-project-group'
            artifactId project.name
            version coverCoreVersion

            scm {
                url 'https://bitbucket.org/blah-blah-blah'
                connection 'scm:[email protected]:blah-blah-blah.git'
                developerConnection 'scm:[email protected]:blah-blah-blah.git'
            }

            // NB this is a collection of org.apache.maven.model.Dependency objects
            dependencies.findAll { dep -> dep.version == 'unspecified' }.each { d ->
                d.groupId = 'my-project-group'
                d.version = currentVersion
            }
        }
    }
}

And the error is:

Execution failed for task ':my-subproject:uploadArchives'.
> Could not publish configuration 'archives'
   > Cannot publish artifact 'my-subproject.zip (my-project-group:my-subproject:unspecified)' (/*redacted*/build/distributions/my-subproject.zip) as it does not exist.

It works okay in 2.2 but not in 2.3, 2.4, 2.5, 2.6 and 2.7.

SourceSets should be lazily referenced

In https://github.com/bmuschko/gradle-nexus-plugin/blob/master/src/main/groovy/org/gradle/api/plugins/nexus/NexusPlugin.groovy#L62 it's referencing sourceSets directly. It should be using a form of matching:

JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention)
javaConvention.sourceSets.matching {it.name == 'main'}.all { SourceSet set ->
    Jar sourcesJarTask = project.tasks.create(SOURCES_JAR_TASK_NAME, Jar)
     sourcesJarTask.classifier = 'sources'
     sourcesJarTask.from set.allSource
}

This will let the nexus plugin be applied in any order, right now it requires being applied after the java-base plugin, which makes it a little hard to reference via an init script.

Though, in the end this plugin shouldn't be generating source jars implicitly, that should be the job of another plugin.

Does this plugin support multi-project build?

I am having issues with using this plugin on a multi-project build. The error I got was:

* What went wrong:
A problem occurred configuring root project 'parent-proj'.
> Task with name 'install' not found in root project 'parent-proj'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Optional flag not generated in pom

This plugin does not retain the optional flag on a dependency, as set by the gradle-extra-configurations-plugin. When using the example with this plugin the dependency is not marked as optional, but if the plugin is removed the metadata is generated correctly.

apply plugin: 'com.bmuschko.nexus'
apply plugin: 'optional-base'

dependencies {
  compile 'org.apache.commons:commons-lang3:3.3.2', optional
  compile group: 'log4j', name: 'log4j', version: '1.2.17', optional
}
<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-lang3</artifactId>
  <version>3.3.2</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.17</version>
  <scope>compile</scope>
</dependency>

Support for Android project

Hi @bmuschko,
I have a project that Java and Android are mixed. I want to use gradle-nexus-plugin in Android project as with Java project.
Is there a plan that corresponds to the Android project?

Operation check is not enough, but I have the source code that runs in its own way.(Fork from gradle-nexus-plugin)
In just a few modifications, it works. If you have a plan, I want to show it to you.

Thanks!


My native language is Japanese. I'm using a machine translation. Please write in English polite. Ability of my English is not high. XD

Cannot upload when adding modifyPom closure

Without modifyPom I can upload successfully to Sonatype OSS but the artifacts cannot be closed as pom is not according the rules.
Hence I added modifyPom closure as described

modifyPom {
    project {
        ..
    }
}

But when I upload I get:

Execution failed for task ':uploadArchives'.

Could not publish configuration 'archives'
Failed to notify action.
> org.gradle.api.internal.MissingMethodException: Could not find method call() for arguments [build_25vt45toa4h0t5eac9511vbvf2$_run_closure1_closure9_closure12@3c71ebd6] on root project 'spring-appengine'.

When I just add:

modifyPom {
}

it works, but as soon as I adde the project section (even empty) it goes wrong.

broken with gradle 2.2.1

https://github.com/stanfy/gson-xml/blob/master/build.gradle#L14

  • What went wrong:
    A problem occurred evaluating root project 'gson-xml'.

    Failed to apply plugin [id 'nexus']
    Could not find method add() for arguments [sourcesJar, class org.gradle.api.tasks.bundling.Jar] on task set.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 11.652 secs
gson-xml$ gradle -v


Gradle 2.2.1

Build time: 2014-11-24 09:45:35 UTC
Build number: none
Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a

Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_65 (Oracle Corporation 24.65-b04)
OS: Mac OS X 10.9.4 x86_64

uploadArchives does not work for single-module projects

Since I moved to this from the Maven publishing plugin, all my single-module projects (shevek/jallocator, shevek/jcpp) etc don't work in uploadArchives, but all my multi-module projects (shevek/dhcp4j, shevek/ipmi4j) etc do work. The build files for these projects are otherwise almost indistinguishable. What's going on?

Update readme

In gradle >= 2.1 we can use the plugins task to add external plugins to the build

plugins {
  id "com.bmuschko.nexus" version "2.1.1"
}

maybe this should be specified in the readme and i didn't know what task to run after installing the plugin and found out later that it was uploadArchives, maybe that should be there as well.
One more thing does this publish to maven central because i uploaded my artifacts and i still don't see them in the repository

uploadArchives adds datestamp to SNAPSHOT builds

Uploading an artifact seems to be auto-generating a timestamp. I'm guessing that this is done via MavenDeployer's uniqueVersion. Taking a stab at fixing this, I added:

project.afterEvaluate {
    project.tasks.getByName("uploadArchives").repositories.mavenDeployer().setUniqueVersion(false)
}

but this didn't work.

I realize this might not be a problem with your plugin but is my own misunderstanding of how your plugin works with Gradle. Perhaps my real question is: how do I interact with the mavenDeployer object, given that I never create one in my script? I'm guessing your plugin creates the mavenDeployer behind the scenes.

For reference, the jar name looks like this:
projectname-1.0-20140321.212405-6.jar
I'd like it to look like this
projectname-1.0-${myOwnGenereatedNumber}.jar

ShortTypeHandling missing in gradle 1.12

Caused by: org.gradle.api.plugins.PluginInstantiationException: Could not create plugin of type 'ExtraArchivePlugin'.
        at org.gradle.api.internal.plugins.DefaultPluginRegistry.loadPlugin(DefaultPluginRegistry.java:67)
        at org.gradle.api.internal.plugins.DefaultPluginContainer.providePlugin(DefaultPluginContainer.java:103)
        at org.gradle.api.internal.plugins.DefaultPluginContainer.addPluginInternal(DefaultPluginContainer.java:68)
        at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:38)
        at org.gradle.api.plugins.PluginContainer$apply$0.call(Unknown Source)
        at com.bmuschko.gradle.nexus.NexusPlugin.apply(NexusPlugin.groovy:42)
        at com.bmuschko.gradle.nexus.NexusPlugin.apply(NexusPlugin.groovy)
        at org.gradle.api.internal.plugins.DefaultPluginContainer.providePlugin(DefaultPluginContainer.java:104)
        at org.gradle.api.internal.plugins.DefaultPluginContainer.addPluginInternal(DefaultPluginContainer.java:68)
        at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:34)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:116)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:85)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:129)
        at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:41)
        at nexus_107comchdlno0bi9m0bans6ivl$_run_closure1.doCall(/home/shevek/java/tftp4j/gradle/nexus.gradle:3)
        at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)
        at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:893)
        at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:898)
        at org.gradle.api.internal.project.AbstractProject.subprojects(AbstractProject.java:881)
        at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:225)
        at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:129)
        at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
        at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
        at nexus_107comchdlno0bi9m0bans6ivl.run(/home/shevek/java/tftp4j/gradle/nexus.gradle:2)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
        ... 64 more
Caused by: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
        at com.bmuschko.gradle.nexus.ExtraArchivePlugin.<clinit>(ExtraArchivePlugin.groovy)
        at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:62)
        at org.gradle.api.internal.plugins.DefaultPluginRegistry.loadPlugin(DefaultPluginRegistry.java:65)
        ... 91 more
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.typehandling.ShortTypeHandling
        ... 94 more

Ability to promote staging repository

To have less manual clicking and/or to make releasing to Maven Central automatic from CI server It would be useful to have an ability (another task?) to promote (probably also drop) staging repository from the plugin.

It should be probably possible with Nexus REST API.

Doesn't sign poms in a multi-module project

In a multi-module project the gradle-nexus-plugin doesn't sign the *.pom files, only jars.

I think the reason is line 144 in NexusPlugin.groovy method signInstallPom():

def installTasks = project.tasks.withType(Upload).matching { it.path == ":$MavenPlugin.INSTALL_TASK_NAME" }

This only finds install tasks which are named ":install", but in a multi-module project they are named ":submodule:subsubmodule:install".

So I think this issue would be fixed if you change line 144 to:

def installTasks = project.tasks.withType(Upload).matching { it.path.endsWith(":$MavenPlugin.INSTALL_TASK_NAME") }

(but I haven't tested it yet.)

The same probably applies to line 132:

def uploadTasks = project.tasks.withType(Upload).matching { it.path == extension.uploadTaskPath }

should be changed to:

def uploadTasks = project.tasks.withType(Upload).matching { it.path.endsWith(extension.uploadTaskPath) }

Setting uniqueVersion to false causes Ivy deployment errors

This one is a puzzle:

uploadArchives{
    repositories {
        mavenDeployer()
    }
}

causes

Caused by: A distributionManagement element or remoteRepository element is required to deploy
        at org.apache.maven.artifact.ant.DeployTask.getDeploymentRepository(DeployTask.java:186)
        at org.apache.maven.artifact.ant.DeployTask.doExecute(DeployTask.java:115)
        at org.gradle.api.publication.maven.internal.ant.CustomDeployTask.doExecute(CustomDeployTask.java:39)
        at org.apache.maven.artifact.ant.AbstractArtifactTask.execute(AbstractArtifactTask.java:751)
        at org.gradle.api.publication.maven.internal.ant.AbstractMavenResolver.execute(AbstractMavenResolver.java:111)
        at org.gradle.api.publication.maven.internal.ant.AbstractMavenResolver.publish(AbstractMavenResolver.java:102)
        at org.gradle.api.publication.maven.internal.ant.AbstractMavenResolver.publish(AbstractMavenResolver.java:80)
        at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyDependencyPublisher.publish(DefaultIvyDependencyPublisher.java:42)
        at org.gradle.api.internal.artifacts.ivyservice.IvyBackedArtifactPublisher$1.execute(IvyBackedArtifactPublisher.java:79)
        at org.gradle.api.internal.artifacts.ivyservice.IvyBackedArtifactPublisher$1.execute(IvyBackedArtifactPublisher.java:54)
        at org.gradle.internal.Transformers$3.transform(Transformers.java:131)
        at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:61)
        at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:39)
        at org.gradle.api.internal.artifacts.ivyservice.IvyBackedArtifactPublisher.publish(IvyBackedArtifactPublisher.java:54)
        at org.gradle.api.tasks.Upload.upload(Upload.java:64)
        ... 77 more

Now what I want to do is mavenDeployer { uniqueVersion = false } because I don't want datestamps in snapshots.

Can this be done in gradle-nexus-plugin?

Make authorization error more user-friendly

If I am trying to upload artifacts to a repository which requires sign-in credentials without having specified them in ~/.gradle/gradle.properties the following error is shown:

Execution failed for task ':foobar:uploadArchives'.
> Could not publish configuration 'archives'
   > Failed to deploy artifacts: Could not transfer artifact 
     com.example.library.foobar:foobar:aar:1.0.0-20160817.125338-10 from/to remote 
     (http://example.com/repository/example-snapshots/): Failed to transfer file: 
     http://example.com/repository/example-snapshots/com/example/library/foobar/foobar/
     1.0.0-SNAPSHOT/foobar-1.0.0-20160817.125338-10.aar. 
     Return code is: 401, ReasonPhrase: Unauthorized.

How about explicitly telling the user that the plugin is looking for the credentials in that location and that they could not be found?

Return code is: 401, ReasonPhrase: Unauthorized.
Cannot find sign-in credentials to authorize at the target repository. Please provide 'nexusUsername' and 'nexusPassword' in ~/.gradle/gradle.properties.

Ability to specify a configuration file to load credentials from

I understand that the recommendation is to put nexusUsername/password into gradle,properties.

However for various reasons this is difficult for me - basically I can't use the gradle.properties for this purpose and in anycase I wish to segregate the credentials from any other config I hold.

In my build environment I cannot influence the contents of $HOME so cannot rely on $HOME so can't put gradle.properties there.

Additionally I'm using 'Force GRADLE_USER_HOME to use workspace' in Jenkins and it is undesirable for me to place gradle.properties in the workspace.

So for me the gradle.properties approach isn't a good fit.

I would like a convenient method to tell the nexus plugin which file to look in for the props.

The following is a usage suggestion just for illustration and discussion ...

nexus {
     credentialsProperties file("/someLocationOfMyChoosing/nexus.credentials")
}

Where the file would contain ...

nexusUsername="hello"
nexusPassword="there"

The credentialsProperties location should be inspected ONLY if the credentials are required - ie only if I'm executing an upload task that needs the credentials..

I can of course hand crank something that optionally loads the properties in a manner that keeps the nexus plugin happy ...

// at top of gradle.build
ext.credentialsProperties=file("/someLocationOfMyChoosing/nexus.credentials")
if (ext.credentialsProperties.exists()) {
    apply from: ext.credentialsProperties
}

With the file containing something like ...

ext {
        nexusUsername="hello"
        nexusPassword="there"
}

However I would much rather just have something like the suggestion I made above as it is a one liner.

Please give your opinion on this suggestion and other options for plumbing the credentials properties into place.

PS Happy to do the work.

Ability to define additional tasks which should trigger setting authentication for repository

When using with gradle-nexus-staging-plugin it would be useful to trigger setting authentication for a repository even when uploadArchives task is not in a task graph. Then gradle-nexus-staging-plugin could reuse credentials defined with gradle-nexus-plugin executing its own closeRepository and promoteRepository tasks.

Those task would be defined in the nexus configuration closure.

@bmuschko if you like the idea I could provide a pull request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.