Skip to content

Commit

Permalink
Merge branch 'gradle6' into 'master'
Browse files Browse the repository at this point in the history
Gradle6 + Gitlab pipeline

See merge request ghsc/hazdev/pdl!131
  • Loading branch information
jmfee-usgs committed Dec 16, 2020
2 parents 6090679 + ede1707 commit 8183231
Show file tree
Hide file tree
Showing 27 changed files with 920 additions and 364 deletions.
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ test-index.db
.idea/
out/
data/
.project
.settings
47 changes: 47 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
image: ${DEVOPS_REGISTRY}usgs/centos:8

stages:
- build

.check_code:
after_script:
# runs before cache is saved (copying from .travis.yml)
- rm -f "${CI_PROJECT_DIR}/.gradle/caches/modules-2/modules-2.lock"
- rm -fr "${CI_PROJECT_DIR}/.gradle/caches/*/plugin-resolution/"
artifacts:
paths:
- ProductClient.jar
- ProductClient.zip
reports:
cobertura: build/reports/cobertura/cobertura.xml
junit: build/test-results/test/TEST-*.xml
cache:
paths:
- .gradle/caches
- .gradle/wrapper
image: ${DEVOPS_REGISTRY}usgs/java:11-jdk
script:
# run gradle
- export GRADLE_USER_HOME="${CI_PROJECT_DIR}/.gradle"
- ./gradlew build createZip
# set up artifact paths
- cp build/libs/ProductClient.jar ProductClient.jar
- cp build/distributions/ProductClient.zip ProductClient.zip
stage: build
tags:
- development

Java 8:
extends:
- .check_code
image: ${DEVOPS_REGISTRY}usgs/java:8-jdk

Java 11:
extends:
- .check_code
image: ${DEVOPS_REGISTRY}usgs/java:11-jdk

Java Latest:
extends:
- .check_code
image: ${DEVOPS_REGISTRY}usgs/java:latest-jdk
23 changes: 0 additions & 23 deletions .project

This file was deleted.

2 changes: 0 additions & 2 deletions .settings/org.eclipse.buildship.core.prefs

This file was deleted.

4 changes: 0 additions & 4 deletions .settings/org.eclipse.jdt.core.prefs

This file was deleted.

62 changes: 36 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ plugins {
id "java"
id "jacoco" // code coverage
id "pmd" // static code analysis
id "com.gradle.build-scan" version "2.0.2" // post build results online
id "org.ajoberstar.grgit" version "2.3.0" // git repo information
id "org.ajoberstar.git-publish" version "1.0.1" // publish gh-pages branch
id "org.ajoberstar.grgit" version "4.1.0" // git repo information
id "org.ajoberstar.git-publish" version "3.0.0" // publish gh-pages branch
id "com.kageiit.jacobo" version "2.1.0"
}

sourceCompatibility = 1.8
Expand All @@ -27,30 +27,33 @@ configurations {
dependencies {
codacy "com.codacy:codacy-coverage-reporter:4.0+"

// for explanation of dependency types, see
// https://docs.gradle.org/current/userguide/building_java_projects.html

// javax.json
compile "javax.json:javax.json-api:1.1"
compile "org.glassfish:javax.json:1.1"
implementation "javax.json:javax.json-api:1.1"
runtimeOnly "org.glassfish:javax.json:1.1"
// javax.xml (for MessageUtils)
compile "javax.activation:activation:1.1.1"
compile "javax.xml.bind:jaxb-api:2.3+"
compile "org.glassfish.jaxb:jaxb-runtime:2.3+"
runtimeOnly "javax.activation:activation:1.1.1"
implementation "javax.xml.bind:jaxb-api:2.3+"
runtimeOnly "org.glassfish.jaxb:jaxb-runtime:2.3+"
// javax.websocket (for notifications)
compile "javax.websocket:javax.websocket-all:1.1"
compile "org.glassfish.tyrus.bundles:tyrus-standalone-client:1.17"
implementation "javax.websocket:javax.websocket-all:1.1"
implementation "org.glassfish.tyrus.bundles:tyrus-standalone-client:1.17"
// database drivers
compile "mysql:mysql-connector-java:5.1.47"
compile "org.xerial:sqlite-jdbc:3.23.1"
runtimeOnly "mysql:mysql-connector-java:5.1.47"
runtimeOnly "org.xerial:sqlite-jdbc:3.23.1"
// ssh keys
compile "ch.ethz.ganymed:ganymed-ssh2:262"
implementation "ch.ethz.ganymed:ganymed-ssh2:262"
// nats
implementation "io.nats:java-nats-streaming:2.1.6"

compile files("lib/MessageUtils.jar")
compile files("lib/QWFileOutClient.jar")
implementation files("lib/MessageUtils.jar")
implementation files("lib/QWFileOutClient.jar")
// XMLVerifier uses this, but is excluded for now
// compile files("lib/cap-library-r11.jar")

testImplementation("junit:junit:4.13")
testImplementation("junit:junit:4.13.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.7.0")
Expand All @@ -64,13 +67,14 @@ sourceSets {

// show compile warnings
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8';
options.setDeprecation(true);
options.setWarnings(true);
}

// coverage reports
jacoco {
toolVersion "0.8.2"
toolVersion "0.8.6"
}
jacocoTestReport {
reports {
Expand All @@ -81,7 +85,7 @@ jacocoTestReport {
check.dependsOn jacocoTestReport

pmd {
toolVersion = "6.17.0"
toolVersion = "6.29.0"
ruleSets = [
file("pmd-ruleset.xml")
]
Expand Down Expand Up @@ -128,14 +132,16 @@ javadoc {

// create jar file
jar {
baseName = "ProductClient"
archiveBaseName = "ProductClient"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

manifest {
attributes "Git-Commit": grgit.head().id
attributes "Main-Class": "gov.usgs.earthquake.distribution.Bootstrap"
}
from {
// classes and dependencies
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
from (".") {
// resources
Expand All @@ -148,7 +154,7 @@ jar {

// create zip bundle
task createZip(type: Zip, dependsOn: jar) {
archiveName "ProductClient.zip"
archiveFileName = "ProductClient.zip"
// init scripts and README
from "etc/examples/default"
// example listeners
Expand Down Expand Up @@ -186,11 +192,15 @@ gitPublish {

// Tasks for TravisCI

// run with "gradle build --scan" to post build output online
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
// convert jacoco to cobertura
import com.kageiit.jacobo.JacoboTask
tasks.create("jacobo", JacoboTask, {
it.jacocoReport = file("${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml")
it.coberturaReport = file("${project.buildDir}/reports/cobertura/cobertura.xml")
it.srcDirs = sourceSets.main.java.srcDirs
}).dependsOn(jacocoTestReport)
check.dependsOn jacobo


// .travis.yml uses this to upload coverage
task sendCoverageToCodacy(type: JavaExec, dependsOn: jacocoTestReport) {
Expand Down
Loading

0 comments on commit 8183231

Please sign in to comment.