forked from loafle/openapi-generator-original
Minor change to Helidon version handling allowing snapshot versions (#19320)
* Minor change to Helidon version handling Signed-off-by: Tim Quinn <tim.quinn@oracle.com> * Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaHelidonCommonCodegen.java Co-authored-by: martin-mfg <2026226+martin-mfg@users.noreply.github.com> * Review comments: fix typo in comment --------- Signed-off-by: Tim Quinn <tim.quinn@oracle.com> Co-authored-by: martin-mfg <2026226+martin-mfg@users.noreply.github.com>
This commit is contained in:
parent
ad7acc30eb
commit
07baddfe12
@ -483,7 +483,7 @@ public abstract class JavaHelidonCommonCodegen extends AbstractJavaCodegen
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setHelidonVersion(String version) {
|
private void setHelidonVersion(String version) {
|
||||||
helidonVersion = VersionUtil.instance().chooseVersion(version);
|
helidonVersion = VersionUtil.instance().chooseVersionBestMatchOrSelf(version);
|
||||||
setParentVersion(helidonVersion);
|
setParentVersion(helidonVersion);
|
||||||
helidonMajorVersion = VersionUtil.majorVersion(helidonVersion);
|
helidonMajorVersion = VersionUtil.majorVersion(helidonVersion);
|
||||||
}
|
}
|
||||||
@ -769,6 +769,30 @@ public abstract class JavaHelidonCommonCodegen extends AbstractJavaCodegen
|
|||||||
return chooseVersion(requestedVersion, versions);
|
return chooseVersion(requestedVersion, versions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns either the best match version or, if there is none, the requested version itself to allow references to
|
||||||
|
* unpublished releases such as snapshots.
|
||||||
|
*
|
||||||
|
* @param requestedVersion version to search for
|
||||||
|
* @return either the best match or, if none, the requested version itself
|
||||||
|
*/
|
||||||
|
String chooseVersionBestMatchOrSelf(String requestedVersion) {
|
||||||
|
return chooseVersionBestMatchOrSelf(requestedVersion, versions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns either the best match version or, if there is none, the requested version itself to allow references to
|
||||||
|
* unpublished releases such as snapshots.
|
||||||
|
*
|
||||||
|
* @param requestedVersion version to search for
|
||||||
|
* @param candidateVersions releases to consider
|
||||||
|
* @return either the best match or, if none, the requested version itself
|
||||||
|
*/
|
||||||
|
String chooseVersionBestMatchOrSelf(String requestedVersion, List<String> candidateVersions) {
|
||||||
|
String bestMatch = chooseVersion(requestedVersion, candidateVersions);
|
||||||
|
return bestMatch != null ? bestMatch : requestedVersion;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the version that is the "closest" match to the requested version expression from among the provided
|
* Returns the version that is the "closest" match to the requested version expression from among the provided
|
||||||
* releases, where the expression expression is one of the following:
|
* releases, where the expression expression is one of the following:
|
||||||
|
@ -48,4 +48,10 @@ public class HelidonCommonCodegenTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test void checkUseOfUnpublishedRelease() {
|
||||||
|
assertThat(test.chooseVersionBestMatchOrSelf("4.0.11-SNAPSHOT",
|
||||||
|
List.of("4.0.10", "3.2.1", "3.2.0", "2.0.4", "1.2.3", "1.2.2", "1.1.0")))
|
||||||
|
.isEqualTo("4.0.11-SNAPSHOT");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user