Skip to content

Commit 33a3d78

Browse files
committed
Update project to Java 21, Gradle 8.5, and modernize CI/CD
Summary of changes: - Upgraded Java target to version 21. - Updated Gradle wrapper to version 8.5 for Java 21 compatibility. - Refactored SerpApi.java to remove incorrect inheritance from Exception. - Updated GitHub Actions workflow to use Java 21 and gradle-setup-java action. - Switched environment variable for API keys to SERPAPI_KEY in tests and CI. - Reorganized tests: moved engine examples to src/test/java/serpapi/example/. - Fixed failures in LocationApiTest and GoogleReverseImageTest.
1 parent 5ba6913 commit 33a3d78

35 files changed

+115
-265
lines changed

.github/workflows/gradle.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v2
19-
- name: Set up JDK 1.8
20-
uses: actions/setup-java@v1
18+
- uses: actions/checkout@v4
19+
- name: Set up JDK 21
20+
uses: actions/setup-java@v4
2121
with:
22-
java-version: 1.8
22+
java-version: '21'
23+
distribution: 'temurin'
2324
- name: Grant execute permission for gradlew
2425
run: chmod +x gradlew
26+
- name: Build with Gradle
27+
uses: gradle/actions/setup-gradle@v3
2528
- name: test
2629
run: ./gradlew test
2730
env:
28-
API_KEY: ${{secrets.API_KEY}}
31+
SERPAPI_KEY: ${{secrets.SERPAPI_KEY}}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018-2024 SerpApi
3+
Copyright (c) 2018-2025 SerpApi
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ it prints the first 3 location matching Austin (Texas, Texas, Rochester)
123123
Let's run a search to get a search_id.
124124
```java
125125
Map<String, String> auth = new HashMap<>();
126-
auth.put("api_key", System.getenv("API_KEY"));
126+
auth.put("api_key", System.getenv("SERPAPI_KEY"));
127127
SerpApi serpapi = new SerpApi(auth);
128128

129129
Map<String, String> parameter = new HashMap<>();

README.md.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ it prints the first 3 location matching Austin (Texas, Texas, Rochester)
135135
Let's run a search to get a search_id.
136136
```java
137137
Map<String, String> auth = new HashMap<>();
138-
auth.put("api_key", System.getenv("API_KEY"));
138+
auth.put("api_key", System.getenv("SERPAPI_KEY"));
139139
SerpApi serpapi = new SerpApi(auth);
140140

141141
Map<String, String> parameter = new HashMap<>();

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ plugins {
99

1010
// Package default
1111
archivesBaseName = 'serpapi'
12-
version = '1.0.0'
12+
version = '1.1.0'
1313
group = 'com.github.serpapi'
1414

1515
// java version
16-
sourceCompatibility = 1.8
17-
targetCompatibility = 1.8
16+
sourceCompatibility = 21
17+
targetCompatibility = 21
1818

1919
// Load repositories
2020
repositories {
@@ -65,6 +65,6 @@ publishing {
6565
}
6666

6767
wrapper {
68-
gradleVersion = "7.3.3"
68+
gradleVersion = "8.5"
6969
distributionType = Wrapper.DistributionType.ALL
7070
}

demo/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.PHONY: build
22

3-
ifndef API_KEY
4-
$(error "API_KEY must be defined")
3+
ifndef SERPAPI_KEY
4+
$(error "SERPAPI_KEY must be defined")
55
else
6-
$(info "found API_KEY variable")
6+
$(info "found SERPAPI_KEY variable")
77
endif
88

99
all: init clean build run

demo/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ plugins {
1414
id 'application'
1515
}
1616

17+
sourceCompatibility = 21
18+
targetCompatibility = 21
19+
1720
repositories {
1821
mavenCentral()
1922

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/serpapi/SerpApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* SerpApi wraps HTTP interaction with the service serpapi.com
1313
*/
14-
public class SerpApi extends Exception {
14+
public class SerpApi {
1515

1616
/**
1717
* client parameters

src/test/java/basic_search_result.json

Lines changed: 0 additions & 175 deletions
This file was deleted.

0 commit comments

Comments
 (0)