Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

Commit

Permalink
Merge pull request #39 from jnehlmeier/issue-38
Browse files Browse the repository at this point in the history
Use toString() representation of project.version
  • Loading branch information
bmuschko committed Dec 20, 2014
2 parents 9a04f81 + ca5fe2e commit 7467669
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.bmuschko.gradle.nexus.singleproject
import org.gradle.tooling.model.GradleProject
import spock.lang.IgnoreIf
import spock.lang.Issue
import spock.lang.Unroll

import static com.bmuschko.gradle.nexus.AbstractIntegrationTest.hasSigningKey

Expand All @@ -27,6 +28,23 @@ import static com.bmuschko.gradle.nexus.AbstractIntegrationTest.hasSigningKey
* @author Benjamin Muschko
*/
class SingleProjectUploadIntegrationTest extends SingleProjectBuildIntegrationTest {

/**
* Different types that evaluate to version "1.0" when calling toString() on them.
*/
static final List<Object> VERIFIED_1_0_RELEASE_VERSION_TYPES = [
"'1.0'",
"new Object() { String toString() { '1.0' } }"
]

/**
* Different types that evaluate to version "1.0-SNAPSHOT" when calling toString() on them.
*/
static final List<Object> VERIFIED_1_0_SNAPSHOT_VERSION_TYPES = [
"'1.0-SNAPSHOT'",
"new Object() { String toString() { '1.0-SNAPSHOT' } }"
]

def setup() {
buildFile << """
extraArchive {
Expand All @@ -35,11 +53,12 @@ extraArchive {
"""
}

@Unroll
@IgnoreIf({ !hasSigningKey() })
def "Uploads all configured JARs, metadata and signature artifacts for release version with default configuration"() {
def "Uploads all configured JARs, metadata and signature artifacts for release version with default configuration for version '#projectVersion'"() {
when:
buildFile << """
version = '1.0'
version = $projectVersion
group = 'org.gradle.mygroup'
nexus {
Expand All @@ -55,6 +74,9 @@ nexus {
"${project.name}-1.0-sources.jar", "${project.name}-1.0-sources.jar.asc", "${project.name}-1.0-tests.jar",
"${project.name}-1.0-tests.jar.asc"]
assertExistingFiles(repoDir, expectedFilenames)

where:
projectVersion << VERIFIED_1_0_RELEASE_VERSION_TYPES
}

@IgnoreIf({ !hasSigningKey() })
Expand Down Expand Up @@ -272,11 +294,12 @@ nexus {
assertNoSignatureFiles(repoDir)
}

@Unroll
@IgnoreIf({ !hasSigningKey() })
def "Uploads all configured JARs, metadata and signature artifacts for snapshot version with default configuration"() {
def "Uploads all configured JARs, metadata and signature artifacts for snapshot version with default configuration for version '#projectVersion'"() {
when:
buildFile << """
version = '1.0-SNAPSHOT'
version = $projectVersion
group = 'org.gradle.mygroup'
nexus {
Expand All @@ -293,6 +316,9 @@ nexus {
"${project.name}-1\\.0-\\d+\\.\\d+-1\\-sources.jar", "${project.name}-1\\.0-\\d+\\.\\d+-1\\-sources.jar.asc",
"${project.name}-1\\.0-\\d+\\.\\d+-1\\-tests.jar", "${project.name}-1\\.0-\\d+\\.\\d+-1\\-tests.jar.asc"]
assertExistingFiles(repoDir, expectedFilenames)

where:
projectVersion << VERIFIED_1_0_SNAPSHOT_VERSION_TYPES
}

@IgnoreIf({ !hasSigningKey() })
Expand Down
3 changes: 2 additions & 1 deletion src/main/groovy/com/bmuschko/gradle/nexus/NexusPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class NexusPlugin implements Plugin<Project> {
if(extension.sign) {
project.signing {
required {
project.gradle.taskGraph.hasTask(extension.getUploadTaskPath(project)) && !project.version.endsWith('SNAPSHOT')
// Gradle allows project.version to be of type Object and always uses the toString() representation.
project.gradle.taskGraph.hasTask(extension.getUploadTaskPath(project)) && !project.version.toString().endsWith('SNAPSHOT')
}

sign project.configurations[extension.configuration]
Expand Down

0 comments on commit 7467669

Please sign in to comment.