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 changes to support jdk11+ #10717

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

Large diffs are not rendered by default.

Expand Up @@ -19,13 +19,28 @@
import java.util.function.Function;

/**
* Defines a rule to be evaluated against some target object.
* Defines a rule to be evaluated against a target object.
*/
@SuppressWarnings("WeakerAccess")
public class ValidationRule {

/**
* Level of severity which this rule considers a failure in evaluation. For example, if this is {@link Severity#WARNING} and
* a call to {@link ValidationRule#evaluate(Object)} returns <code>false</code>, a user should not expect an error to be thrown under
* normal operation.
*/
private Severity severity;

/**
* Description to help differentiate this rule from others (not intended to be user-facing).
*/
private String description;

/**
* Gets the message to be displayed in the event of a test failure (intended to be user-facing).
*/
private String failureMessage;

private Function<Object, Result> test;

/**
Expand All @@ -44,11 +59,6 @@ public class ValidationRule {
this.test = test;
}

/**
* Gets the message to be displayed in the event of a test failure (intended to be user-facing).
*
* @return A string message
*/
public String getFailureMessage() {
return failureMessage;
}
Expand All @@ -65,21 +75,12 @@ public Result evaluate(Object input) {
}

/**
* Get the level of severity which this rule considers a failure in evaluation. For example, if this is {@link Severity#WARNING} and
* a call to {@link ValidationRule#evaluate(Object)} returns <code>false</code>, a user should not expect an error to be thrown under
* normal operation.
*
* @return An enum defining how severe a failure to evaluate this rule should be considered by the caller.
*/
public Severity getSeverity() {
return severity;
}

/**
* Gets a description to help differentiate this rule from others (not intended to be user-facing).
*
* @return A string description.
*/
public String getDescription() {
return description;
}
Expand Down Expand Up @@ -192,7 +193,9 @@ public boolean passed() {
}

public static final class Fail extends Result {
public static Result empty() { return new Fail(); }
public static Result empty() {
return new Fail();
}

public Fail() {
super();
Expand Down
57 changes: 25 additions & 32 deletions modules/openapi-generator-gradle-plugin/build.gradle
@@ -1,8 +1,10 @@
buildscript {
ext.kotlin_version = '1.3.30'
ext.kotlin_version = '1.5.21'
repositories {
mavenLocal()
maven { url "https://repo1.maven.org/maven2" }
maven {
url "https://repo1.maven.org/maven2"
}
maven {
url "https://plugins.gradle.org/m2/"
}
Expand All @@ -15,10 +17,9 @@ buildscript {
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "gradle.plugin.org.gradle.kotlin:gradle-kotlin-dsl-plugins:1.1.3"
classpath "com.gradle.publish:plugin-publish-plugin:0.11.0"
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.20.0"
classpath "de.marcphilipp.gradle:nexus-publish-plugin:0.2.0"
classpath "org.gradle.kotlin:gradle-kotlin-dsl-plugins:2.1.6"
classpath "com.gradle.publish:plugin-publish-plugin:0.16.0"
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
}
}

Expand All @@ -37,9 +38,9 @@ apply plugin: 'com.gradle.plugin-publish'
apply plugin: 'java-gradle-plugin'
apply plugin: 'signing'
apply plugin: 'kotlin'
apply plugin: 'maven-publish'
apply plugin: "org.gradle.kotlin.kotlin-dsl"
apply plugin: 'io.codearte.nexus-staging'
apply plugin: "de.marcphilipp.nexus-publish"
apply plugin: "io.github.gradle-nexus.publish-plugin"

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand All @@ -57,15 +58,14 @@ repositories {
}

dependencies {
compile gradleApi()
implementation gradleApi()
// Shared OpenAPI Generator version be passed via command line arg as -PopenApiGeneratorVersion=VERSION
compile "org.openapitools:openapi-generator:$openApiGeneratorVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

testCompile 'org.testng:testng:6.9.6',
"org.jetbrains.kotlin:kotlin-test:$kotlin_version"
implementation "org.openapitools:openapi-generator:$openApiGeneratorVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

testCompile "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"
testImplementation 'org.testng:testng:6.9.6'
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testImplementation "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"
}

test {
Expand Down Expand Up @@ -144,14 +144,16 @@ publishing {
}
}

nexusStaging {
username = project.properties["ossrhUsername"]
password = project.properties["ossrhPassword"]
}

nexusPublishing {
// To retrieve: ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="$SIGNING_SECRET" getStagingProfile --no-daemon
stagingProfileId = "456297f829bbbe"
// packageGroup = "com.example.mycompany.myproject" //defaults to 'project.group'
repositories {
sonatype {
username = project.properties["ossrhUsername"]
password = project.properties["ossrhPassword"]
// To retrieve: ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="$SIGNING_SECRET" getStagingProfile --no-daemon
stagingProfileId = "456297f829bbbe" //can reduce execution time by even 10 seconds
}
}
}

gradlePlugin {
Expand Down Expand Up @@ -208,13 +210,4 @@ javadoc {
}
}

tasks {
closeRepository {
onlyIf { nexusPublishing.useStaging.get() }
}
releaseRepository{
onlyIf { nexusPublishing.useStaging.get() }
}
}

publishToNexus.dependsOn 'check'
publish.dependsOn 'check'
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
24 changes: 15 additions & 9 deletions modules/openapi-generator-gradle-plugin/pom.xml
Expand Up @@ -17,7 +17,8 @@

<properties>
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
<gradleVersion>5.6.4</gradleVersion>
<gradleVersion>7.2</gradleVersion>
<gradle-tooling.version>7.3-20210825160000+0000</gradle-tooling.version>
</properties>

<pluginRepositories>
Expand Down Expand Up @@ -77,15 +78,27 @@
<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>
<arg>-P openApiGeneratorVersion=${project.version}</arg>
</args>
</configuration>

<executions>
<execution>
<phase>install</phase>
<phase>compile</phase>
<goals>
<!-- goal must be "invoke" -->
<goal>invoke</goal>
Expand All @@ -102,13 +115,6 @@
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.gradle</groupId>
<artifactId>gradle-tooling-api</artifactId>
<version>5.6.4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Expand Down
1 change: 0 additions & 1 deletion modules/openapi-generator-gradle-plugin/settings.gradle
@@ -1,3 +1,2 @@
rootProject.name = 'openapi-generator-gradle-plugin'
enableFeaturePreview('STABLE_PUBLISHING')

4 changes: 0 additions & 4 deletions modules/openapi-generator/pom.xml
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
Expand Up @@ -15,6 +15,7 @@
import org.openapitools.codegen.config.GlobalSettings;
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 @@ -104,7 +105,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 @@ -169,7 +170,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 @@ -200,7 +201,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 @@ -231,7 +232,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 @@ -276,11 +277,12 @@ public void dryRunWithSupportFilesSelections() throws IOException {
TestUtils.ensureContainsFile(files, output, ".openapi-generator/VERSION");
} finally {
GlobalSettings.reset();
output.delete();
output.deleteOnExit();
}
}

@Test
@Ignore("https://github.com/jknack/handlebars.java/issues/917")
public void supportCustomTemplateEngine() throws IOException {
Path target = Files.createTempDirectory("test");
File templateDir = new File(target.toFile(), "template");
Expand Down Expand Up @@ -333,7 +335,7 @@ public void supportCustomTemplateEngine() throws IOException {
"testCase,httpStatusCode,someObj",
"Success,200,0");
} finally {
output.delete();
output.deleteOnExit();
}
}

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

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

Expand Down Expand Up @@ -581,8 +583,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 @@ -632,8 +634,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 @@ -740,8 +742,8 @@ public void testProcessUserDefinedTemplatesWithConfig() throws IOException {
"from io.something import rest"
);
} finally {
output.delete();
templates.toFile().delete();
output.deleteOnExit();
templates.toFile().deleteOnExit();
}
}
}