Skip to content

Commit

Permalink
Merge pull request #236 from rundeck/exp/tool-module
Browse files Browse the repository at this point in the history
Refactor gradle project structure
  • Loading branch information
gschueler authored Jun 20, 2019
2 parents 89577e6 + 25ac4e2 commit 1ac2dec
Show file tree
Hide file tree
Showing 109 changed files with 316 additions and 175 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ deploy:
api_key:
secure: E5dKfiXBUTFpIJFWSk2+jBcS6FdO++DHqqGp8XDtrrCpKJfynYqPR+/23oYKYVz+H21CnEiUTqtVKvlftccWbErcRAD3R0G1bw6efj3TNiBb0Z0dRa8qgP+3NVTWhRZ4hwSn/0mClY96kz3cEjiJlBs6lYgneKlmg2As++LDjGIWZEfPUBXK6gtG69ZtMj2NBibKg1KQWZV6nZApBvYtkGJJqhu82jlDMbi5ltaOayVl4ISy0NlfcyW9ZNeLsCgjq9NVl5UV7ti6wB25fosz3fc7OZVF0SlU7Txg5Gi0bsnvRAijZRpZQwuo0Dza3Tqv6YDTXmfZT8qaqF6+SGNBH1BLSVApk2pBddJATzM5o0SZkuywUK4tMq6qCJjdPgMXnR4b/t3jK5f5w/ahWgYsqU7z7dBpxDDWafDFibkylJEQaUexktYdxq7JQZ5F6CNcT+qkPhj6LELR9eYh22xnuorwh6sfBfQqWJ0zveD9IcAv4Fl0ogXniftaLxRJ+G9vSQtzruWCTQRT3Ys2eIjc67wI47uMFcU5naM/YDt9BAQZzBoP9vKGiiyRwoa5kqpEy++qtod8oQTN1mw0B3BubrtlDAKirp8S+Zoix7EAvBt0abIO+zOvblUAjzb4zf2DxXkakvWZ4hxq8LnOItxItyBBRbDxiNYigYd8lRW0los=
file:
- build/distributions/rd-*.zip
- build/distributions/rundeck-cli*.rpm
- build/distributions/rundeck-cli*.deb
- build/libs/rundeck-cli-*-all.jar
- rd-cli-tool/build/distributions/rd-*.zip
- rd-cli-tool/build/distributions/rundeck-cli*.rpm
- rd-cli-tool/build/distributions/rundeck-cli*.deb
- rd-cli-tool/build/libs/rundeck-cli-*-all.jar
- rd-api-client/build/libs/rd-api-client-*.jar
on:
repo: rundeck/rundeck-cli
tags: true
file_glob: true
skip_cleanup: true
after_deploy:
- ./gradlew -PbintrayUser=gschueler -PbintrayUserOrg=rundeck -PbintrayRepo=rundeck-rpm -Pcomponent=rpm bintrayUpload
- ./gradlew -PbintrayUser=gschueler -PbintrayUserOrg=rundeck -PbintrayRepo=rundeck-deb -Pcomponent=deb bintrayUpload
- ./gradlew -PbintrayUser=gschueler -PbintrayUserOrg=rundeck -PbintrayRepo=rundeck-maven -Pcomponent=api bintrayUpload
- ./gradlew -p rd-cli-tool -PbintrayUser=gschueler -PbintrayUserOrg=rundeck -PbintrayRepo=rundeck-rpm -Pcomponent=rpm bintrayUpload
- ./gradlew -p rd-cli-tool -PbintrayUser=gschueler -PbintrayUserOrg=rundeck -PbintrayRepo=rundeck-deb -Pcomponent=deb bintrayUpload
- ./gradlew -p rd-api-client -PbintrayUser=gschueler -PbintrayUserOrg=rundeck -PbintrayRepo=rundeck-maven bintrayUpload
env:
global:
- secure: 2LDWRCZsuUYNUNHQz4oiaq9VIcdp0ziI7SKBxUxfqT4rehJ0J7kz+UPqwtgxMiUyQaHJQqzkcR+m6H3VZj9BREY+POiyu+yJOqhe3KRpDAfiN/gnwN81Nh9wloVaxyVe6i5yPaaBvE5vIREi7SAUdDtdsQ6WSkQ3JnaSL5Nz6e3DKR6+wgaTmBhh/TTW1YuN1qo5EjBpm0//M+KwY5BvVYOfPYLHCpVqnWFePQBkZY13lvufC5XPipXMf6c5Un/Uy6oVaRgLSPHDyELQvBzMSRPtzNmJSDm75LvclHHgDYEUcrcxRoWgAEISaBeIpGhe/PnsswCtQMfQBIm0W8Cv+HThbdCrrTdz/hWsohVvLFkCl9L8NOTOnATr2I9F0GBmsdhJvvr10JqGGol8Y9wwu5eiO9AWmchjZPicIWj5Dwo9E8AdT20aX4l287StESedS/Wtqh7gdf4d3Y1svWLEmh3gbERqOI9hRDV0DotfumhaW49SbaN/XecODiyPrnLBONSrYk1bWADDAvBZm/Jy0hvFbaVFFI8HfZMVJCO4GJJwna2MEMnsouNl2eDBFtvX5JHQ00JP4QacPFwW3/0NsgdaUGLiPSNezNJ1kBYtVbhQg4oL3yTkFaU6KuGhJcdSCVJUwOeP0YZF0oklofLhEhc4puzAi6EmGvLpMeh/huw=
Expand Down
153 changes: 2 additions & 151 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ buildscript {
}
plugins {
id 'pl.allegro.tech.build.axion-release' version '1.4.1'
id 'groovy'
id 'com.github.johnrengelman.shadow' version '2.0.3'
id "nebula.ospackage" version "4.8.0"

id 'maven'
}
ext.githubUrl = "https://github.com/rundeck/rundeck-cli"
ext.changelogFile = file("CHANGELOG.md")
Expand Down Expand Up @@ -156,154 +155,6 @@ task changeLog(){
}
}


