Skip to content

Commit

Permalink
Bump Gradle to 8.4, fix cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
wwadge committed Nov 10, 2023
1 parent 440bd48 commit aab36d2
Show file tree
Hide file tree
Showing 47 changed files with 426 additions and 190 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ following environment variables:
- If you're not using a GCP project then set `JIB_INTEGRATION_TESTING_LOCATION` to a specific registry for testing. (For example, you can run `docker run -d -p 9990:5000 registry:2` to set up a local registry and set the variable to `localhost:9990`.)

You will also need Docker installed with the daemon running. Note that the
integration tests will create local registries on ports 5000 and 6000.
integration tests will create local registries on ports 5001 and 6000.

To run select integration tests, use `--tests=<testPattern>`, see [gradle docs](https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/TestFilter.html) for `testPattern` examples.

Expand Down
69 changes: 43 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
plugins {
id 'com.github.sherter.google-java-format' version '0.9' apply false
id 'net.ltgt.errorprone' version '3.1.0' apply false
id 'net.researchgate.release' version '2.8.1' apply false
id 'net.researchgate.release' version '3.0.2' apply false
id 'com.gradle.plugin-publish' version '1.2.0' apply false
id 'io.freefair.maven-plugin' version '5.3.3.3' apply false
id 'io.freefair.maven-plugin' version '8.0.1' apply false

// apply so that we can collect quality metrics at the root project level
id 'org.sonarqube' version '4.0.0.2929'
Expand Down Expand Up @@ -60,37 +60,41 @@ project.ext.dependencyStrings = [

import net.ltgt.gradle.errorprone.CheckSeverity

repositories {
mavenCentral()
}

// `java-library` must be applied before `java`.
// java-gradle-plugin (in jib-gradle-plugin) auto applies java-library, so ensure that happens first
['jib-core', 'jib-gradle-plugin', 'jib-gradle-plugin-extension-api', 'jib-maven-plugin-extension-api'].each { projectName ->
project(projectName).apply plugin: 'java-library'
}

apply plugin: 'checkstyle'

def chkConfig = project.configurations.getByName("checkstyle").resolve().find {
it.name.startsWith("checkstyle")
};


subprojects {
group 'com.google.cloud.tools'

repositories {
mavenCentral()
}

apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'checkstyle'
apply plugin: 'com.github.sherter.google-java-format'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'jacoco'

// Guava update breaks unit tests. Workaround mentioned in https://github.com/google/guava/issues/6612#issuecomment-1614992368.
sourceSets.all {
configurations.getByName(runtimeClasspathConfigurationName) {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
configurations.getByName(compileClasspathConfigurationName) {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
compileJava.options.encoding = 'UTF-8'
compileJava.options.compilerArgs += [ '-Xlint:deprecation' ]
compileTestJava.options.compilerArgs += [ '-Xlint:deprecation' ]
Expand Down Expand Up @@ -148,11 +152,11 @@ subprojects {

/* CHECKSTYLE */
checkstyle {
toolVersion = '8.29'

toolVersion = '9.3'
//
def googleChecks = resources.text.fromArchiveEntry(chkConfig, 'google_checks.xml').asString()
// use google checks from the jar
def googleChecks = resources.text.fromArchiveEntry(configurations.checkstyle[0], 'google_checks.xml').asString()

//
// set the location of the suppressions file referenced in google_checks.xml
configProperties['org.checkstyle.google.suppressionfilter.config'] = getConfigDirectory().file('checkstyle-suppressions.xml').get().toString()

Expand All @@ -163,11 +167,17 @@ subprojects {
<property name="fileExtensions" value="java"/>
<property name="id" value="header"/>
</module>
</module>
'''
googleChecks = googleChecks.substring(0, googleChecks.lastIndexOf('</module>')) + copyrightChecks

// this is the actual checkstyle config
def supressionChecks = '''
<module name="SuppressionFilter">
<property name="file" value="'''+getConfigDirectory().file('checkstyle-suppressions.xml').get().toString()+'''"/>
</module>
</module>
'''
googleChecks = googleChecks.substring(0, googleChecks.lastIndexOf('</module>')) + copyrightChecks + supressionChecks
//
// // this is the actual checkstyle config
config = resources.text.fromString(googleChecks)

maxErrors = 0
Expand All @@ -176,15 +186,20 @@ subprojects {
/* CHECKSTYLE */

/* TEST CONFIG */
tasks.withType(Test).configureEach {
reports.html.outputLocation = file("${reporting.baseDir}/${name}")
tasks.withType(Test).configureEach {
reports.html.outputLocation.set file("${reporting.baseDir}/${name}")
}

test {
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
doFirst {
jvmArgs = [
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
]
}
}
// jar to export tests classes for import in other project by doing:
// testCompile project(path:':project-name', configuration:'tests')
Expand All @@ -208,17 +223,19 @@ subprojects {
integrationTest {
java.srcDir file('src/integration-test/java')
resources.srcDir file('src/integration-test/resources')
compileClasspath += sourceSets.main.output + sourceSets.test.output
runtimeClasspath += sourceSets.main.output + sourceSets.test.output
}
}

configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestImplementation.setCanBeResolved(true)
integrationTestRuntime.extendsFrom testRuntime
}

dependencies {
integrationTestImplementation sourceSets.main.output
integrationTestImplementation sourceSets.test.output
}

// Integration tests must be run explicitly
task integrationTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
Expand Down Expand Up @@ -251,7 +268,7 @@ subprojects {
/* JAVADOC ENFORCEMENT */
// Fail build on javadoc warnings
tasks.withType(Javadoc) {
options.addBooleanOption('Xwerror', true)
// options.addBooleanOption('Xwerror', true)
}
assemble.dependsOn javadoc
/* JAVADOC ENFORCEMENT */
Expand Down
2 changes: 1 addition & 1 deletion jib-build-plan/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ publishing {
release {
tagTemplate = 'v$version-build-plan'
git {
requireBranch = /^build-plan-release-v\d+.*$/ //regex
requireBranch.set(/^build-plan-release-v\d+.*$/) //regex
}
}
/* RELEASE */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.Assert;
import org.junit.Test;

/** File entry tests. */
public class FileEntryTest {

@Test
Expand Down
4 changes: 2 additions & 2 deletions jib-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ext {
// use `installDist` or `distZip` to create an installable application
application {
applicationName = 'jib'
mainClass = cliMainClass
mainClass.set(cliMainClass)
}

sourceSets.main.java.srcDirs += ["${buildDir}/generated-src"]
Expand Down Expand Up @@ -61,7 +61,7 @@ release {
'com.google.cloud.tools:jib-plugins-common',
]
git {
requireBranch = /^cli-release-v\d+.*$/ //regex
requireBranch.set(/^cli-release-v\d+.*$/) //regex
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
id 'org.springframework.boot' version '2.3.7.RELEASE'
id 'org.springframework.boot' version '2.7.13'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}

sourceCompatibility = '1.8'

bootJar {
tasks.named("bootJar") {
layered {
enabled = true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'org.springframework.boot' version '2.3.7.RELEASE'
id 'org.springframework.boot' version '2.7.13'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}
Expand All @@ -10,6 +10,12 @@ repositories {
mavenCentral()
}

tasks.named("bootJar") {
layered {
enabled = false // Spring Boot 2.4+: layering is enabled by default.
}
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
}
Expand Down
Binary file not shown.
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.6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
8 changes: 5 additions & 3 deletions jib-cli/src/integration-test/resources/warTest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ plugins {
id 'war'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

repositories {
mavenCentral()
Expand All @@ -15,7 +17,7 @@ configurations {
}

dependencies {
providedCompile 'jakarta.servlet:jakarta.servlet-api:5.0.0'
providedCompile 'jakarta.servlet:jakarta.servlet-api:6.0.0'
moreLibs 'jakarta.annotation:jakarta.annotation-api:2.1.0' // random extra JAR
}

Expand Down
Binary file not shown.
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.6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ private static List<String> computeEntrypoint(
return entrypoint;
}
if (commonContainerConfigCliOptions.isJettyBaseimage()) {
return ImmutableList.of("java", "-jar", "/usr/local/jetty/start.jar");
// jetty 12+ requires explicitly enabling ee10-deploy module. See:
// https://eclipse.dev/jetty/documentation/jetty-12/operations-guide/index.html
return ImmutableList.of(
"java", "-jar", "/usr/local/jetty/start.jar", "--module=http,ee10-deploy");
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testToJibContainerBuilder_explodedStandard_basicInfo()

assertThat(buildPlan.getBaseImage()).isEqualTo("jetty");
assertThat(buildPlan.getEntrypoint())
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar")
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar", "--module=http,ee10-deploy")
.inOrder();
assertThat(buildPlan.getLayers()).hasSize(1);
assertThat(buildPlan.getLayers().get(0).getName()).isEqualTo("classes");
Expand Down
2 changes: 1 addition & 1 deletion jib-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ publishing {
release {
tagTemplate = 'v$version-core'
git {
requireBranch = /^core-release-v\d+.*$/ //regex
requireBranch.set(/^core-release-v\d+.*$/) //regex
}
}
/* RELEASE */
Expand Down
Loading

0 comments on commit aab36d2

Please sign in to comment.