-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add dependabot file * Add gradle build workflow * Clean up / modify jar manifest definition * Add some logging around manifest definition (for testing purposes) * Modify how manifest is built and exception is caught * Update version of git-details plugin * Remove maven settings plugin and mavenLocal repository * Remove maven publishing
- Loading branch information
1 parent
a8f4615
commit 5cef775
Showing
3 changed files
with
184 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gradle" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
assignees: | ||
- "johnflavin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | ||
|
||
name: Java CI with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "main", "develop" ] | ||
pull_request: | ||
branches: [ "main", "develop" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '8' | ||
distribution: 'corretto' | ||
|
||
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. | ||
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
|
||
- name: Build with Gradle Wrapper | ||
run: ./gradlew fatJar | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: Package | ||
path: build/libs | ||
|
||
test: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '8' | ||
distribution: 'corretto' | ||
|
||
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. | ||
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
|
||
- name: Build with Gradle Wrapper | ||
run: ./gradlew test | ||
|
||
- name: Upload test artifacts | ||
run: mkdir staging && cp -r build/reports staging/ && cp -r build/test-results staging/ | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: Test Results | ||
path: staging | ||
|
||
dependency-submission: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '8' | ||
distribution: 'corretto' | ||
|
||
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. | ||
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md | ||
- name: Generate and submit dependency graph | ||
uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,9 @@ buildscript { | |
plugins { | ||
id "idea" | ||
id "java" | ||
id "maven-publish" | ||
id "com.palantir.git-version" version "0.12.1" | ||
id "com.palantir.git-version" version "3.1.0" | ||
id "io.spring.dependency-management" version "1.0.9.RELEASE" | ||
id "io.franzbecker.gradle-lombok" version "4.0.0" | ||
id "net.linguica.maven-settings" version "0.5" | ||
} | ||
|
||
group "org.nrg.xnatx.plugins" | ||
|
@@ -26,7 +24,6 @@ def vJavassist = "3.21.0-GA" | |
def vAwaitility = "2.0.0" | ||
|
||
repositories { | ||
mavenLocal() | ||
maven { url "https://nrgxnat.jfrog.io/nrgxnat/libs-release" } | ||
maven { url "https://nrgxnat.jfrog.io/nrgxnat/libs-snapshot" } | ||
mavenCentral() | ||
|
@@ -207,42 +204,35 @@ tasks.register ( 'integrationTest', Test ) { | |
test | ||
} | ||
|
||
// Pulls in the Jenkins BUILD_NUMBER environment variable if available. | ||
def buildDate = new Date() | ||
def buildNumber = System.getenv().BUILD_NUMBER?.toInteger() ?: "Manual" | ||
def isDirty, branchName, gitHash, gitHashFull, commitDistance, lastTag, isCleanTag | ||
|
||
// Build manifest from git repo information, if available | ||
def gitDetails, isDirty | ||
try { | ||
def gitDetails = versionDetails() | ||
gitDetails = versionDetails() | ||
isDirty = gitVersion().endsWith ".dirty" | ||
branchName = gitDetails.branchName ?: "Unknown" | ||
gitHash = gitDetails.gitHash | ||
gitHashFull = gitDetails.gitHashFull | ||
commitDistance = gitDetails.commitDistance | ||
lastTag = gitDetails.lastTag | ||
isCleanTag = gitDetails.isCleanTag | ||
} catch (IllegalArgumentException e) { | ||
} catch (ignored) { | ||
logger.info "Got an error trying to read VCS metadata from git. It's possible this project is not under VCS control. Using placeholder values for manifest entries." | ||
gitDetails = [ | ||
branchName: "Unknown", | ||
gitHash: "None", | ||
gitHashFull: "None", | ||
commitDistance: 0, | ||
lastTag: "None", | ||
isCleanTag: false | ||
] | ||
isDirty = true | ||
branchName = "Unknown" | ||
gitHash = "None" | ||
gitHashFull = "None" | ||
commitDistance = 0 | ||
lastTag = "None" | ||
isCleanTag = false | ||
} | ||
|
||
ext.gitManifest = manifest { | ||
def sharedManifest = java.manifest { | ||
attributes "Application-Name": pluginAppName, | ||
"Build-Date": buildDate, | ||
"Build-Number": buildNumber, | ||
"Build-Date": new Date(), | ||
"Build-Number": System.getenv().BUILD_NUMBER?.toInteger() ?: "Manual", // Pulls in the Jenkins BUILD_NUMBER environment variable if available. | ||
"Implementation-Version": project.version, | ||
"Implementation-Sha": gitHash, | ||
"Implementation-Sha-Full": gitHashFull, | ||
"Implementation-Commit": commitDistance, | ||
"Implementation-LastTag": lastTag, | ||
"Implementation-Branch": branchName, | ||
"Implementation-CleanTag": isCleanTag, | ||
"Implementation-Sha": gitDetails.gitHash, | ||
"Implementation-Sha-Full": gitDetails.gitHashFull, | ||
"Implementation-Commit": gitDetails.commitDistance, | ||
"Implementation-LastTag": gitDetails.lastTag, | ||
"Implementation-Branch": gitDetails.branchName ?: "Unknown", | ||
"Implementation-CleanTag": gitDetails.isCleanTag, | ||
"Implementation-Dirty": isDirty | ||
} | ||
|
||
|
@@ -257,8 +247,8 @@ task fatJar(type: Jar) { | |
exclude "META-INF/*.RSA" | ||
} | ||
duplicatesStrategy "exclude" | ||
manifest { | ||
from gitManifest | ||
manifest = java.manifest { | ||
from sharedManifest | ||
} | ||
with jar | ||
} | ||
|
@@ -268,9 +258,9 @@ sourceSets.main.java { | |
exclude "*/AutoValue.java" | ||
} | ||
|
||
jar{ | ||
manifest { | ||
from gitManifest | ||
jar { | ||
manifest = java.manifest { | ||
from sharedManifest | ||
} | ||
doLast { | ||
if (!gradle.taskGraph.hasTask(":fatJar")) { | ||
|
@@ -281,78 +271,73 @@ jar{ | |
|
||
task sourceJar(type: Jar, dependsOn: classes) { | ||
classifier = "sources" | ||
manifest { | ||
from gitManifest | ||
manifest = java.manifest { | ||
from sharedManifest | ||
} | ||
from sourceSets.main.allSource | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
classifier = "javadoc" | ||
manifest { | ||
from gitManifest | ||
manifest = java.manifest { | ||
from sharedManifest | ||
} | ||
from javadoc.destinationDir | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
artifacts { | ||
artifact sourceJar | ||
artifact javadocJar | ||
artifact fatJar | ||
} | ||
|
||
pom.withXml { | ||
def root = asNode() | ||
root.appendNode("name", pluginAppName) | ||
root.appendNode("description", "XNAT plugin for launching and managing containers.") | ||
root.appendNode("url", "https://github.com/nrgxnat/container-service") | ||
root.appendNode("inceptionYear", "2016") | ||
|
||
def scm = root.appendNode("scm") | ||
scm.appendNode("url", "https://github.com/nrgxnat/container-service") | ||
scm.appendNode("connection", "scm:https://github.com/nrgxnat/container-service.git") | ||
scm.appendNode("developerConnection", "scm:[email protected]:nrgxnat/container-service") | ||
|
||
def license = root.appendNode("licenses").appendNode("license") | ||
license.appendNode("name", "Simplified BSD 2-Clause License") | ||
license.appendNode("url", "https://xnat.org/about/license.php") | ||
license.appendNode("distribution", "repo") | ||
|
||
def developers = root.appendNode("developers") | ||
def flavin = developers.appendNode("developer") | ||
flavin.appendNode("id", "jflavin") | ||
flavin.appendNode("name", "John Flavin") | ||
flavin.appendNode("email", "[email protected]") | ||
|
||
def kelsey = developers.appendNode("developer") | ||
kelsey.appendNode("id", "kelseym") | ||
kelsey.appendNode("name", "Matt Kelsey") | ||
kelsey.appendNode("email", "[email protected]") | ||
|
||
def will = developers.appendNode("developer") | ||
will.appendNode("id", "hortonw") | ||
will.appendNode("name", "Will Horton") | ||
will.appendNode("email", "[email protected]") | ||
} | ||
} | ||
} | ||
repositories { | ||
maven { | ||
if (project.version.endsWith("-SNAPSHOT")) { | ||
url "https://nrgxnat.jfrog.io/nrgxnat/libs-snapshot-local" | ||
} else { | ||
url "https://nrgxnat.jfrog.io/nrgxnat/libs-release-local" | ||
} | ||
// The value for name must match <id> in ~/.m2/settings.xml | ||
name = "XNAT_Artifactory" | ||
} | ||
} | ||
} | ||
|
||
def propertyWithDefault(def String property, def Object value) { | ||
hasProperty(property) ? getProperty(property) : value | ||
} | ||
|
||
//publishing { | ||
// publications { | ||
// mavenJava(MavenPublication) { | ||
// artifacts { | ||
// artifact sourceJar | ||
// artifact javadocJar | ||
// artifact fatJar | ||
// } | ||
// | ||
// pom.withXml { | ||
// def root = asNode() | ||
// root.appendNode("name", pluginAppName) | ||
// root.appendNode("description", "XNAT plugin for launching and managing containers.") | ||
// root.appendNode("url", "https://github.com/nrgxnat/container-service") | ||
// root.appendNode("inceptionYear", "2016") | ||
// | ||
// def scm = root.appendNode("scm") | ||
// scm.appendNode("url", "https://github.com/nrgxnat/container-service") | ||
// scm.appendNode("connection", "scm:https://github.com/nrgxnat/container-service.git") | ||
// scm.appendNode("developerConnection", "scm:[email protected]:nrgxnat/container-service") | ||
// | ||
// def license = root.appendNode("licenses").appendNode("license") | ||
// license.appendNode("name", "Simplified BSD 2-Clause License") | ||
// license.appendNode("url", "https://xnat.org/about/license.php") | ||
// license.appendNode("distribution", "repo") | ||
// | ||
// def developers = root.appendNode("developers") | ||
// def flavin = developers.appendNode("developer") | ||
// flavin.appendNode("id", "jflavin") | ||
// flavin.appendNode("name", "John Flavin") | ||
// flavin.appendNode("email", "[email protected]") | ||
// | ||
// def kelsey = developers.appendNode("developer") | ||
// kelsey.appendNode("id", "kelseym") | ||
// kelsey.appendNode("name", "Matt Kelsey") | ||
// kelsey.appendNode("email", "[email protected]") | ||
// | ||
// def will = developers.appendNode("developer") | ||
// will.appendNode("id", "hortonw") | ||
// will.appendNode("name", "Will Horton") | ||
// will.appendNode("email", "[email protected]") | ||
// } | ||
// } | ||
// } | ||
// repositories { | ||
// maven { | ||
// if (project.version.endsWith("-SNAPSHOT")) { | ||
// url "https://nrgxnat.jfrog.io/nrgxnat/libs-snapshot-local" | ||
// } else { | ||
// url "https://nrgxnat.jfrog.io/nrgxnat/libs-release-local" | ||
// } | ||
// // The value for name must match <id> in ~/.m2/settings.xml | ||
// name = "XNAT_Artifactory" | ||
// } | ||
// } | ||
//} |