apply plugin: 'idea'
apply plugin: 'groovy'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'nebula.ospackage'

mainClassName = 'org.rundeck.client.tool.Main'
applicationName = 'rd'
//install path in rpm/deb
ext.distInstallPath = '/var/lib/rundeck-cli'
defaultTasks 'clean', 'build'

repositories {
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }
}

ext.toolbeltVersion = "0.2.2"
ext.toolbeltGroup = "${toolbeltVersion.contains('SNAPSHOT')?'org':'com.github'}.rundeck.cli-toolbelt"

dependencies {
compileOnly "org.projectlombok:lombok:1.16.16"
annotationProcessor "org.projectlombok:lombok:1.16.16"

compile project(":rd-api-client")

compile "$toolbeltGroup:toolbelt:$toolbeltVersion"
compile "$toolbeltGroup:toolbelt-snakeyaml:$toolbeltVersion"
compile "$toolbeltGroup:toolbelt-json-jackson:$toolbeltVersion"
compile "$toolbeltGroup:toolbelt-jewelcli:$toolbeltVersion"

testCompile project(":rd-api-client")
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'com.squareup.retrofit2:retrofit-mock:2.1.0'
testCompile 'com.squareup.okhttp3:mockwebserver:3.5.0'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
testCompile "org.codehaus.groovy:groovy-all:2.3.7"
testCompile "org.spockframework:spock-core:0.7-groovy-2.0"
}
shadowJar {

}

//force distZip/distTar artifacts to be overwritten by shadow versions
shadowDistZip.mustRunAfter distZip
shadowDistTar.mustRunAfter distTar

