diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 935ed1a1db..5b5a34a2fa 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -106,6 +106,11 @@ groupName: 'batik', automerge: true, }, + { + matchPackageNames: ['checkstyle', 'spotbugs'], + matchUpdateTypes: ['major', 'minor'], + enabled: false, + }, /** Accept only the patch on the stabilization branches */ { matchBaseBranches: ['/3\\..*/'], diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 891b555746..e63951ff12 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -90,7 +90,7 @@ jobs: if: always() - run: docker cp builder:/src/core/build/ core/build/ || true if: always() - - run: ls -l core/build/libs core/build/distributions + - run: ls -l core/build/distributions if: always() - run: docker cp mapfish-print_tests_1:/src/examples/build/ examples/build/ || true diff --git a/.gitignore b/.gitignore index 13a1556395..a21035f5e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,8 @@ /*/bin -/.classpath -/*/.classpath /.gradle/ -/.project -/*/.project -/.settings -/*/.settings/ /examples/*.jasper - +/reports/ /build/ /*/build/ -/examples/geoserver-data/.updatepassword.lock -/examples/geoserver-data/controlflow.properties -/examples/geoserver-data/gwc-gs.xml -/examples/geoserver-data/security/geoserver.jceks -/examples/geoserver-data/security/version.properties -/examples/geoserver-data/workspaces/default.xml -/examples/geoserver-data/wps.xml - /CI.asc -/.github/changelog-generator-cache diff --git a/Dockerfile b/Dockerfile index c1044b3c9d..3c141c3a3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM gradle:6.9.4-jdk11 AS builder +FROM gradle:8.1.1-jdk11 AS builder RUN --mount=type=cache,target=/var/cache,sharing=locked \ --mount=type=cache,target=/root/.cache \ diff --git a/build.gradle b/build.gradle index 818a751615..73c4aad5df 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import se.bjurr.violations.gradle.plugin.ViolationsTask + buildscript { repositories { mavenCentral() @@ -13,7 +15,7 @@ buildscript { defaultTasks 'build' wrapper { - gradleVersion = '6.9.4' + gradleVersion = '7.6.1' distributionType = Wrapper.DistributionType.ALL } @@ -22,7 +24,7 @@ allprojects { version = version } -configurations.all { +configurations.configureEach { resolutionStrategy { force 'xml-apis:xml-apis:2.0.2' } @@ -40,7 +42,7 @@ configure(subprojects.findAll { ['core', 'examples'].contains(it.name) }) { jar.dependsOn(checkstyleMain) checkstyle { - toolVersion = "10.10.0" // com.puppycrawl.tools:checkstyle + toolVersion = "6.19" // com.puppycrawl.tools:checkstyle configFile = file("$rootProject.rootDir/checkstyle_checks.xml") configProperties = ['basedir': project.rootDir.path] ignoreFailures = true @@ -49,22 +51,22 @@ configure(subprojects.findAll { ['core', 'examples'].contains(it.name) }) { checkstyleTest.enabled = false spotbugs { - toolVersion = "4.7.3" // com.github.spotbugs:spotbugs-annotations + toolVersion = "4.4.2" // com.github.spotbugs:spotbugs-annotations ignoreFailures = true reportsDir = file("$project.buildDir/reports/spotbugsReports") effort = "max" reportLevel = "high" } - spotbugsTest.enabled = false + spotbugsTest.enabled = true - task violations(type: se.bjurr.violations.gradle.plugin.ViolationsTask) { + tasks.register('violations', ViolationsTask) { minSeverity = 'INFO' detailLevel = 'VERBOSE' // PER_FILE_COMPACT, COMPACT or VERBOSE - maxViolations = 0 + maxViolations = 1070 printViolations = true violations = [ - ["FINDBUGS", ".", ".*/reports/spotbugsReports/.*\\.xml", "Spotbugs"], - ["CHECKSTYLE", ".", ".*/reports/checkstyleReports/.*\\.xml", "Checkstyle"] + ["FINDBUGS", ".", ".*/reports/spotbugsReports/.*\\.xml", "Spotbugs"], + ["CHECKSTYLE", ".", ".*/reports/checkstyleReports/.*\\.xml", "Checkstyle"] ] } check.finalizedBy violations @@ -75,7 +77,7 @@ configure(subprojects.findAll { ['core', 'examples'].contains(it.name) }) { compileJava.options.compilerArgs = ['-Xlint:deprecation', '-Xlint:unchecked'] dependencies { - testCompile( + testImplementation( "junit:junit:4.13.2", 'org.mockito:mockito-core:5.3.1', ) @@ -90,10 +92,17 @@ configure(subprojects.findAll { ['core', 'examples'].contains(it.name) }) { } } - tasks.withType(JavaCompile) { + tasks.withType(JavaCompile).configureEach { options.encoding = 'utf-8' } - tasks.withType(Javadoc) { - options.encoding = 'utf-8' + tasks.withType(Javadoc).tap { + configureEach { + options.encoding = 'utf-8' + } } } + +tasks.register('docs') { + enabled = false +} + diff --git a/checkstyle_checks.xml b/checkstyle_checks.xml index 4e2cbe7a34..185e1e7a25 100644 --- a/checkstyle_checks.xml +++ b/checkstyle_checks.xml @@ -77,15 +77,15 @@ - - - - - + + - - + + + + + diff --git a/core/build.gradle b/core/build.gradle index 18d6747e8f..4bff1f9eeb 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -7,7 +7,11 @@ apply plugin: 'distribution' defaultTasks 'build' repositories { - mavenCentral() + mavenCentral { + content { + excludeModule("javax.media", "jai_core") + } + } maven { url "https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts" } maven { url "https://repo.osgeo.org/repository/release/" } } @@ -15,24 +19,22 @@ repositories { // the task `run` of the gretty plugin conflicts with the task with the same // name of the plugin `application`. that's why the following tasks are defined // manually. -task startScripts(type: CreateStartScripts) { +tasks.register('startScripts', CreateStartScripts) { } -task print(type: JavaExec) { - main = 'org.mapfish.print.cli.Main' +tasks.register('print', JavaExec) { + mainClass = 'org.mapfish.print.cli.Main' classpath = sourceSets.main.runtimeClasspath } -// define what should be included as distribution. usually this configuration -// is done when applying the plugin `application`. this is the default config -// as in: https://github.com/gradle/gradle/blob/7df34b3f00e743cbd8f9398acb08e67edf86b527/subprojects/plugins/src/main/groovy/org/gradle/api/plugins/ApplicationPlugin.groovy#L123-L134 +// define what should be included as distribution. distributions { main { contents { - from(project.file('src/dist')) + from 'src/dist' into('lib') { from(jar) - from(project.configurations.runtime) + from(project.configurations.runtimeClasspath) } into('bin') { from(startScripts) @@ -47,14 +49,14 @@ def appDir = new File(project.buildDir, 'install') installDist.doFirst { appDir.deleteDir() } -tasks.withType(Javadoc) { +tasks.withType(Javadoc).configureEach { options.encoding = 'utf-8' title = "Mapfish Print Core Module $version" if (JavaVersion.current().isJava9Compatible()) { options.addBooleanOption('html5', true) } } -task testCLI(type: Exec) { +tasks.register('testCLI', Exec) { dependsOn installDist workingDir new File(appDir, 'core/bin') def cmd @@ -68,14 +70,14 @@ task testCLI(type: Exec) { File configFile = file('src/test/resources/org/mapfish/print/cli/config.yaml') File v3ApiRequestFile = file('src/test/resources/org/mapfish/print/cli/v3Request.json') cmd.addAll([ - '-config', configFile.getAbsolutePath(), - '-spec', v3ApiRequestFile.getAbsolutePath(), - '-output', outputFile.getAbsolutePath()]) + '-config', configFile.getAbsolutePath(), + '-spec', v3ApiRequestFile.getAbsolutePath(), + '-output', outputFile.getAbsolutePath()]) commandLine cmd environment('JAVA_OPTS', '-Xmx500m') doFirst { println("Testing CLI application: $workingDir") - outputFile.delete(); + outputFile.delete() assert !outputFile.exists() } doLast { @@ -83,28 +85,36 @@ task testCLI(type: Exec) { assert outputFile.length() > 0 } } + test { maxHeapSize = "500M" reports { - junitXml.enabled = true - html.enabled = true + junitXml.getRequired().set(true) + html.getRequired().set(true) } } -build.dependsOn tasks.distZip, tasks.testCLI + +build { + dependsOn(tasks.distZip) + dependsOn(tasks.testCLI) + processTestResources.mustRunAfter(javadoc) +} configurations { compile.transitive = true - compile.exclude module: 'jai_core' metrics { - description = 'Libraries for measuring performance and load. See http://metrics.codahale.com/' + description = 'Libraries for measuring performance and load. See https://github.com/dropwizard/metrics' } + implementation.extendsFrom(metrics) geotools { description = 'Geotools spatial libraries' } + implementation.extendsFrom(geotools) jasper { description = 'Dependencies for the jasper reports generation' } + implementation.extendsFrom(jasper) // Want to use the slf4j bridge instead all*.exclude group: 'commons-logging' @@ -115,7 +125,7 @@ configurations { dependencies { - compile( + implementation( "org.springframework:spring-context:5.3.27", "org.springframework:spring-web:5.3.27", "org.springframework:spring-webmvc:5.3.27", @@ -132,6 +142,7 @@ dependencies { "org.springframework:spring-jdbc:5.3.27", "org.springframework:spring-tx:5.3.27", "org.springframework:spring-test:5.3.27", + "javax.media:jai-core:1.1.3" ) metrics( "io.dropwizard.metrics:metrics-core:4.2.18", @@ -160,8 +171,7 @@ dependencies { "net.sf.jasperreports:jasperreports-functions:6.20.4", 'joda-time:joda-time:2.12.5' ) - compile fileTree(dir: "$projectDir/libs", include: '*.jar') - compile( + implementation( 'com.google.guava:guava:31.1-jre', "org.slf4j:slf4j-api:2.0.7", "org.slf4j:jcl-over-slf4j:2.0.7", @@ -179,15 +189,7 @@ dependencies { 'net.logstash.logback:logstash-logback-encoder:7.3', ) - compile(configurations.metrics) { - exclude module: 'httpclient' - exclude module: 'slf4j-api' - exclude module: 'logback-classic' - } - compile(configurations.geotools) - compile(configurations.jasper) - - compile( + implementation( 'org.apache.xmlgraphics:xmlgraphics-commons:2.8', "org.apache.xmlgraphics:batik-transcoder:1.16", "org.apache.xmlgraphics:batik-bridge:1.16", @@ -198,10 +200,10 @@ dependencies { providedCompile('javax.servlet:javax.servlet-api:4.0.1') compileOnly "com.github.spotbugs:spotbugs-annotations:4.7.3" - testCompile group: 'de.saly', name: 'javamail-mock2-fullmock', version: '0.5-beta4' + testImplementation group: 'de.saly', name: 'javamail-mock2-fullmock', version: '0.5-beta4' } -def gitRevision() { +static def gitRevision() { def gitRev = System.getenv('GIT_HEAD') return gitRev != null ? gitRev : "git rev-parse HEAD".execute().text.trim() } @@ -231,34 +233,35 @@ def addManifestAttribute(manifest) { jar { enabled = true - baseName = 'print-lib' + archiveBaseName = 'print-lib' addManifestAttribute(manifest) } war { - baseName = 'print-servlet' + archiveBaseName = 'print-servlet' addManifestAttribute(manifest) duplicatesStrategy = DuplicatesStrategy.EXCLUDE } -task show { +tasks.register('show') { } show.doLast { war.classpath.files.each { println it } } -task libJavadocJar(type: Jar, dependsOn: javadoc) { - baseName = 'print-lib' - classifier = 'javadoc' +tasks.register('libJavadocJar', Jar) { + dependsOn javadoc + archiveBaseName = 'print-lib' + archiveClassifier = 'javadoc' from 'build/docs/javadoc' } -task libSourcesJar(type: Jar) { - baseName = 'print-lib' +tasks.register('libSourcesJar', Jar) { + archiveBaseName = 'print-lib' from sourceSets.main.allSource - classifier = 'sources' + archiveClassifier = 'sources' } @@ -276,8 +279,8 @@ gradle.taskGraph.whenReady { taskGraph -> startScripts { // Clear up the classpath because the launcher jar has it. applicationName = 'print' - mainClassName = 'org.mapfish.print.cli.Main' - classpath = files(jar.archivePath) + mainClass = 'org.mapfish.print.cli.Main' + classpath = files(jar.archiveFile) outputDir = new File(project.buildDir, 'scripts') doLast { @@ -286,12 +289,12 @@ startScripts { // There was a bug in the start script where all jars were listed and that failed in windows. // now I just have the main jar and replace it with * so that all jars in that directory // are loaded on classpath. - file.setText(file.getText(encoding).replace(jar.archivePath.name, '*'), encoding) + file.setText(file.getText(encoding).replace(jar.archiveFile.get().getAsFile().name, '*'), encoding) } } } -task explodedWar(type: Sync) { +tasks.register('explodedWar', Sync) { into "${buildDir}/webapp" with war } diff --git a/core/libs/README.md b/core/libs/README.md deleted file mode 100644 index 3ef778cb4b..0000000000 --- a/core/libs/README.md +++ /dev/null @@ -1,2 +0,0 @@ -The jars in this directory are jars that have problems in the maven repositories because of bad descriptors or -some other reason and sometimes fail to download (for example by travis). diff --git a/core/libs/jai_core-1.1.3.jar b/core/libs/jai_core-1.1.3.jar deleted file mode 100644 index b29b8eed5b..0000000000 Binary files a/core/libs/jai_core-1.1.3.jar and /dev/null differ diff --git a/docs/build.gradle b/docs/build.gradle index 57121f3ba3..849f30acc8 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -5,28 +5,40 @@ apply plugin: 'idea' defaultTasks 'build' repositories { - mavenCentral() + mavenCentral { + content { + excludeModule("javax.media", "jai_core") + } + } maven { url "https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts" } maven { url "https://repo.osgeo.org/repository/release/" } } dependencies { - compile project(':core') - compile "org.codehaus.groovy:groovy-all:3.0.17", + implementation project(':core') + implementation ("org.codehaus.groovy:groovy-all:3.0.17", "org.springframework:spring-test:5.3.27", 'org.ccil.cowan.tagsoup:tagsoup:1.2.1', - 'com.samskivert:jmustache:1.15' + 'com.samskivert:jmustache:1.15', + 'com.google.guava:guava:31.1-jre', + 'commons-io:commons-io:2.11.0', + "org.springframework:spring-beans:5.3.27", + "org.springframework:spring-web:5.3.27", + "org.springframework:spring-context:5.3.27", + 'javax.servlet:javax.servlet-api:4.0.1' + ) } def site = new File(buildDir, "site").path -task copyJavadocs(type: Copy) { +tasks.register('copyJavadocs', Copy) { dependsOn ':core:javadoc' from project(':core').tasks.javadoc.destinationDir into new File(site, 'javadoc') } -task copySite(type: Copy) { +tasks.register('copySite', Copy) { + dependsOn ':docs:processResources' from(sourceSets.main.output.resourcesDir) { exclude 'pages.json', 'templates/*', 'templates' } @@ -37,12 +49,12 @@ task copySite(type: Copy) { into site } -task('buildDocs', type: JavaExec) { +tasks.register('buildDocs', JavaExec) { dependsOn compileGroovy dependsOn copyJavadocs dependsOn copySite - main = 'GenerateDocs' + mainClass = 'GenerateDocs' classpath = sourceSets.main.runtimeClasspath def javadocs = project(':core').tasks.javadoc.destinationDir diff --git a/examples/build.gradle b/examples/build.gradle index 185ca736da..30d5594a79 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -1,28 +1,38 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent repositories { - mavenCentral() + mavenCentral { + content { + excludeModule("javax.media", "jai_core") + } + } maven { url 'https://maven.restlet.org' } maven { url "https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts" } maven { url "https://repo.osgeo.org/repository/release/" } } dependencies { - testCompile( + testImplementation( project(':core'), + 'commons-io:commons-io:2.11.0', + "org.springframework:spring-web:5.3.27", + 'org.json:json:20230227', + 'org.apache.commons:commons-lang3:3.5', + "org.locationtech.jts:jts-core:1.18.2", + "org.slf4j:slf4j-api:2.0.7", + "org.springframework:spring-test:5.3.27", + "ch.qos.logback:logback-classic:1.4.7" ) } configurations { - compile.exclude module: 'jai_core' - // need to exclude those two to get rid of stuff taken from geotools dependencies (they break the tests) compile.exclude group: 'org.eclipse.emf', module: 'ecore' compile.exclude group: 'org.eclipse.emf', module: 'common' compile.exclude group: 'org.slf4j', module: 'slf4j-log4j12' } -task geoserver(type: Exec) { +tasks.register('geoserver' , Exec) { description 'Run and wait for GeoServer with test data' commandLine 'curl', 'http://geoserver:8080/web/', '--output', '/dev/null' } @@ -33,7 +43,8 @@ task geoserver(type: Exec) { test {} test.onlyIf { false } -task integrationTest(type: Test) { +tasks.register('integrationTest', Test) { + dependsOn(':core:compileJava', 'geoserver') testLogging { exceptionFormat = 'full' showCauses true @@ -43,8 +54,7 @@ task integrationTest(type: Test) { } maxHeapSize = "750M" reports { - junitXml.enabled = true - html.enabled = true + junitXml.getRequired().set(true) + html.getRequired().set(true) } } -integrationTest.dependsOn ':core:compileJava', 'geoserver' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c023..943f0cbfa7 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c51cbf1737..8707e8b506 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787337..65dcd68d65 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # 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" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd32c4..93e3f59f13 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal