Skip to content

Commit a92106d

Browse files
committed
#4 Support multi-project builds / internal refactoring
1 parent a92d3ec commit a92106d

File tree

9 files changed

+3031
-3420
lines changed

9 files changed

+3031
-3420
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ build.gradle.kts
66
gradlew
77
gradlew.bat
88
build
9-
gradle
9+
gradle
10+
.idea
11+
*.iml

args.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const argv = require('yargs')
2+
.option('resolution', {
3+
alias: 'r',
4+
describe: 'Controls the dependency resolution strategy.\nSupported options:\n* release: selects the latest release\n* milestone: select the latest version being either a milestone or a release (default)\n* integration: selects the latest revision of the dependency module (such as SNAPSHOT)',
5+
type: 'string',
6+
nargs: 1,
7+
demand: false
8+
})
9+
.option('semver', {
10+
alias: 's',
11+
describe: 'Which semantic version diffs to include (https://semver.org). Flag can be used multiple times.\nSupported options:\n* major: Include upgrades with a major version change\n* minor: Include upgrades with a minor version change\n* patch: Include upgrades with a patch version change',
12+
type: 'string',
13+
array: true,
14+
nargs: 1,
15+
demand: false
16+
})
17+
.option('external-file', {
18+
alias: 'e',
19+
describe: 'Points to a file where dependencies have been declared, e.g. gradle/dependencies.gradle. Option can be used multiple times.',
20+
type: 'array',
21+
nargs: 1,
22+
demand: false
23+
})
24+
.option('debug', {
25+
alias: 'd',
26+
describe: 'Prints debugging information, such as commands executed and current status.',
27+
type: 'boolean',
28+
demand: false,
29+
default: false
30+
})
31+
.option('no-color', {
32+
describe: 'Disables color output',
33+
nargs: 1,
34+
demand: false
35+
}).argv
36+
37+
module.exports = {
38+
argv
39+
}

buildFiles.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const {
2+
existsSync
3+
} = require('fs');
4+
const {
5+
subDirectories
6+
} = require('./io')
7+
const {
8+
join
9+
} = require('path')
10+
11+
function getBuildFiles(externalFiles) {
12+
let buildFiles = [];
13+
exports.buildFiles = buildFiles;
14+
if (externalFiles && externalFiles.length) {
15+
externalFiles.forEach(externalFile => {
16+
if (!existsSync(externalFile)) {
17+
console.log(`Unable to find ${externalFile} file.`.bgRed);
18+
return;
19+
} else {
20+
buildFiles.push(externalFile);
21+
}
22+
});
23+
}
24+
25+
const directoriesToCheck = ['./']
26+
directoriesToCheck.push(...subDirectories('./'))
27+
28+
directoriesToCheck.forEach(directory => {
29+
const groovyBuildFile = join(directory, 'build.gradle');
30+
const kotlinBuildFile = join(directory, 'build.gradle.kts');
31+
if (existsSync(groovyBuildFile)) {
32+
buildFiles.push(groovyBuildFile);
33+
} else if (existsSync(kotlinBuildFile)) {
34+
buildFiles.push(kotlinBuildFile);
35+
}
36+
})
37+
38+
return buildFiles
39+
}
40+
41+
42+
43+
module.exports = {
44+
getBuildFiles
45+
}

gradleCommand.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const {
2+
spawnSync
3+
} = require('child_process');
4+
5+
function determineGradleCommand() {
6+
let gradleCommand = null
7+
let gradleWrapper = false
8+
try {
9+
const isWindows = process.platform === 'win32'
10+
const gradleWrapperFile = isWindows ? 'gradlew.bat' : 'gradlew'
11+
if (existsSync(gradleWrapperFile)) {
12+
gradleCommand = (isWindows ? '' : './') + gradleWrapperFile
13+
gradleWrapper = true
14+
}
15+
} catch (err) {}
16+
17+
if (!gradleCommand) {
18+
const gradleVersion = spawnSync('gradle', ['--version'])
19+
if (gradleVersion.status === 0) {
20+
gradleCommand = 'gradle'
21+
}
22+
}
23+
24+
return {
25+
gradleCommand,
26+
gradleWrapper
27+
}
28+
}
29+
30+
module.exports = {
31+
determineGradleCommand
32+
}

0 commit comments

Comments
 (0)