Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Update samplebackend to Gradle 8 and Java 17 #67

Merged
merged 3 commits into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'

- name: Build modules
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ regarding the App Engine plugin with Gradle, go to this

Install and configure the following prerequisites:

- Make sure your environment is set to Java 11.
- Make sure your environment is set to Java 17.
- Make sure that your Cloud project is set up on your Google account. Go to
[Setting up and validating your Cloud project](https://cloud.google.com/appengine/docs/standard/java/using-gradle#setting_up_and_validating_your)
- [gcloud CLI tool](https://cloud.google.com/sdk/install).
Expand Down
100 changes: 68 additions & 32 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ buildscript { // Configuration for building
mavenCentral()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.5'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.8.1'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.4'
}
}

plugins {
// id 'com.github.sherter.google-java-format' version '0.8'
}

repositories { // repositories for Jar's you access in your code
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots' // SNAPSHOT repository (if needed)
Expand All @@ -39,47 +35,84 @@ apply plugin: 'war' // standard Web Archive plugin
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
apply plugin: 'com.google.protobuf'

// Define this to handle any internal references to 'compile' configuration
configurations {
compile.extendsFrom implementation
}

dependencies {
compileOnly 'com.google.appengine:appengine-api-1.0-sdk:2.0.26'
compileOnly 'javax.servlet:javax.servlet-api:3.1.0' // Use compileOnly for provided dependencies
compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
compileOnly 'jstl:jstl:1.2'

// Add dependencies here
// Core dependencies
implementation 'com.google.maps:fleetengine-auth:2.0.0'
implementation 'com.google.api:gax:1.65.1'
implementation 'com.google.api:gax:2.30.0'
implementation 'com.google.maps:google-maps-fleetengine:0.1.0'

implementation 'com.auth0:java-jwt:3.10.2'
// Guice dependencies
implementation 'com.google.inject:guice:5.1.0'
implementation 'com.google.inject.extensions:guice-servlet:5.1.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.google.auto.value:auto-value-annotations:1.6.2'
implementation 'com.google.guava:guava:30.1-jre'
implementation 'io.grpc:grpc-protobuf:1.28.0'
implementation 'io.grpc:grpc-stub:1.28.0'
implementation 'io.grpc:grpc-netty:1.28.0'
implementation 'javax.ws.rs:jsr311-api:1.1.1'
implementation 'com.google.protobuf:protobuf-java:3.25.3'
implementation 'javax.annotation:javax.annotation-api:1.2'
annotationProcessor 'com.google.auto.value:auto-value:1.6.2'

testImplementation 'junit:junit:4.12'
testImplementation 'com.google.truth:truth:0.33'
testImplementation 'org.mockito:mockito-all:1.10.19'
// Other dependencies
implementation 'com.auth0:java-jwt:3.19.2'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.google.auto.value:auto-value-annotations:1.10.1'
annotationProcessor 'com.google.auto.value:auto-value:1.10.1'
implementation 'com.google.guava:guava:32.1.2-jre'

// Explicitly add gRPC dependencies with fixed versions
implementation 'io.grpc:grpc-api:1.53.0'
implementation 'io.grpc:grpc-context:1.53.0'
implementation 'io.grpc:grpc-core:1.53.0'
implementation 'io.grpc:grpc-protobuf:1.53.0'
implementation 'io.grpc:grpc-stub:1.53.0'
implementation 'io.grpc:grpc-netty-shaded:1.53.0'
implementation 'io.grpc:grpc-auth:1.53.0'

// Protobuf dependencies
implementation 'com.google.protobuf:protobuf-java:3.21.7'
implementation 'com.google.protobuf:protobuf-java-util:3.21.7'

// Java annotations
implementation 'javax.annotation:javax.annotation-api:1.3.2'
implementation 'javax.ws.rs:jsr311-api:1.1.1'

// Test dependencies
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.google.truth:truth:1.1.3'
testImplementation 'org.mockito:mockito-core:3.12.4'
testImplementation 'com.google.appengine:appengine-testing:+'
testImplementation 'com.google.appengine:appengine-api-stubs:+'
testImplementation 'com.google.appengine:appengine-tools-sdk:+'
}

configurations.all {
withDependencies {
resolutionStrategy.eachDependency {
if (it.requested.group == 'com.google.guava' && it.requested.name == 'guava') {
it.useTarget("com.google.guava:guava:30.1-jre")
}
}
resolutionStrategy {
// Force gRPC versions to be consistent
force 'io.grpc:grpc-api:1.53.0'
force 'io.grpc:grpc-context:1.53.0'
force 'io.grpc:grpc-core:1.53.0'
force 'io.grpc:grpc-protobuf:1.53.0'
force 'io.grpc:grpc-stub:1.53.0'
force 'io.grpc:grpc-netty-shaded:1.53.0'
force 'io.grpc:grpc-auth:1.53.0'

// Force Guice to be consistent
force 'com.google.inject:guice:5.1.0'
force 'com.google.inject.extensions:guice-servlet:5.1.0'

// Force Guava version
force 'com.google.guava:guava:32.1.2-jre'
}
}

war {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from(configurations.runtimeClasspath) {
include '**/grpc-context-*.jar'
include '**/grpc-api-*.jar'
into 'WEB-INF/lib'
}
}

Expand Down Expand Up @@ -113,8 +146,11 @@ test {
}
}

group = "com.example.appenginej11" // Generated output GroupId
group = "com.example.appenginej17" // Generated output GroupId
version = "1.0-SNAPSHOT" // Version in generated output

sourceCompatibility = 11
targetCompatibility = 11
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
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-6.9.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 19 additions & 0 deletions src/main/appengine/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
runtime: java17
entrypoint: java -noverify -jar sampleprovider-1.0-SNAPSHOT.war
inbound_services:
- warmup
derived_file_type:
- java_precompiled
threadsafe: True
auto_id_policy: default
beta_settings:
'source_reference': 'https://github.com/googlemaps/java-on-demand-rides-deliveries-stub-provider.git#49b50e019b836f0cc96da29e14adc9bdfdab52e7'
api_version: 'user_defined'
handlers:
- url: /.*
secure: always
script: auto
http_headers:
Access-Control-Allow-Origin: '*'

skip_files: app.yaml
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/appengine-web.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<runtime>java11</runtime>
<runtime>java17</runtime>

<!-- Replace YOUR-APPID-HERE before deploying.
If you created an App Engine for Business (googleplex) app for Googlers
Expand Down