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

Update to JDK11 #15553

Merged
merged 26 commits into from
May 21, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ commands: # a reusable command with parameters
# 'See docs on artifact collection here https://circleci.com/docs/2.0/artifacts/'
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
# This is based on your 1.0 configuration file or project settings
#- run:
# command: sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java; sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac; echo -e "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" >> $BASH_ENV
- run:
command: sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java; sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac; echo -e "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" >> $BASH_ENV
command: java -version
- run:
command: 'sudo docker info >/dev/null 2>&1 || sudo service docker start; '
- run:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/check-supported-versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [8, 11]
java: [11, 17]
os: [ubuntu-latest]
include:
- java: 8
- java: 11
os: windows-latest
- java: 17
os: ubuntu-latest
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:

- name: Upload Maven build artifact
uses: actions/upload-artifact@v3
if: matrix.java == '8' && matrix.os == 'ubuntu-latest'
if: matrix.java == '11' && matrix.os == 'ubuntu-latest'
with:
name: artifact
path: modules/openapi-generator-cli/target/openapi-generator-cli.jar
Expand All @@ -63,7 +63,7 @@ jobs:
run: gradle -b modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle buildGoSdk --stacktrace

- name: Test Maven plugin integration
if: matrix.java == '8'
if: matrix.java == '11'
shell: bash
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/openapi-generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 8
java-version: 11
distribution: 'temurin'
- name: Cache maven dependencies
uses: actions/cache@v3
Expand Down Expand Up @@ -54,10 +54,10 @@ jobs:
- build
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 8
java-version: 11
distribution: 'temurin'
- name: Cache maven dependencies
uses: actions/cache@v3
Expand Down Expand Up @@ -91,10 +91,10 @@ jobs:
- build
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 8
java-version: 11
distribution: 'temurin'
- name: Download openapi-generator-cli.jar artifact
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -130,10 +130,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 8
java-version: 11
distribution: 'temurin'
- name: Download openapi-generator-cli.jar artifact
uses: actions/download-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: required
language: java
jdk:
- openjdk8
- openjdk11

# See https://docs.travis-ci.com/user/languages/java/#caching
before_cache:
Expand Down Expand Up @@ -151,7 +151,7 @@ script:
# run integration tests defined in maven pom.xml
# WARN: Travis will timeout after 10 minutes of no stdout/stderr activity, which is problematic with mvn --quiet.
# show "error" only to reduce the log size
- mvn -e --no-snapshot-updates --quiet --batch-mode --show-version clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error 2>&1 | grep -i error
- mvn -e --no-snapshot-updates --quiet --batch-mode --show-version clean install -DskipTests -Dmaven.javadoc.skip=true -Dorg.slf4j.simpleLogger.defaultLogLevel=error 2>&1 | grep -i error
#- mvn -e --no-snapshot-updates --quiet --batch-mode --show-version verify -Psamples -Dorg.slf4j.simpleLogger.defaultLogLevel=error
after_success:
# push to maven repo
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ build_script:
#- nuget restore samples\client\petstore\csharp\OpenAPIClientNetStandard\Org.OpenAPITools.sln
#- msbuild samples\client\petstore\csharp\OpenAPIClientNetStandard\Org.OpenAPITools.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
# install openapi-generator locally
- mvn --no-snapshot-updates --quiet clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
- mvn --no-snapshot-updates --quiet clean install -DskipTests -Dmaven.javadoc.skip=true -Dorg.slf4j.simpleLogger.defaultLogLevel=error
# run the locally installed openapi-generator-gradle-plugin
- gradle -b modules\openapi-generator-gradle-plugin\samples\local-spec\build.gradle buildGoSdk --stacktrace
test_script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ public Builder withHttpUserAgent(String httpUserAgent) {
public GeneratorSettings build() {
GeneratorSettings instance = new GeneratorSettings(this);
//noinspection PlaceholderCountMatchesArgumentCount
LOGGER.debug("GeneratorSettings#build: %s", instance.toString());
LOGGER.debug("GeneratorSettings#build: {}", instance);
return instance;
}
}
Expand Down
4 changes: 2 additions & 2 deletions modules/openapi-generator-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ specifications as part of your build. Other tasks are available as command line
java {
withSourcesJar()
withJavadocJar()
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 1.11
targetCompatibility = 1.11
}

repositories {
Expand Down
21 changes: 13 additions & 8 deletions modules/openapi-generator-gradle-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<properties>
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
<gradleVersion>7.6</gradleVersion>
<gradle-tooling.version>7.3-20210825160000+0000</gradle-tooling.version>
</properties>

<pluginRepositories>
Expand Down Expand Up @@ -77,6 +78,17 @@
<groupId>org.fortasoft</groupId>
<artifactId>gradle-maven-plugin</artifactId>
<version>1.0.8</version>

<!-- The plugin is no longer supported, so dependency has to be overridden -->
<!-- https://github.com/LendingClub/gradle-maven-plugin/issues/39 -->
<dependencies>
<dependency>
<groupId>org.gradle</groupId>
<artifactId>gradle-tooling-api</artifactId>
<version>${gradle-tooling.version}</version>
</dependency>
</dependencies>

<configuration>
<gradleVersion>${gradleVersion}</gradleVersion>
<args>
Expand All @@ -85,7 +97,7 @@
</configuration>
<executions>
<execution>
<phase>install</phase>
<phase>compile</phase>
<goals>
<!-- goal must be "invoke" -->
<goal>invoke</goal>
Expand All @@ -100,13 +112,6 @@
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.gradle</groupId>
<artifactId>gradle-tooling-api</artifactId>
<version>${gradleVersion}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Expand Down
4 changes: 0 additions & 4 deletions modules/openapi-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@
<version>${maven-javadoc-plugin.version}</version>
<configuration>
<debug>true</debug>
<links>
<link>http://java.sun.com/javaee/5/docs/api</link>
<link>http://java.sun.com/j2se/1.5.0/docs/api</link>
</links>
<excludePackageNames/>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.openapitools.codegen;

import com.sun.org.apache.xerces.internal.impl.dv.xs.AbstractDateTimeDV;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.callbacks.Callback;
import io.swagger.v3.oas.models.media.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.lang.reflect.AccessibleObject;
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
final Logger LOGGER = LoggerFactory.getLogger(HandlebarsEngineAdapter.class);
Expand Down Expand Up @@ -68,12 +71,35 @@ public TemplateSource sourceAt(String location) {
}
};

// $ref: https://github.com/jknack/handlebars.java/issues/917
var MY_FIELD_VALUE_RESOLVER = new FieldValueResolver() {
@Override
protected Set<FieldWrapper> members(
Class<?> clazz) {
var members = super.members(clazz);
return members.stream()
.filter(fw -> isValidField(fw))
.collect(Collectors.toSet());
}

boolean isValidField(
FieldWrapper fw) {
if (fw instanceof AccessibleObject) {
if (isUseSetAccessible(fw)) {
return true;
}
return false;
}
return true;
}
};

Context context = Context
.newBuilder(bundle)
.resolver(
MapValueResolver.INSTANCE,
JavaBeanValueResolver.INSTANCE,
FieldValueResolver.INSTANCE,
MY_FIELD_VALUE_RESOLVER.INSTANCE,
MethodValueResolver.INSTANCE)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1322,12 +1322,6 @@ protected Object clone() throws CloneNotSupportedException {
return super.clone();
}

@Override
protected void finalize() throws Throwable {
// TODO Auto-generated method stub
super.finalize();
}

