From 098afc0d8884fa09a557742e3f740d7f1a6cad9e Mon Sep 17 00:00:00 2001 From: Robert Oschwald Date: Fri, 15 May 2020 17:40:55 +0200 Subject: [PATCH] restructured gradle configs into separate files --- gradle.properties | 4 ++ gradle/artifactoryPublish.gradle | 13 ++++++ gradle/docs.gradle | 54 ++++++++++++++++++++++ gradle/grailsPublish.gradle | 22 +++++++++ plugin/build.gradle | 78 ++++---------------------------- travis-build.sh | 6 +-- 6 files changed, 104 insertions(+), 73 deletions(-) create mode 100644 gradle/artifactoryPublish.gradle create mode 100644 gradle/docs.gradle create mode 100644 gradle/grailsPublish.gradle diff --git a/gradle.properties b/gradle.properties index 08ae22b1..faad6f9f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,3 +4,7 @@ gradleWrapperVersion=5.6.4 org.gradle.daemon=true org.gradle.parallel=true org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1024M + +vcsUrl=https://github.com/robertoschwald/grails-audit-logging-plugin +websiteUrl=https://github.com/robertoschwald/grails-audit-logging-plugin +issueTrackerUrl=https://github.com/robertoschwald/grails-audit-logging-plugin/issues diff --git a/gradle/artifactoryPublish.gradle b/gradle/artifactoryPublish.gradle new file mode 100644 index 00000000..4bc4a8aa --- /dev/null +++ b/gradle/artifactoryPublish.gradle @@ -0,0 +1,13 @@ +artifactory { + contextUrl = 'https://oss.jfrog.org' + publish { + repository { + repoKey = 'oss-snapshot-local' + username = System.getenv("BINTRAY_USER") ?: project.hasProperty("bintrayUser") ? project.bintrayUser : '' + password = System.getenv("BINTRAY_KEY") ?: project.hasProperty("bintrayKey") ? project.bintrayKey : '' + } + defaults { + publications('maven') + } + } +} \ No newline at end of file diff --git a/gradle/docs.gradle b/gradle/docs.gradle new file mode 100644 index 00000000..8a36fcc9 --- /dev/null +++ b/gradle/docs.gradle @@ -0,0 +1,54 @@ +asciidoctor { + logDocuments true + baseDirFollowsSourceDir() + + sourceDir = file('src/docs') + sources { + include 'index.adoc' + } + + outputDir new File(buildDir, 'docs') + + outputOptions { + backends = ['html5', 'pdf', 'epub3'] + separateOutputDirs = false + } + + attributes 'experimental': 'true', + 'source-highlighter': 'coderay', + 'compat-mode': 'true', + toc: 'left', + icons: 'font', + setanchors: 'true', + idprefix: '', + idseparator: '-', + toc2: '', + numbered: '', + version: project.version, + groupId: project.group, + artifactId: project.name, + revnumber: project.version, + revdate: buildDate() +} + +task docs(dependsOn: 'asciidoctor') { + doLast { + File dir = new File(buildDir, 'docs') + dir.mkdirs() + + ['pdf', 'epub'].each { String ext -> + File f = new File(dir, 'index.' + ext) + if (f.exists()) { + f.renameTo new File(dir, project.name + '-' + project.version + '.' + ext) + } + } + + new File(buildDir, 'docs/ghpages.html') << file('src/docs/templates/index.tmpl').text.replaceAll("@VERSION@", project.version).replaceAll("@DOCDATE@", buildDate()) + + copy { + from 'src/docs' + into new File(buildDir, 'docs').path + include '**/*.png' + } + } +} diff --git a/gradle/grailsPublish.gradle b/gradle/grailsPublish.gradle new file mode 100644 index 00000000..14a3f41a --- /dev/null +++ b/gradle/grailsPublish.gradle @@ -0,0 +1,22 @@ +def setIfNotSet = { String name, value -> + if (!project.ext.has(name)) { + project.ext[name] = value + } +} +setIfNotSet 'issueTrackerUrl', project.vcsUrl + '/issues' +setIfNotSet 'websiteUrl', project.vcsUrl + +grailsPublish { + user = System.getenv("BINTRAY_USER") ?: project.hasProperty("bintrayUser") ? project.bintrayUser : '' + key = System.getenv("BINTRAY_KEY") ?: project.hasProperty("bintrayKey") ? project.bintrayKey : '' + githubSlug = 'robertoschwald/grails-audit-logging-plugin' + websiteUrl = project.hasProperty('websiteUrl') ? project.websiteUrl : "https://grails.org/plugin/$project.name" + license { + name = project.hasProperty('license') ? [project.license] : ['Apache-2.0'] + } + issueTrackerUrl = project.hasProperty('issueTrackerUrl') ? project.issueTrackerUrl : "https://github.com/grails-plugins/$project.name/issues" + vcsUrl = project.hasProperty('vcsUrl') ? project.vcsUrl : "https://github.com/robertoschwald/$project.name" + title = "Grails Audit-Logging Plugin" + desc = "Grails Audit-Logging Plugin for Grails 4.x" + developers = [robertoschwald:"Robert Oschwald", longwa:"Aaron Long", elkr:"Elmar Kretzer"] +} \ No newline at end of file diff --git a/plugin/build.gradle b/plugin/build.gradle index a0de1753..bc107453 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { classpath "org.grails:grails-gradle-plugin:$grailsVersion" - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' + classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release" } } @@ -26,13 +26,7 @@ apply plugin: "idea" apply plugin: "org.grails.grails-plugin" apply plugin: "org.grails.grails-plugin-publish" apply plugin: "org.grails.grails-gsp" -apply plugin: 'com.jfrog.bintray' - - - -// Used for publishing to central repository, remove if not needed -// apply from: 'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/grailsCentralPublishing.gradle' -// apply from:'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/bintrayPublishing.gradle' +apply plugin: "com.jfrog.artifactory" ext { grailsVersion = project.grailsVersion @@ -41,9 +35,12 @@ ext { repositories { mavenLocal() + mavenCentral() maven { url "https://repo.grails.org/grails/core" } } +sourceCompatibility = targetCompatibility = 1.8 + dependencies { profile "org.grails.profiles:web-plugin" @@ -80,69 +77,10 @@ task wrapper(type: Wrapper) { gradleVersion = gradleWrapperVersion } -grailsPublish { - user = System.getenv('BINTRAY_USER') - key = System.getenv('BINTRAY_KEY') - githubSlug = 'robertoschwald/grails-audit-logging-plugin' - license { - name = project.hasProperty('license') ? [project.license] : ['Apache-2.0'] - } - title = "Grails Audit-Logging Plugin" - desc = "Grails Audit-Logging Plugin for Grails 3.3.x" - developers = [robertoschwald:"Robert Oschwald", longwa:"Aaron Long", elkr:"Elmar Kretzer"] -} +apply from: "${rootProject.projectDir}/gradle/grailsPublish.gradle" +apply from: "${rootProject.projectDir}/gradle/artifactoryPublish.gradle" +apply from: "${rootProject.projectDir}/gradle/docs.gradle" -asciidoctor { - logDocuments true - baseDirFollowsSourceDir() - sourceDir = file('src/docs') - sources { - include 'index.adoc' - } - outputDir new File(buildDir, 'docs') - outputOptions { - backends = ['html5', 'pdf', 'epub3'] - separateOutputDirs = false - } - - attributes 'experimental': 'true', - 'source-highlighter': 'coderay', - 'compat-mode': 'true', - toc: 'left', - icons: 'font', - setanchors: 'true', - idprefix: '', - idseparator: '-', - toc2: '', - numbered: '', - version: project.version, - groupId: project.group, - artifactId: project.name, - revnumber: project.version, - revdate: buildDate() -} - -task docs(dependsOn: 'asciidoctor') { - doLast { - File dir = new File(buildDir, 'docs') - dir.mkdirs() - - ['pdf', 'epub'].each { String ext -> - File f = new File(dir, 'index.' + ext) - if (f.exists()) { - f.renameTo new File(dir, project.name + '-' + project.version + '.' + ext) - } - } - - new File(buildDir, 'docs/ghpages.html') << file('src/docs/templates/index.tmpl').text.replaceAll("@VERSION@", project.version).replaceAll("@DOCDATE@", buildDate()) - - copy { - from 'src/docs' - into new File(buildDir, 'docs').path - include '**/*.png' - } - } -} diff --git a/travis-build.sh b/travis-build.sh index 24c0d08d..326acc7f 100755 --- a/travis-build.sh +++ b/travis-build.sh @@ -24,10 +24,10 @@ if [[ ( -n "$TRAVIS_TAG" ) || ( "$TRAVIS_BRANCH" == "master" ) ]]; then if [[ -n $TRAVIS_TAG ]]; then echo " *** Publishing to Bintray.." - ./gradlew audit-logging:bintrayUpload -S || EXIT_STATUS=$? + ./gradlew :audit-logging:bintrayUpload || EXIT_STATUS=$? else - echo " *** Publishing to Grails Artifactory, as no release-tag was found (Currently disabled due to Artifactory error)" - # ./gradlew audit-logging:publish -S || EXIT_STATUS=$? + echo " *** Publishing SNAPSHOT to OJO, as no release-tag was found (SKIPPED. Disabled for now, as we do not have right for deployment, yet)" + # ./gradlew :audit-logging:artifactoryPublish || EXIT_STATUS=$? fi echo "*** Building docs and publish to gh-pages branch.."