def scriptsClos = {

def prependConfigData = { regexTest, additionalText, line ->
// Looking for the line that starts with regexTest closure argument,
//prepend the additionalText
line = line.replaceAll(~/${regexTest}/) { original ->
additionalText + "\n" + original
}
}
def appendConfigData = { regexTest, additionalText, line ->
line = line.replaceAll(~/${regexTest}/) { original ->
original + "\n" + additionalText
}
}

def addUnixConfigSource = prependConfigData.curry(
'^# Determine the Java command to use to start the JVM.*',
'''
# Source user's config file
RD_CONF=${RD_CONF:-$HOME/.$APP_NAME/$APP_NAME.conf}
test -f $RD_CONF && . $RD_CONF
'''
)
def setE = appendConfigData.curry(
'^#!/usr/bin/env sh',
'''
set -e
'''
)

// The default script content is generated and
// with the doLast method we can still alter
// the contents before the complete task ends.
doLast {
// Alter the start script for Unix systems.
unixScript.text =
unixScript
.readLines()
.collect(addUnixConfigSource)
.collect(setE)
.join('\n')

//TODO: modify windows start script to load config
}

}
startScripts scriptsClos
startShadowScripts scriptsClos

task verifyScripts {
group = "Verification"
description = 'Verify the start scripts (normal and shadow) contain the modifications for the RD_CONF'
doFirst {
[startScripts.outputDir, startShadowScripts.outputDir].each { dir ->
def f = new File(dir, applicationName)
assert f.exists()
assert f.text ==~ /(?s)^.*RD_CONF.*$/
}
}
}
check.dependsOn verifyScripts

/**
* Define rpm/deb details
*/
ospackage {
version = rpmVersion
release = 1
summary = "A commandline tool for Rundeck."
packageDescription = "The rd program provides an all-in-one commandline tool to interact with Rundeck"
url = 'https://github.com/rundeck/rundeck-cli'
vendor = 'Rundeck, Inc.'
license = 'APL'
os = 'LINUX'
packageGroup = 'System'
user = 'root'
prefix(distInstallPath)

//packaging includes the shadowDistZip contents, exclude *.bat
from(zipTree(shadowDistZip.outputs.files.singleFile)) {
exclude '**/*.bat'
into distInstallPath
}

def archivedir=shadowDistZip.archiveName - ".${shadowDistZip.extension}"

//symlink /usr/bin/rd to the rd script
postInstall("""
/bin/ln -s \${RPM_INSTALL_PREFIX:-${distInstallPath}}/${archivedir}/bin/${applicationName} /usr/bin/${applicationName}
""")
}

//depend on the shadow artifact
buildDeb.dependsOn shadowDistZip
buildRpm.dependsOn shadowDistZip
assemble.dependsOn buildRpm, buildDeb

apply from: 'gradle/bintray.gradle'

