mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 09:02:50 +00:00
Build outputs
This commit is contained in:
parent
d4e24dfc10
commit
650620f9f9
4 changed files with 86 additions and 54 deletions
66
dist/main/index.js
vendored
66
dist/main/index.js
vendored
|
@ -138599,17 +138599,14 @@ const cache_extract_entries_1 = __nccwpck_require__(76161);
|
|||
const RESTORED_CACHE_KEY_KEY = 'restored-cache-key';
|
||||
exports.META_FILE_DIR = '.gradle-build-action';
|
||||
class GradleStateCache {
|
||||
constructor(gradleUserHome) {
|
||||
constructor(userHome, gradleUserHome) {
|
||||
this.userHome = userHome;
|
||||
this.gradleUserHome = gradleUserHome;
|
||||
this.cacheName = 'gradle';
|
||||
this.cacheDescription = 'Gradle User Home';
|
||||
}
|
||||
init() {
|
||||
const actionCacheDir = path_1.default.resolve(this.gradleUserHome, '.gradle-build-action');
|
||||
fs_1.default.mkdirSync(actionCacheDir, { recursive: true });
|
||||
const initScriptsDir = path_1.default.resolve(this.gradleUserHome, 'init.d');
|
||||
fs_1.default.mkdirSync(initScriptsDir, { recursive: true });
|
||||
this.initializeGradleUserHome(this.gradleUserHome, initScriptsDir);
|
||||
this.initializeGradleUserHome();
|
||||
const encryptionKey = params.getCacheEncryptionKey();
|
||||
if (encryptionKey) {
|
||||
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey);
|
||||
|
@ -138725,17 +138722,15 @@ class GradleStateCache {
|
|||
}
|
||||
return path_1.default.resolve(this.gradleUserHome, rawPath);
|
||||
}
|
||||
initializeGradleUserHome(gradleUserHome, initScriptsDir) {
|
||||
const gradleProperties = path_1.default.resolve(gradleUserHome, 'gradle.properties');
|
||||
const existingGradleProperties = fs_1.default.existsSync(gradleProperties)
|
||||
? fs_1.default.readFileSync(gradleProperties, 'utf8')
|
||||
: '';
|
||||
if (!existingGradleProperties.includes('org.gradle.java.installations.fromEnv=')) {
|
||||
fs_1.default.appendFileSync(gradleProperties, `
|
||||
# Auto-detect pre-installed JDKs
|
||||
org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME_17_X64
|
||||
`);
|
||||
initializeGradleUserHome() {
|
||||
const actionCacheDir = path_1.default.resolve(this.gradleUserHome, '.gradle-build-action');
|
||||
fs_1.default.mkdirSync(actionCacheDir, { recursive: true });
|
||||
this.copyInitScripts();
|
||||
this.registerToolchains();
|
||||
}
|
||||
copyInitScripts() {
|
||||
const initScriptsDir = path_1.default.resolve(this.gradleUserHome, 'init.d');
|
||||
fs_1.default.mkdirSync(initScriptsDir, { recursive: true });
|
||||
const initScriptFilenames = [
|
||||
'gradle-build-action.build-result-capture.init.gradle',
|
||||
'gradle-build-action.build-result-capture-service.plugin.groovy',
|
||||
|
@ -138744,13 +138739,30 @@ org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME
|
|||
'gradle-build-action.inject-gradle-enterprise.init.gradle'
|
||||
];
|
||||
for (const initScriptFilename of initScriptFilenames) {
|
||||
const initScriptContent = this.readInitScriptAsString(initScriptFilename);
|
||||
const initScriptContent = this.readResourceFileAsString('init-scripts', initScriptFilename);
|
||||
const initScriptPath = path_1.default.resolve(initScriptsDir, initScriptFilename);
|
||||
fs_1.default.writeFileSync(initScriptPath, initScriptContent);
|
||||
}
|
||||
}
|
||||
readInitScriptAsString(resource) {
|
||||
const absolutePath = path_1.default.resolve(__dirname, '..', '..', 'src', 'resources', 'init-scripts', resource);
|
||||
registerToolchains() {
|
||||
const preInstalledToolchains = this.readResourceFileAsString('toolchains.xml');
|
||||
const m2dir = path_1.default.resolve(this.userHome, '.m2');
|
||||
const toolchainXmlTarget = path_1.default.resolve(m2dir, 'toolchains.xml');
|
||||
if (!fs_1.default.existsSync(toolchainXmlTarget)) {
|
||||
fs_1.default.mkdirSync(m2dir, { recursive: true });
|
||||
fs_1.default.writeFileSync(toolchainXmlTarget, preInstalledToolchains);
|
||||
core.info(`Wrote default JDK locations to ${toolchainXmlTarget}`);
|
||||
}
|
||||
else {
|
||||
const existingToolchainContent = fs_1.default.readFileSync(toolchainXmlTarget, 'utf8');
|
||||
const appendedContent = preInstalledToolchains.split('<toolchains>').pop();
|
||||
const mergedContent = existingToolchainContent.replace('</toolchains>', appendedContent);
|
||||
fs_1.default.writeFileSync(toolchainXmlTarget, mergedContent);
|
||||
core.info(`Merged default JDK locations into ${toolchainXmlTarget}`);
|
||||
}
|
||||
}
|
||||
readResourceFileAsString(...paths) {
|
||||
const absolutePath = path_1.default.resolve(__dirname, '..', '..', 'src', 'resources', ...paths);
|
||||
return fs_1.default.readFileSync(absolutePath, 'utf8');
|
||||
}
|
||||
debugReportGradleUserHomeSize(label) {
|
||||
|
@ -139758,14 +139770,14 @@ const cache_utils_1 = __nccwpck_require__(41678);
|
|||
const cache_base_1 = __nccwpck_require__(47591);
|
||||
const cache_cleaner_1 = __nccwpck_require__(57);
|
||||
const CACHE_RESTORED_VAR = 'GRADLE_BUILD_ACTION_CACHE_RESTORED';
|
||||
function restore(gradleUserHome, cacheListener) {
|
||||
function restore(userHome, gradleUserHome, cacheListener) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (process.env[CACHE_RESTORED_VAR]) {
|
||||
core.info('Cache only restored on first action step.');
|
||||
return;
|
||||
}
|
||||
core.exportVariable(CACHE_RESTORED_VAR, true);
|
||||
const gradleStateCache = new cache_base_1.GradleStateCache(gradleUserHome);
|
||||
const gradleStateCache = new cache_base_1.GradleStateCache(userHome, gradleUserHome);
|
||||
if ((0, cache_utils_1.isCacheDisabled)()) {
|
||||
core.info('Cache is disabled: will not restore state from previous builds.');
|
||||
gradleStateCache.init();
|
||||
|
@ -139800,7 +139812,7 @@ function restore(gradleUserHome, cacheListener) {
|
|||
});
|
||||
}
|
||||
exports.restore = restore;
|
||||
function save(gradleUserHome, cacheListener, daemonController) {
|
||||
function save(userHome, gradleUserHome, cacheListener, daemonController) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if ((0, cache_utils_1.isCacheDisabled)()) {
|
||||
core.info('Cache is disabled: will not save state for later builds.');
|
||||
|
@ -139827,7 +139839,7 @@ function save(gradleUserHome, cacheListener, daemonController) {
|
|||
}
|
||||
}
|
||||
yield core.group('Caching Gradle state', () => __awaiter(this, void 0, void 0, function* () {
|
||||
return new cache_base_1.GradleStateCache(gradleUserHome).save(cacheListener);
|
||||
return new cache_base_1.GradleStateCache(userHome, gradleUserHome).save(cacheListener);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
@ -141052,10 +141064,12 @@ const build_results_1 = __nccwpck_require__(82107);
|
|||
const cache_reporting_1 = __nccwpck_require__(66674);
|
||||
const daemon_controller_1 = __nccwpck_require__(85146);
|
||||
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED';
|
||||
const USER_HOME = 'USER_HOME';
|
||||
const GRADLE_USER_HOME = 'GRADLE_USER_HOME';
|
||||
const CACHE_LISTENER = 'CACHE_LISTENER';
|
||||
function setup() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const userHome = yield determineUserHome();
|
||||
const gradleUserHome = yield determineGradleUserHome();
|
||||
if (process.env[GRADLE_SETUP_VAR]) {
|
||||
core.info('Gradle setup only performed on first gradle-build-action step in workflow.');
|
||||
|
@ -141063,9 +141077,10 @@ function setup() {
|
|||
}
|
||||
core.exportVariable(GRADLE_SETUP_VAR, true);
|
||||
core.saveState(GRADLE_SETUP_VAR, true);
|
||||
core.saveState(USER_HOME, userHome);
|
||||
core.saveState(GRADLE_USER_HOME, gradleUserHome);
|
||||
const cacheListener = new cache_reporting_1.CacheListener();
|
||||
yield caches.restore(gradleUserHome, cacheListener);
|
||||
yield caches.restore(userHome, gradleUserHome, cacheListener);
|
||||
core.saveState(CACHE_LISTENER, cacheListener.stringify());
|
||||
yield dependencyGraph.setup(params.getDependencyGraphOption());
|
||||
});
|
||||
|
@ -141079,10 +141094,11 @@ function complete() {
|
|||
}
|
||||
core.info('In post-action step');
|
||||
const buildResults = (0, build_results_1.loadBuildResults)();
|
||||
const userHome = core.getState(USER_HOME);
|
||||
const gradleUserHome = core.getState(GRADLE_USER_HOME);
|
||||
const cacheListener = cache_reporting_1.CacheListener.rehydrate(core.getState(CACHE_LISTENER));
|
||||
const daemonController = new daemon_controller_1.DaemonController(buildResults);
|
||||
yield caches.save(gradleUserHome, cacheListener, daemonController);
|
||||
yield caches.save(userHome, gradleUserHome, cacheListener, daemonController);
|
||||
yield jobSummary.generateJobSummary(buildResults, cacheListener);
|
||||
yield dependencyGraph.complete(params.getDependencyGraphOption());
|
||||
core.info('Completed post-action step');
|
||||
|
|
2
dist/main/index.js.map
vendored
2
dist/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
66
dist/post/index.js
vendored
66
dist/post/index.js
vendored
|
@ -136052,17 +136052,14 @@ const cache_extract_entries_1 = __nccwpck_require__(76161);
|
|||
const RESTORED_CACHE_KEY_KEY = 'restored-cache-key';
|
||||
exports.META_FILE_DIR = '.gradle-build-action';
|
||||
class GradleStateCache {
|
||||
constructor(gradleUserHome) {
|
||||
constructor(userHome, gradleUserHome) {
|
||||
this.userHome = userHome;
|
||||
this.gradleUserHome = gradleUserHome;
|
||||
this.cacheName = 'gradle';
|
||||
this.cacheDescription = 'Gradle User Home';
|
||||
}
|
||||
init() {
|
||||
const actionCacheDir = path_1.default.resolve(this.gradleUserHome, '.gradle-build-action');
|
||||
fs_1.default.mkdirSync(actionCacheDir, { recursive: true });
|
||||
const initScriptsDir = path_1.default.resolve(this.gradleUserHome, 'init.d');
|
||||
fs_1.default.mkdirSync(initScriptsDir, { recursive: true });
|
||||
this.initializeGradleUserHome(this.gradleUserHome, initScriptsDir);
|
||||
this.initializeGradleUserHome();
|
||||
const encryptionKey = params.getCacheEncryptionKey();
|
||||
if (encryptionKey) {
|
||||
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey);
|
||||
|
@ -136178,17 +136175,15 @@ class GradleStateCache {
|
|||
}
|
||||
return path_1.default.resolve(this.gradleUserHome, rawPath);
|
||||
}
|
||||
initializeGradleUserHome(gradleUserHome, initScriptsDir) {
|
||||
const gradleProperties = path_1.default.resolve(gradleUserHome, 'gradle.properties');
|
||||
const existingGradleProperties = fs_1.default.existsSync(gradleProperties)
|
||||
? fs_1.default.readFileSync(gradleProperties, 'utf8')
|
||||
: '';
|
||||
if (!existingGradleProperties.includes('org.gradle.java.installations.fromEnv=')) {
|
||||
fs_1.default.appendFileSync(gradleProperties, `
|
||||
# Auto-detect pre-installed JDKs
|
||||
org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME_17_X64
|
||||
`);
|
||||
initializeGradleUserHome() {
|
||||
const actionCacheDir = path_1.default.resolve(this.gradleUserHome, '.gradle-build-action');
|
||||
fs_1.default.mkdirSync(actionCacheDir, { recursive: true });
|
||||
this.copyInitScripts();
|
||||
this.registerToolchains();
|
||||
}
|
||||
copyInitScripts() {
|
||||
const initScriptsDir = path_1.default.resolve(this.gradleUserHome, 'init.d');
|
||||
fs_1.default.mkdirSync(initScriptsDir, { recursive: true });
|
||||
const initScriptFilenames = [
|
||||
'gradle-build-action.build-result-capture.init.gradle',
|
||||
'gradle-build-action.build-result-capture-service.plugin.groovy',
|
||||
|
@ -136197,13 +136192,30 @@ org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME
|
|||
'gradle-build-action.inject-gradle-enterprise.init.gradle'
|
||||
];
|
||||
for (const initScriptFilename of initScriptFilenames) {
|
||||
const initScriptContent = this.readInitScriptAsString(initScriptFilename);
|
||||
const initScriptContent = this.readResourceFileAsString('init-scripts', initScriptFilename);
|
||||
const initScriptPath = path_1.default.resolve(initScriptsDir, initScriptFilename);
|
||||
fs_1.default.writeFileSync(initScriptPath, initScriptContent);
|
||||
}
|
||||
}
|
||||
readInitScriptAsString(resource) {
|
||||
const absolutePath = path_1.default.resolve(__dirname, '..', '..', 'src', 'resources', 'init-scripts', resource);
|
||||
registerToolchains() {
|
||||
const preInstalledToolchains = this.readResourceFileAsString('toolchains.xml');
|
||||
const m2dir = path_1.default.resolve(this.userHome, '.m2');
|
||||
const toolchainXmlTarget = path_1.default.resolve(m2dir, 'toolchains.xml');
|
||||
if (!fs_1.default.existsSync(toolchainXmlTarget)) {
|
||||
fs_1.default.mkdirSync(m2dir, { recursive: true });
|
||||
fs_1.default.writeFileSync(toolchainXmlTarget, preInstalledToolchains);
|
||||
core.info(`Wrote default JDK locations to ${toolchainXmlTarget}`);
|
||||
}
|
||||
else {
|
||||
const existingToolchainContent = fs_1.default.readFileSync(toolchainXmlTarget, 'utf8');
|
||||
const appendedContent = preInstalledToolchains.split('<toolchains>').pop();
|
||||
const mergedContent = existingToolchainContent.replace('</toolchains>', appendedContent);
|
||||
fs_1.default.writeFileSync(toolchainXmlTarget, mergedContent);
|
||||
core.info(`Merged default JDK locations into ${toolchainXmlTarget}`);
|
||||
}
|
||||
}
|
||||
readResourceFileAsString(...paths) {
|
||||
const absolutePath = path_1.default.resolve(__dirname, '..', '..', 'src', 'resources', ...paths);
|
||||
return fs_1.default.readFileSync(absolutePath, 'utf8');
|
||||
}
|
||||
debugReportGradleUserHomeSize(label) {
|
||||
|
@ -137211,14 +137223,14 @@ const cache_utils_1 = __nccwpck_require__(41678);
|
|||
const cache_base_1 = __nccwpck_require__(47591);
|
||||
const cache_cleaner_1 = __nccwpck_require__(57);
|
||||
const CACHE_RESTORED_VAR = 'GRADLE_BUILD_ACTION_CACHE_RESTORED';
|
||||
function restore(gradleUserHome, cacheListener) {
|
||||
function restore(userHome, gradleUserHome, cacheListener) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (process.env[CACHE_RESTORED_VAR]) {
|
||||
core.info('Cache only restored on first action step.');
|
||||
return;
|
||||
}
|
||||
core.exportVariable(CACHE_RESTORED_VAR, true);
|
||||
const gradleStateCache = new cache_base_1.GradleStateCache(gradleUserHome);
|
||||
const gradleStateCache = new cache_base_1.GradleStateCache(userHome, gradleUserHome);
|
||||
if ((0, cache_utils_1.isCacheDisabled)()) {
|
||||
core.info('Cache is disabled: will not restore state from previous builds.');
|
||||
gradleStateCache.init();
|
||||
|
@ -137253,7 +137265,7 @@ function restore(gradleUserHome, cacheListener) {
|
|||
});
|
||||
}
|
||||
exports.restore = restore;
|
||||
function save(gradleUserHome, cacheListener, daemonController) {
|
||||
function save(userHome, gradleUserHome, cacheListener, daemonController) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if ((0, cache_utils_1.isCacheDisabled)()) {
|
||||
core.info('Cache is disabled: will not save state for later builds.');
|
||||
|
@ -137280,7 +137292,7 @@ function save(gradleUserHome, cacheListener, daemonController) {
|
|||
}
|
||||
}
|
||||
yield core.group('Caching Gradle state', () => __awaiter(this, void 0, void 0, function* () {
|
||||
return new cache_base_1.GradleStateCache(gradleUserHome).save(cacheListener);
|
||||
return new cache_base_1.GradleStateCache(userHome, gradleUserHome).save(cacheListener);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
@ -138137,10 +138149,12 @@ const build_results_1 = __nccwpck_require__(82107);
|
|||
const cache_reporting_1 = __nccwpck_require__(66674);
|
||||
const daemon_controller_1 = __nccwpck_require__(85146);
|
||||
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED';
|
||||
const USER_HOME = 'USER_HOME';
|
||||
const GRADLE_USER_HOME = 'GRADLE_USER_HOME';
|
||||
const CACHE_LISTENER = 'CACHE_LISTENER';
|
||||
function setup() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const userHome = yield determineUserHome();
|
||||
const gradleUserHome = yield determineGradleUserHome();
|
||||
if (process.env[GRADLE_SETUP_VAR]) {
|
||||
core.info('Gradle setup only performed on first gradle-build-action step in workflow.');
|
||||
|
@ -138148,9 +138162,10 @@ function setup() {
|
|||
}
|
||||
core.exportVariable(GRADLE_SETUP_VAR, true);
|
||||
core.saveState(GRADLE_SETUP_VAR, true);
|
||||
core.saveState(USER_HOME, userHome);
|
||||
core.saveState(GRADLE_USER_HOME, gradleUserHome);
|
||||
const cacheListener = new cache_reporting_1.CacheListener();
|
||||
yield caches.restore(gradleUserHome, cacheListener);
|
||||
yield caches.restore(userHome, gradleUserHome, cacheListener);
|
||||
core.saveState(CACHE_LISTENER, cacheListener.stringify());
|
||||
yield dependencyGraph.setup(params.getDependencyGraphOption());
|
||||
});
|
||||
|
@ -138164,10 +138179,11 @@ function complete() {
|
|||
}
|
||||
core.info('In post-action step');
|
||||
const buildResults = (0, build_results_1.loadBuildResults)();
|
||||
const userHome = core.getState(USER_HOME);
|
||||
const gradleUserHome = core.getState(GRADLE_USER_HOME);
|
||||
const cacheListener = cache_reporting_1.CacheListener.rehydrate(core.getState(CACHE_LISTENER));
|
||||
const daemonController = new daemon_controller_1.DaemonController(buildResults);
|
||||
yield caches.save(gradleUserHome, cacheListener, daemonController);
|
||||
yield caches.save(userHome, gradleUserHome, cacheListener, daemonController);
|
||||
yield jobSummary.generateJobSummary(buildResults, cacheListener);
|
||||
yield dependencyGraph.complete(params.getDependencyGraphOption());
|
||||
core.info('Completed post-action step');
|
||||
|
|
2
dist/post/index.js.map
vendored
2
dist/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue