Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Address Maven optimization PR feedback
Make the toolchain XML generator consistently async, remove redundant Maven configuration await handling, and reuse the existing XML test helper.

Configure CodeQL to skip generated dist output so newly split vendored chunks do not report duplicate generated-code alerts.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b
  • Loading branch information
brunoborges committed Jul 30, 2026
commit 7eadc3b7558209465feef698f5641eb787ec1727
4 changes: 4 additions & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: setup-java CodeQL configuration

paths-ignore:
- dist/**
2 changes: 2 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ jobs:
security-events: write
name: CodeQL analysis
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main
with:
codeql-cfg-path: ./.github/codeql/codeql-config.yml
4 changes: 2 additions & 2 deletions __tests__/maven-xml-loading.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jest.unstable_mockModule('xmlbuilder2', () => {
const toolchains = await import('../src/toolchains.js');

describe('Maven XML loading', () => {
it('does not load xmlbuilder2 for new toolchains.xml generation', () => {
const xml = toolchains.generateToolchainDefinition(
it('does not load xmlbuilder2 for new toolchains.xml generation', async () => {
const xml = await toolchains.generateToolchainDefinition(
'',
'21',
'temurin',
Expand Down
18 changes: 4 additions & 14 deletions __tests__/toolchains.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('toolchains tests', () => {
)
);
expect(
toolchains.generateToolchainDefinition(
await toolchains.generateToolchainDefinition(
'',
jdkInfo.version,
jdkInfo.vendor,
Expand Down Expand Up @@ -889,7 +889,7 @@ describe('toolchains tests', () => {
expect(updated).toContain(`<jdkHome>${jdkInfo.jdkHome}</jdkHome>`);
}, 100000);

it('generates valid toolchains.xml with minimal configuration', () => {
it('generates valid toolchains.xml with minimal configuration', async () => {
const jdkInfo = {
version: 'JAVA_VERSION',
vendor: 'JAVA_VENDOR',
Expand All @@ -915,7 +915,7 @@ describe('toolchains tests', () => {
</toolchains>`;

expect(
toolchains.generateToolchainDefinition(
await toolchains.generateToolchainDefinition(
'',
jdkInfo.version,
jdkInfo.vendor,
Expand Down Expand Up @@ -960,16 +960,6 @@ describe('toolchains tests', () => {
return '';
});

function xmlElementText(xml: string, tagName: string): string {
const match = new RegExp(`<${tagName}>([\\s\\S]*?)</${tagName}>`).exec(
xml
);
expect(match).not.toBeNull();
return (
parseXml(`<value>${match?.[1]}</value>`).root().node.textContent ?? ''
);
}

await toolchains.configureToolchains(
version,
distributionName,
Expand All @@ -980,7 +970,7 @@ describe('toolchains tests', () => {
expect(fs.existsSync(m2Dir)).toBe(true);
expect(fs.existsSync(toolchainsFile)).toBe(true);
expect(fs.readFileSync(toolchainsFile, 'utf-8')).toEqual(
toolchains.generateToolchainDefinition(
await toolchains.generateToolchainDefinition(
'',
version,
distributionName,
Expand Down
2 changes: 1 addition & 1 deletion dist/setup/451.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async function createToolchainsSettings({ jdkInfo, settingsDirectory }) {
await writeToolchainsFileToDisk(settingsDirectory, updatedToolchains);
}
// only exported for testing purposes
function generateToolchainDefinition(original, version, vendor, id, jdkHome) {
async function generateToolchainDefinition(original, version, vendor, id, jdkHome) {
if (!original?.length) {
return generateNewToolchainDefinition(version, vendor, id, jdkHome);
}
Expand Down
10 changes: 0 additions & 10 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36241,16 +36241,6 @@ async function run() {
catch (error) {
actionError = error;
}
if (mavenConfiguration) {
try {
await mavenConfiguration;
}
catch (error) {
if (!actionError) {
actionError = error;
}
}
}
if (cacheRestore) {
try {
await cacheRestore;
Expand Down
10 changes: 0 additions & 10 deletions src/setup-java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,6 @@ export async function run() {
actionError = error as Error;
}

if (mavenConfiguration) {
try {
await mavenConfiguration;
} catch (error) {
if (!actionError) {
actionError = error as Error;
}
}
}

if (cacheRestore) {
try {
await cacheRestore;
Expand Down
2 changes: 1 addition & 1 deletion src/toolchains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function createToolchainsSettings({
}

// only exported for testing purposes
export function generateToolchainDefinition(
export async function generateToolchainDefinition(
original: string,
version: string,
vendor: string,
Expand Down
Loading