@Override
public Number getNumber(JsonPointer ptr) {
return root == null ? null : root.at(ptr).numberValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.utils.ModelUtils;
import org.testng.Assert;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

import java.io.File;
Expand Down Expand Up @@ -111,7 +112,7 @@ public void testIgnoreFileProcessing() throws IOException {
TestUtils.ensureDoesNotContainsFile(files, output, "src/main/java/org/openapitools/client/api/UserApi.java");
Assert.assertFalse(new File(output, "src/main/java/org/openapitools/client/api/UserApi.java").exists());
} finally {
output.delete();
output.deleteOnExit();
}
}

Expand Down Expand Up @@ -176,7 +177,7 @@ public void testFilesAreNeverOverwritten() throws IOException {
String modelTestContents = Files.readAllLines(modelTestFile.toPath()).get(0);
Assert.assertEquals(modelTestContents, "empty", "Expected test file to retain original contents.");
} finally {
output.delete();
output.deleteOnExit();
}
}

Expand Down Expand Up @@ -207,7 +208,7 @@ public void dryRunWithApisOnly() throws IOException {
Assert.assertEquals(files.size(), 1);
TestUtils.ensureContainsFile(files, output, "src/main/java/org/openapitools/client/api/PingApi.java");
} finally {
output.delete();
output.deleteOnExit();
}
}

Expand Down Expand Up @@ -238,7 +239,7 @@ public void dryRunWithModelsOnly() throws IOException {
Assert.assertEquals(files.size(), 1);
TestUtils.ensureContainsFile(files, output, "src/main/java/org/openapitools/client/model/SomeObj.java");
} finally {
output.delete();
output.deleteOnExit();
}
}

Expand Down Expand Up @@ -283,7 +284,7 @@ public void dryRunWithSupportFilesSelections() throws IOException {
TestUtils.ensureContainsFile(files, output, ".openapi-generator/VERSION");
} finally {
GlobalSettings.reset();
output.delete();
output.deleteOnExit();
}
}

Expand Down Expand Up @@ -340,7 +341,7 @@ public void supportCustomTemplateEngine() throws IOException {
"testCase,httpStatusCode,someObj",
"Success,200,0");
} finally {
output.delete();
output.deleteOnExit();
}
}

Expand Down Expand Up @@ -480,7 +481,7 @@ public void testBuiltinLibraryTemplates() throws IOException {
"open class ClientException",
"open class ServerException");
} finally {
output.delete();
output.deleteOnExit();
}
}

Expand Down Expand Up @@ -523,7 +524,7 @@ public void testBuiltinNonLibraryTemplates() throws IOException {
"## Build",
"## Features/Implementation Notes");
} finally {
output.delete();
output.deleteOnExit();
}
}

Expand Down Expand Up @@ -588,8 +589,8 @@ public void testCustomLibraryTemplates() throws IOException {
"open class CustomException(",
"private const val serialVersionUID: Long = 789L");
} finally {
output.delete();
templates.toFile().delete();
output.deleteOnExit();
templates.toFile().deleteOnExit();
}
}

Expand Down Expand Up @@ -639,8 +640,8 @@ public void testCustomNonLibraryTemplates() throws IOException {
// README.md should contain our custom templated text
TestUtils.assertFileContains(readme.toPath(), "# testCustomNonLibraryTemplates");
} finally {
output.delete();
templates.toFile().delete();
output.deleteOnExit();
templates.toFile().deleteOnExit();
}
}

Expand Down Expand Up @@ -747,8 +748,8 @@ public void testProcessUserDefinedTemplatesWithConfig() throws IOException {
"from io.something import rest"
);
} finally {
output.delete();
templates.toFile().delete();
output.deleteOnExit();
templates.toFile().deleteOnExit();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void testCodeGenWithAllOf() throws IOException {

assertFileEquals(path, Paths.get("src/test/resources/3_0/protobuf-schema/pet.proto"));

output.delete();
output.deleteOnExit();
}

private void assertFileEquals(Path generatedFilePath, Path expectedFilePath) throws IOException {
Expand Down
Loading