Skip to content

Commit

Permalink
Add ci files and update build.gradle to make ci build happen
Browse files Browse the repository at this point in the history
  • Loading branch information
johnflavin committed Jun 5, 2024
1 parent a8f4615 commit ebc85d1
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 102 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
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"
89 changes: 89 additions & 0 deletions .github/workflows/gradle.yml
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
189 changes: 87 additions & 102 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
Expand Down Expand Up @@ -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
}

Expand All @@ -257,8 +247,8 @@ task fatJar(type: Jar) {
exclude "META-INF/*.RSA"
}
duplicatesStrategy "exclude"
manifest {
from gitManifest
manifest = java.manifest {
from sharedManifest
}
with jar
}
Expand All @@ -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")) {
Expand All @@ -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"
// }
// }
//}

0 comments on commit ebc85d1

Please sign in to comment.