mirror of
https://github.com/actions/setup-java.git
synced 2025-04-20 01:46:46 +00:00
Add support for maven-compiler-plugin configuration (#1)
This commit is contained in:
parent
bc6665734d
commit
f5e27775fa
4 changed files with 178 additions and 12 deletions
48
dist/cleanup/index.js
vendored
48
dist/cleanup/index.js
vendored
|
@ -103834,16 +103834,21 @@ function parseJavaVersionFile(content) {
|
|||
return fileContent;
|
||||
}
|
||||
function parsePomXmlFile(xmlFileAsString) {
|
||||
const versionDefinitionTypes = [getByMavenCompilerSpecification, getBySpringBootSpecification];
|
||||
for (var definitionType of versionDefinitionTypes) {
|
||||
var version = definitionType(xmlbuilder2_1.create(xmlFileAsString));
|
||||
const xmlDoc = xmlbuilder2_1.create(xmlFileAsString);
|
||||
const versionDefinitionTypes = [
|
||||
getByMavenProperties,
|
||||
getBySpringBootSpecification,
|
||||
getByMavenCompilerPluginConfig
|
||||
];
|
||||
for (const definitionType of versionDefinitionTypes) {
|
||||
const version = definitionType(xmlDoc);
|
||||
if (version !== null) {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function getByMavenCompilerSpecification(xmlDoc) {
|
||||
function getByMavenProperties(xmlDoc) {
|
||||
const possibleTagsRegex = [
|
||||
'maven.compiler.source',
|
||||
'maven.compiler.release',
|
||||
|
@ -103869,6 +103874,41 @@ function getVersionByTagName(xmlDoc, tag) {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
function getByMavenCompilerPluginConfig(xmlDoc) {
|
||||
var _a;
|
||||
const source = xmlDoc.find(n => {
|
||||
// Find <source> node
|
||||
if (n.node.nodeName !== "source") {
|
||||
return false;
|
||||
}
|
||||
if (n.node.childNodes.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
// Must be within <configuration>
|
||||
if (n.up().node.nodeName !== "configuration") {
|
||||
return false;
|
||||
}
|
||||
// Which must be inside <plugin>
|
||||
if (n.up().up().node.nodeName !== "plugin") {
|
||||
return false;
|
||||
}
|
||||
// Make sure the plugin is maven-compiler-plugin
|
||||
const isCompilerPlugin = n.up().up().some(c => {
|
||||
if (c.node.nodeName !== "artifactId") {
|
||||
return false;
|
||||
}
|
||||
if (c.node.childNodes.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
return c.first().toString() === "maven-compiler-plugin";
|
||||
}, false, true);
|
||||
if (!isCompilerPlugin) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return (_a = source === null || source === void 0 ? void 0 : source.first().toString()) !== null && _a !== void 0 ? _a : null;
|
||||
}
|
||||
// By convention, action expects version 8 in the format `8.*` instead of `1.8`
|
||||
function avoidOldNotation(content) {
|
||||
return content.startsWith('1.') ? content.substring(2) : content;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue