Skip to content

Commit

Permalink
RLN-16: update to work with Gradle 7 (#22)
Browse files Browse the repository at this point in the history
* RLN-16: update to work with Gradle 7

* Update src/main/groovy/jp/co/soramitsu/devops/SoraPlugin.groovy

Co-authored-by: Bogdan Mingela <[email protected]>

* RLN-16: add RLN-46 to comments

* replace travis ci with github actions

Signed-off-by: Ahmed Elkashef <[email protected]>

* add --info for debug

* test run

* Added explicit local publishing

* Explicit test projects version

* try to set version manually

* remove test string

* Add conditions for publish step

* refactoring

* Fix tag var

* Check without tag

* Fix tag

* fix version obtain from system

* fix publish

* fix publish v2

* fix publish v3

* fix publish v5

* fix publish v6

* fix publish v6

* fix publish v7

* fix publish v 7.1

* fix publish v8

* fix projects version

* return old projects version

Co-authored-by: Bogdan Mingela <[email protected]>
Co-authored-by: Ahmed Elkashef <[email protected]>
Co-authored-by: Pavel Varfolomeev <[email protected]>
Co-authored-by: Mingela <[email protected]>
  • Loading branch information
5 people authored Sep 20, 2021
1 parent df46136 commit 85ecd50
Show file tree
Hide file tree
Showing 26 changed files with 130 additions and 141 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: test-deploy-gradle-sora-plugin
on: [pull_request, create]
jobs:
test-deploy-plugin:
runs-on: ubuntu-latest
steps:
# Checks-out the repo under $GITHUB_WORKSPACE, so that workflow accesses it
- uses: actions/checkout@v2
- name: Store gradle key & secret into gradle.properties
env:
GRADLE_KEY: ${{ secrets.GRADLE_KEY }}
GRADLE_SECRET: ${{ secrets.GRADLE_SECRET }}
run: |
mkdir -p ~/.gradle/
echo gradle.publish.key=${GRADLE_KEY} >> ~/.gradle/gradle.properties
echo gradle.publish.secret=${GRADLE_SECRET} >> ~/.gradle/gradle.properties
- name: Check for new tag created # and set TAG_NAME
if: ${{ github.event_name == 'create' && github.event.ref_type == 'tag' }}
run: |
echo "plugin_tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Make scripts executable
run: |
chmod +x gradlew
- name: Run Gradle Wrapper Daemon, Build, then Test
run: |
export TAG_NAME=${{ env.plugin_tag }}
./gradlew --daemon
./gradlew build -x test
./gradlew publishToMavenLocal
./gradlew test
- name: Run Publish # if new tag created
if: ${{ github.event_name == 'create' && github.event.ref_type == 'tag' }}
run: |
export TAG_NAME=${{ env.plugin_tag }}
./gradlew publishPlugins
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# gradle-devops-helper

Min supported gradle 4.8
Works with gradle 5+
Works with gradle 7

## Usage

Expand Down Expand Up @@ -52,10 +52,10 @@ soramitsu {
tag = "custom-tag"
# to enable dockerPush task, define registry credentials
registry {
url = 'https://nexus.iroha.tech:19001'
username = 'bogdan'
password = 'password'
email = '[email protected]' # optional
url = 'https://<host>:<port>'
username = '<username>'
password = '<password>'
email = '<email>' # optional
}
# files that will be added to the docker image (optional)
# host fs: docker image fs
Expand All @@ -69,10 +69,10 @@ soramitsu {

Docker registry data can be defined from env vars. Env vars ALWAYS override any value from build.gradle:
```bash
DOCKER_REGISTRY_URL="https://nexus.iroha.tech:19001"
DOCKER_REGISTRY_USERNAME="bogdan"
DOCKER_REGISTRY_PASSWORD="password"
DOCKER_REGISTRY_EMAIL="[email protected]"
DOCKER_REGISTRY_URL="https://<host>:<port>"
DOCKER_REGISTRY_USERNAME="<username>"
DOCKER_REGISTRY_PASSWORD="<password>"
DOCKER_REGISTRY_EMAIL="<email>"
```

## Features
Expand Down
18 changes: 8 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@ plugins {
// id 'nebula.lint' version '9.3.2'
id "com.palantir.idea-test-fix" version "0.1.0"
id 'groovy'
id 'maven'
id 'maven-publish'
id 'idea'
id 'java'
id "com.gradle.plugin-publish" version "0.10.1"
id "com.gradle.plugin-publish" version "0.15.0"
id "java-gradle-plugin"
id 'com.palantir.git-version' version '0.12.0-rc2'
id 'com.adarshr.test-logger' version '1.6.0'
id 'com.adarshr.test-logger' version '3.0.0'
}

group 'jp.co.soramitsu'
def pluginId = "${group}.sora-plugin"
version System.getenv('PLUGIN_VERSION') ?: "0.1.5"
version System.getenv('TAG_NAME') ?: "0.4.0"

repositories {
mavenCentral()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
Expand All @@ -29,19 +27,18 @@ dependencies {
implementation localGroovy()
testImplementation gradleTestKit()

implementation 'com.bmuschko:gradle-docker-plugin:4.6.0'
implementation 'com.bmuschko:gradle-docker-plugin:6.7.0'
implementation 'gradle.plugin.com.palantir.gradle.gitversion:gradle-git-version:0.12.0-rc2'


testImplementation('org.spockframework:spock-core:1.1-groovy-2.4') {
testImplementation('org.spockframework:spock-core:2.0-groovy-3.0') {
exclude module: 'groovy-all'
}
}

jar {
manifest {
attributes 'Implementation-Title': 'Gradle Sora plugin',
'Implementation-Version': version,
'Implementation-Version': archiveVersion,
'Built-By': System.getProperty('user.name'),
'Built-Date': new Date(),
'Built-JDK': System.getProperty('java.version'),
Expand All @@ -67,11 +64,12 @@ pluginBundle {
}

test {
useJUnitPlatform()
def projectsDir = "$project.projectDir/projects"
inputs.files fileTree(dir: projectsDir, exclude: '**/.gradle')
}

test.dependsOn(install)
test.dependsOn(publishToMavenLocal)

testlogger {
theme 'standard'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
11 changes: 4 additions & 7 deletions projects/01-java-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
gradlePluginPortal()
dependencies { classpath 'jp.co.soramitsu:sora-plugin:+' }
}
Expand All @@ -17,17 +17,14 @@ apply plugin: 'java'

println("Hello from 01-java-app")

repositories {
jcenter()
}

dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
}

// Define the main class for the application
group = 'jp.co.soramitsu'
mainClassName = 'example.App'
project.version = 'test'

soramitsu {
docker {
Expand All @@ -43,7 +40,7 @@ soramitsu {

jar {
manifest {
attributes 'Implementation-Version': version,
attributes 'Implementation-Version': archiveVersion,
'Main-Class': 'example.App'
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 3 additions & 2 deletions projects/02-java-lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
gradlePluginPortal()
dependencies { classpath 'jp.co.soramitsu:sora-plugin:+' }
}
Expand All @@ -12,9 +12,10 @@ apply plugin: 'java'
// this project does not have 'application' plugin, so docker tasks are not available

group = 'jp.co.soramitsu'
project.version = 'test'

println('Hello from 02-java-lib')

dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 8 additions & 11 deletions projects/03-kotlin-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
gradlePluginPortal()
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21'
classpath 'jp.co.soramitsu:sora-plugin:+'
}
}
Expand All @@ -22,9 +22,10 @@ apply plugin: 'kotlin'

println("Hello from 03-kotlin-app")

repositories {
jcenter()
}
// Define the main class for the application
mainClassName = 'example.App'
group = 'jp.co.soramitsu'
project.version = 'test'

dependencies {
// Use the Kotlin test library.
Expand All @@ -33,14 +34,10 @@ dependencies {
// Use the Kotlin JUnit integration.
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'

compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}


// Define the main class for the application
mainClassName = 'example.App'
group = 'jp.co.soramitsu'

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
Expand All @@ -59,7 +56,7 @@ soramitsu {
// define main class in the manifest
jar {
manifest {
attributes 'Implementation-Version': version,
attributes 'Implementation-Version': archiveVersion,
'Main-Class': 'example.App'
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 3 additions & 2 deletions projects/04-kotlin-lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
gradlePluginPortal()
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21'
classpath 'jp.co.soramitsu:sora-plugin:+'
}
}
Expand All @@ -15,6 +15,7 @@ apply plugin: 'kotlin'
// this project does not have 'application' plugin, so docker tasks are not available

group = 'jp.co.soramitsu'
project.version = 'test'

println('Hello from 04-kotlin-lib')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
11 changes: 5 additions & 6 deletions projects/05-java-spring-app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
gradlePluginPortal()
dependencies {
classpath 'jp.co.soramitsu:sora-plugin:+'
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.3.RELEASE")
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.5.4")
}
}
}
Expand All @@ -15,12 +15,11 @@ apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'


println("Hello from 05-java-spring-app")


group = 'jp.co.soramitsu'
mainClassName = 'example.javaspringapp.Application'
project.version = 'test'

repositories {
mavenCentral()
Expand All @@ -40,7 +39,7 @@ soramitsu {
// define main class in the manifest
jar {
manifest {
attributes 'Implementation-Version': version,
attributes 'Implementation-Version': archiveVersion,
'Main-Class': 'example.javaspringapp.Application'
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 85ecd50

Please sign in to comment.