task wrapper(type: Wrapper) {
gradleVersion = '4.7'
}
15 changes: 15 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright 2019 Rundeck, Inc. (http://rundeck.com)
#
# 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.
#
32 changes: 20 additions & 12 deletions gradle/bintray.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
*/


def components = [
rpm: [pattern: '*.rpm', dir: "$buildDir/distributions", name: 'rundeck-cli', desc: 'Rundeck CLI Tools'],
deb: [pattern: '*.deb', dir: "$buildDir/distributions", name: 'rundeck-cli', desc: 'Rundeck CLI Tools'],
api: [pattern: '*.jar', dir: "rd-api-client/build/libs", name: 'rd-api-client', desc: 'Rundeck API Lib'],
]

def bintrayUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
def bintrayKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') :
System.getenv('BINTRAY_API_KEY')
Expand All @@ -35,6 +29,11 @@ def bintrayRepo = project.hasProperty('bintrayRepo') ? project.property('bintray

if (bintrayUser && bintrayKey && bintrayRepo) {

def components = [
rpm: [pat: '*.rpm'],
deb: [pat: '*.deb'],
]

def component = (
project.hasProperty('component') ? project.property('component') :
System.getenv('BINTRAY_UPLOAD_COMPONENT')
Expand All @@ -45,22 +44,25 @@ if (bintrayUser && bintrayKey && bintrayRepo) {
"Valid values: ${components.keySet()}"
)
}
def includePat = components[component].pattern

apply plugin: 'com.jfrog.bintray'
bintray {
user = bintrayUser
key = bintrayKey

filesSpec {
from(components[component].dir) {
include includePat
from("$buildDir/distributions") {
include components[component].pat
}

into "."
}

dryRun = false
publish = true
override = true
pkg {
name = components[component].name
name = 'rundeck-cli'
repo = bintrayRepo
if(bintrayUserOrg) {
userOrg = bintrayUserOrg
Expand All @@ -71,10 +73,16 @@ if (bintrayUser && bintrayKey && bintrayRepo) {
issueTrackerUrl = 'https://github.com/rundeck/rundeck-cli/issues'
githubRepo = 'rundeck/rundeck-cli' //Optional Github repository
githubReleaseNotesFile = 'README.md' //Optional Github readme file

if(component=='deb'){
debian {
distribution = 'any'
component = 'main'
architecture = 'noarch'
}
}
version {
name = rpmVersion
desc = "${components[component].desc} ${rpmVersion}"
desc = "Rundeck CLI Tools ${rpmVersion}"
vcsTag = "v${rpmVersion}"
}
}
Expand Down
87 changes: 86 additions & 1 deletion rd-api-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ buildscript {
}
plugins{
id 'de.fuerstenau.buildconfig' version '1.1.8'
id 'maven'
id 'maven-publish'
}


Expand All @@ -20,6 +22,8 @@ apply plugin: 'idea'
apply plugin: 'groovy'
apply plugin: 'de.fuerstenau.buildconfig'

group = 'org.rundeck.api'

/**
* Generates java source with embedded version info
*/
Expand Down Expand Up @@ -78,4 +82,85 @@ artifacts {
archives testJar
archives sourceJar
archives javadocJar
}
}
def pomConfig = {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
url 'https://github.com/rundeck/rundeck-cli'
connection 'scm:git:[email protected]/rundeck/rundeck-cli.git'
developerConnection 'scm:git:[email protected]:rundeck/rundeck-cli.git'
}
developers {
developer {
id('gschueler')
name('Greg Schueler')
email('[email protected]')
}
}
}
publishing {
publications {
rdApiClientPublication(MavenPublication) {
from components.java
artifact sourceJar
artifact javadocJar
artifact testJar

pom.withXml {
def root = asNode()
root.appendNode('description', project.description ?: 'Rundeck API Library')
root.appendNode('name', "Rundeck API Library ${project.version}")
root.appendNode('url', 'https://github.com/rundeck/rundeck-cli')
root.children().last() + pomConfig
}

}
}
}

def bintrayUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
def bintrayKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') :
System.getenv('BINTRAY_API_KEY')
def bintrayUserOrg = project.hasProperty('bintrayUserOrg') ? project.property('bintrayUserOrg') :
System.getenv('BINTRAY_USER_ORG')
def bintrayRepo = project.hasProperty('bintrayRepo') ? project.property('bintrayRepo') :
System.getenv('BINTRAY_REPO')

if (bintrayUser && bintrayKey && bintrayRepo) {

apply plugin: 'com.jfrog.bintray'
bintray {
user = bintrayUser
key = bintrayKey
publications = ['rdApiClientPublication']

dryRun = false
publish = true
override = true
pkg {
name = project.name
repo = bintrayRepo
if (bintrayUserOrg) {
userOrg = bintrayUserOrg
}
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/rundeck/rundeck-cli.git'
websiteUrl = 'https://github.com/rundeck/rundeck-cli'
issueTrackerUrl = 'https://github.com/rundeck/rundeck-cli/issues'
githubRepo = 'rundeck/rundeck-cli' //Optional Github repository
githubReleaseNotesFile = 'README.md' //Optional Github readme file

version {
name = rpmVersion
desc = "${description} ${rpmVersion}"
vcsTag = "v${rpmVersion}"
}
}
}
}
Loading

0 comments on commit 1ac2dec

Please sign in to comment.