Skip to content

Commit

Permalink
Merge pull request #4 from smancill/update-gradle
Browse files Browse the repository at this point in the history
Update Gradle Wrapper to version 8.7
  • Loading branch information
gurjyan authored Apr 10, 2024
2 parents 49c81a0 + 83b8728 commit 1ebdb81
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .mailmap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Sebastián Mancilla <[email protected]>
Sebastián Mancilla <smancill@smancill.dev> <smancill@jlab.org>
Vardan Gyurjyan <[email protected]>
Vardan Gyurjyan <[email protected]> <gurjyan@b9d438ff-8729-0410-a4ab-d2f36c9c72ed>
165 changes: 77 additions & 88 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

plugins {
id 'java-library'
id 'maven'
id 'com.google.protobuf' version '0.8.10'
id 'maven-publish'
id 'com.google.protobuf' version '0.9.4'

id 'checkstyle'
id 'com.github.spotbugs' version '1.6.9'
id 'com.github.spotbugs' version '5.2.5'

id 'eclipse'
id 'idea'
Expand All @@ -35,16 +35,8 @@ plugins {
group = 'org.jlab.coda'
version = '2.4-SNAPSHOT'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

defaultTasks 'build'


configurations {
deployerJars
}

sourceSets {
main {
proto {
Expand All @@ -69,13 +61,19 @@ dependencies {
api 'org.zeromq:jeromq:0.4.3'
api 'com.google.protobuf:protobuf-java:3.6.1'
implementation 'net.sf.jopt-simple:jopt-simple:5.0.4'
deployerJars 'org.apache.maven.wagon:wagon-ssh-external:2.12'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.0'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.5.0'
testImplementation 'org.hamcrest:hamcrest-library:2.1'
testImplementation 'org.mockito:mockito-core:2.28.2'
}

java {
withSourcesJar()
withJavadocJar()

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

ext {
generatedProtoDir = "${buildDir.name}/generated/source/proto/main/java"
Expand All @@ -92,76 +90,60 @@ protobuf {

tasks.withType(JavaCompile) {
if (JavaVersion.current() > JavaVersion.VERSION_1_8) {
options.compilerArgs += ['--release', '8']
options.release = 8
}
}


javadoc {
options.overview = 'src/org/jlab/coda/xmsg/overview.html'
options.charSet = 'utf8'
options.encoding = 'utf8'
options.docEncoding = 'utf8'
options.addStringOption('Xdoclint:none', '-quiet')

exclude "org/jlab/coda/xmsg/examples/**"
exclude "org/jlab/coda/xmsg/net/*Factory.java"
exclude "org/jlab/coda/xmsg/sys/*/*.java"
}


task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc
}

task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = 'sources'
from sourceSets.main.allJava
from generatedProtoDir
}

artifacts {
archives javadocJar
archives sourcesJar
}

uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.deployerJars
repository(url: 'scpexe://[email protected]/group/clas/www/clasweb/html/clas12maven') {
authentication(userName: 'clas12')
}
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
}


test {
testLogging {
exceptionFormat = 'full'
}
useJUnitPlatform {
excludeTags 'integration'
}
testLogging {
exceptionFormat = 'full'
}
}

task integrationTest(type: Test) {
tasks.register('integrationTest', Test) {
useJUnitPlatform {
includeTags 'integration'
}
testLogging {
showStandardStreams = true
events 'started', 'passed', 'failed'
}
testClassesDirs = testing.suites.test.sources.output.classesDirs
classpath = testing.suites.test.sources.runtimeClasspath
outputs.upToDateWhen { false }
}

//////////////////////////////////////////////////////////////////////////////
// deployment
//////////////////////////////////////////////////////////////////////////////

def deploySpec = copySpec {
into ('lib') {
from configurations.runtimeClasspath
from jar.archiveFile
from jar
}

from ('scripts/unix') {
Expand All @@ -171,7 +153,7 @@ def deploySpec = copySpec {
}
}

task deploy(type: Copy, dependsOn: install) {
tasks.register('deploy', Copy) {
def dest = "$System.env.CLARA_HOME"

into dest
Expand All @@ -182,42 +164,45 @@ task deploy(type: Copy, dependsOn: install) {
throw new GradleException('CLARA_HOME not set')
}
}

dependsOn publishToMavenLocal
}

//////////////////////////////////////////////////////////////////////////////
// development scripts
//////////////////////////////////////////////////////////////////////////////

ext.classPathCache = file("${buildDir}/tmp/classpath")
ext.testClassPathCache = file("${buildDir}/tmp/test_classpath")
ext {
classPathCache = file("${buildDir}/tmp/classpath")
testClassPathCache = file("${buildDir}/tmp/test_classpath")
}

task cacheClasspath {
tasks.register('cacheClasspath') {
inputs.files sourceSets.main.runtimeClasspath
inputs.files sourceSets.test.runtimeClasspath
outputs.files classPathCache
outputs.files testClassPathCache
doLast {
if (!classPathCache.isFile()) {
classPathCache.parentFile.mkdirs()
classPathCache.createNewFile()
}
classPathCache.write sourceSets.main.runtimeClasspath.asPath
testClassPathCache.write sourceSets.test.runtimeClasspath.asPath
}
}
cacheClasspath.inputs.files sourceSets.main.runtimeClasspath
cacheClasspath.inputs.files sourceSets.test.runtimeClasspath
cacheClasspath.outputs.files classPathCache
cacheClasspath.outputs.files testClassPathCache

task printClasspath {
tasks.register('printClasspath') {
doLast {
println classPathCache.text
println classPathCache.text.replace(':', '\n')
}
dependsOn cacheClasspath
}

build.dependsOn cacheClasspath
printClasspath.dependsOn cacheClasspath
assemble.dependsOn cacheClasspath

//////////////////////////////////////////////////////////////////////////////
// quality check
//////////////////////////////////////////////////////////////////////////////

def ciMode() {
if (hasProperty("ciMode")) {
return ciMode.toBoolean()
}
return false
ext {
ciMode = properties['ciMode'] ?: 'false'
}

checkstyle {
Expand All @@ -227,32 +212,30 @@ checkstyle {
}

spotbugs {
toolVersion = '3.1.12'
toolVersion = '4.8.3'
ignoreFailures = true
effort = 'max'
reportLevel = 'medium'
excludeFilter = file('config/quality/findbugs-exclude.xml')
}

tasks.withType(com.github.spotbugs.SpotBugsTask) {
def useXml = ciMode()
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
def useXml = ciMode.toBoolean()
reports {
xml.enabled = useXml
html.enabled = !xml.enabled
html.enabled = !useXml
}
}

// Marker task to enable SpotBugs.
task spotbugs(
group: 'Verification',
description: 'Marker task to enable SpotBugs.'
)

task checkSpotBugsResults {
tasks.register('checkSpotBugsResults') {
doLast {
def bugsFound = 0
[spotbugsMain, spotbugsTest].forEach {
bugsFound += printSpotBugs it.reports.xml.destination
[spotbugsMain, spotbugsTest].each {
try {
bugsFound += printSpotBugs it.reports.getByName('xml').destination
} catch (FileNotFoundException e) {
logger.info e.message
}
}
if (bugsFound > 0) {
throw new GradleException("$bugsFound SpotBugs rule violations were found.")
Expand All @@ -263,32 +246,38 @@ task checkSpotBugsResults {
def printSpotBugs(File xml) {
def slurped = new XmlSlurper().parse(xml)
def bugs = slurped.BugInstance

bugs.each { bug ->
def line = bug.SourceLine
logger.error "[SpotBugs] ${line.@sourcepath}:${line.@start}:${line.@end} [${bug.@type}]"
}
bugs.size()
}

if (ciMode()) {
checkSpotBugsResults.mustRunAfter spotbugsMain, spotbugsTest
check.dependsOn checkSpotBugsResults
tasks.register('spotbugs') {
group = 'Verification'
description = 'Marker task to enable SpotBugs.'

mustRunAfter spotbugsMain, spotbugsTest
if (ciMode.toBoolean()) {
finalizedBy checkSpotBugsResults
}
}

gradle.taskGraph.whenReady { taskGraph ->
tasks.spotbugsMain.onlyIf {
taskGraph.hasTask((tasks.spotbugs))
taskGraph.hasTask(tasks.spotbugs)
}
tasks.spotbugsTest.onlyIf {
taskGraph.hasTask((tasks.spotbugs))
taskGraph.hasTask(tasks.spotbugs)
}
tasks.checkSpotBugsResults.onlyIf {
taskGraph.hasTask((tasks.spotbugs))
taskGraph.hasTask(tasks.spotbugs)
}
}


//////////////////////////////////////////////////////////////////////////////
// IDE configuration
//////////////////////////////////////////////////////////////////////////////

eclipse {
classpath {
Expand Down
11 changes: 11 additions & 0 deletions config/quality/findbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,15 @@
<Match>
<Rank value="17" />
</Match>

<!-- Fix false positive -->
<Match>
<Class name="~.*xMsgUtil" />
<Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" />
</Match>

<!-- Exclude new detector added by 4.8.0 -->
<Match>
<Bug pattern="CT_CONSTRUCTOR_THROW" />
</Match>
</FindBugsFilter>
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 17 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# 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
#
# https://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.
#

##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
Loading

0 comments on commit 1ebdb81

Please sign in to comment.