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

Update project to Gradle 6.9 #45

Merged
merged 5 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
string(credentialsId: 'atlas_node_release_coveralls_token', variable: 'coveralls_token')]) {

def testEnvironment = [
'osx' : [
'macos' : [
"artifactoryCredentials=${artifactory_publish}",
"artifactory_npm_token=${npm_token}",
"ATLAS_GITHUB_INTEGRATION_USER=${githubUser}",
Expand All @@ -46,5 +46,5 @@
]
]

buildGradlePlugin plaforms: ['osx','windows'], coverallsToken: coveralls_token, testEnvironment: testEnvironment
buildGradlePlugin platforms: ['macos','windows'], coverallsToken: coveralls_token, testEnvironment: testEnvironment
}
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ Applying the plugin
**build.gradle**
```groovy
plugins {
id 'net.wooga.node-release' version '0.+'
id 'net.wooga.node-release' version '2.+'
}
```

Conventions
===========
* Applies [nebula.release](https://github.com/nebula-plugins/nebula-release-plugin)
* Applies [com.moowork.node](https://github.com/nebula-plugins/nebula-release-plugin)
* Applies [com.github.node-gradle](https://github.com/node-gradle/gradle-node-plugin)
* Expects a valid `package.json` on project root.
* Expects `clean`, `test` and `build` task in `scripts` block of `package.json`
* Expects existence of a git repository with remote origin
Expand Down
33 changes: 21 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Wooga GmbH
* Copyright 2020-2022 Wooga GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,45 +16,54 @@
*/

plugins {
id 'net.wooga.plugins' version '1.4.0'
id 'net.wooga.plugins' version '3.0.0-rc.2'
}

group 'net.wooga.gradle'
description = 'Node release plugin for Gradle.'

repositories {
jcenter()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}

dependencies {
testCompile('org.jfrog.artifactory.client:artifactory-java-client-services:2.+') {
// TODO: Figure out how to address this once the below rejected versions finally work, they don't work when resolved to
testImplementation('org.jfrog.artifactory.client:artifactory-java-client-services:(2.9, 3]') {
exclude module: 'logback-classic'
version {
reject("2.11.1", "2.11.0")
prefer("2.10.0")
}
}
testCompile 'org.kohsuke:github-api:latest.release'
testCompile 'com.github.stefanbirkner:system-rules:1.18.0'
testImplementation 'org.kohsuke:github-api:1.3+'
testImplementation 'com.wooga.gradle:gradle-commons-test:0.3.0'

implementation 'org.ajoberstar.grgit:grgit-core:(4.1,5]'
implementation 'org.ajoberstar.grgit:grgit-gradle:(4.1,5]'
implementation "com.github.node-gradle:gradle-node-plugin:3.2.1"

compile 'com.netflix.nebula:nebula-release-plugin:6.+'
compile 'com.moowork.gradle:gradle-node-plugin:1.2.0'
compile "gradle.plugin.net.wooga.gradle:atlas-github:1.+"
compile "gradle.plugin.net.wooga.gradle:atlas-release:1.+"
compile gradleApi()
compile localGroovy()
// Internal wooga plugins
implementation 'com.wooga.gradle:gradle-commons:(0.4,0.5]'
implementation 'gradle.plugin.net.wooga.gradle:atlas-version:1+'
implementation 'gradle.plugin.net.wooga.gradle:atlas-github:(2, 3]'
}

pluginBundle {
website = 'https://wooga.github.io/atlas-node-release'
vcsUrl = 'https://github.com/wooga/atlas-node-release'
tags = ['Wooga', 'release', 'node', 'npm']
}

gradlePlugin {
plugins {
nodeRelease {
id = 'net.wooga.node-release'
displayName = 'Gradle Wooga Node Release plugin'
description = 'Plugin for wooga npm library releases'
implementationClass = "wooga.gradle.node.NodeReleasePlugin"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Wooga GmbH
* Copyright 2020 Wooga GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Wooga GmbH
* Copyright 2020 Wooga GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,18 +22,7 @@ import groovy.json.StringEscapeUtils
import org.junit.Rule
import org.junit.contrib.java.lang.system.ProvideSystemProperty

class IntegrationSpec extends nebula.test.IntegrationSpec {

@Rule
ProvideSystemProperty properties = new ProvideSystemProperty("ignoreDeprecations", "true")

def escapedPath(String path) {
String osName = System.getProperty("os.name").toLowerCase()
if (osName.contains("windows")) {
return StringEscapeUtils.escapeJava(path)
}
path
}
class IntegrationSpec extends com.wooga.gradle.test.IntegrationSpec {

String packageJsonContent(Map<String, Object> content) {
new JsonBuilder(content).toPrettyString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Wooga GmbH
* Copyright 2018-2022 Wooga GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright 2020 Wooga GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package wooga.gradle.node

import org.ajoberstar.grgit.Grgit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Wooga GmbH
* Copyright 2020-2022 Wooga GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -127,14 +127,16 @@ class NodeReleasePluginPublishSpec extends GithubIntegrationSpec {
def cleanupArtifactory(String repoName, String artifactName) {
List<RepoPath> searchItems = artifactory.searches()
.repositories(repoName)
.artifactsByName(artifactName)
.artifactsByName(artifactName.replaceAll(/\+.*$/, ''))
.doSearch()

for (RepoPath searchItem : searchItems) {
String repoKey = searchItem.getRepoKey()
println(repoKey)
String itemPath = searchItem.getItemPath()
artifactory.repository(repoName).delete(itemPath)
try {
artifactory.repository(repoName).delete(itemPath)
} catch (e) {
println("error while deleting ${itemPath}: ${e}")
}
}
}

Expand All @@ -144,8 +146,7 @@ class NodeReleasePluginPublishSpec extends GithubIntegrationSpec {
.artifactsByName(artifactName)
.doSearch()

assert packages.size() >= 2
true
packages.size() >= 2
}

def packageNameForPackageJson() {
Expand All @@ -154,7 +155,7 @@ class NodeReleasePluginPublishSpec extends GithubIntegrationSpec {
}

@Unroll
def 'builds and publish a package running task #task with version #version'() {
def 'builds and publish a package running task publish with #stage with version #version'() {
given: "the future npm artifact"
packageJsonFile.exists()

Expand All @@ -167,7 +168,8 @@ class NodeReleasePluginPublishSpec extends GithubIntegrationSpec {
git.commit(message: 'add files')

when: "run the publish task"
def result = runTasks(task)
environmentVariables.set("VERSION_BUILDER_STAGE", stage)
def result = runTasks("publish")
def config = new JsonSlurper().parseText(packageJsonFile.text)

then:
Expand All @@ -178,14 +180,14 @@ class NodeReleasePluginPublishSpec extends GithubIntegrationSpec {
config.version == version

where:
task | version
"snapshot" | "0.1.0-master.1"
"candidate" | "0.1.0-rc.1"
"final" | "0.1.0"
stage | version
"snapshot" | "0.1.0-master.1"
"rc" | "0.1.0-rc.1"
"final" | "0.1.0"
}

@Unroll
def 'builds and and create #task #version with github release #expectRelease as prerelease #prerelease'() {
def 'build and creates #stage version #version with github release #expectRelease as prerelease #prerelease'() {
given: "the future npm artifact"
packageJsonFile.exists()

Expand All @@ -197,25 +199,32 @@ class NodeReleasePluginPublishSpec extends GithubIntegrationSpec {
git.add(patterns: ['.'])
git.commit(message: 'add files')

and: "ensure artifact is not located on artifactory"
environmentVariables.set("VERSION_BUILDER_STAGE", stage)
cleanupArtifactory(artifactoryRepoName, "${packageID}-${version}")
assert !hasPackageOnArtifactory(artifactoryRepoName, "${packageID}-${version}")

when: "run the publish task"
def result = runTasks(task)
def result = runTasks("publish")

then:
result.success
result.wasExecuted("node_publish")
result.wasExecuted("npm_publish")
result.wasSkipped("githubPublish") != expectRelease

sleep(2000)
hasReleaseByName(version) == expectRelease
hasPackageOnArtifactory(artifactoryRepoName, "${packageID}-${version}")

if (expectRelease) {
getReleaseByName(version).prerelease == prerelease
}

where:
task | version | expectRelease | prerelease
"snapshot" | "0.1.0-master.1" | false | true
"candidate" | "0.1.0-rc.1" | true | true
"final" | "0.1.0" | true | false
stage | version | expectRelease | prerelease
"snapshot" | "0.1.0-master.1" | false | true
"rc" | "0.1.0-rc.1" | true | true
"final" | "0.1.0" | true | false
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Wooga GmbH
* Copyright 2020-2022 Wooga GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,8 @@ import groovy.json.JsonSlurper
import spock.lang.Unroll
import wooga.gradle.node.IntegrationSpec

import static com.wooga.gradle.PlatformUtils.escapedPath

class ModifyPackageJsonTaskSpec extends IntegrationSpec {

def "run ModifyPackageJsonTask successfully"() {
Expand Down
23 changes: 23 additions & 0 deletions src/main/groovy/wooga/gradle/node/Engine.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2022 Wooga GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package wooga.gradle.node

enum Engine {
npm,
yarn
}
Loading