Skip to content

Commit c1fb457

Browse files
committed
feat: move gradle wrapper from tools to platform root dir
1 parent 8f458b0 commit c1fb457

File tree

6 files changed

+12
-46
lines changed

6 files changed

+12
-46
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ example
3131
/test/.externalNativeBuild
3232
/test/androidx/cdv-gradle-config.json
3333
/test/androidx/tools
34+
/test/androidx/gradle
35+
/test/androidx/gradlew
36+
/test/androidx/gradlew.bat
3437
/test/assets/www/.tmp*
3538
/test/assets/www/cordova.js
3639
/test/bin
@@ -39,6 +42,7 @@ example
3942
/test/libs
4043
tmp/**
4144
tmp/**/*
45+
4246
!/spec/fixtures/org.test.plugins.dummyplugin/src/android/TestLib.jar
4347
# IntelliJ IDEA files
4448
**/.idea/**/*

lib/builders/ProjectBuilder.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class ProjectBuilder {
115115
}
116116

117117
getGradleWrapperPath () {
118-
let wrapper = path.join(this.root, 'tools', 'gradlew');
118+
let wrapper = path.join(this.root, 'gradlew');
119119

120120
if (isWindows()) {
121121
wrapper += '.bat';
@@ -132,9 +132,9 @@ class ProjectBuilder {
132132
async installGradleWrapper (gradleVersion) {
133133
if (process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL) {
134134
events.emit('verbose', `Overriding Gradle Version via CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL (${process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL})`);
135-
await execa('gradle', ['-p', path.join(this.root, 'tools'), 'wrapper', '--gradle-distribution-url', process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL], { stdio: 'inherit' });
135+
await execa('gradle', ['-p', path.join(this.root), 'wrapper', '--gradle-distribution-url', process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL], { stdio: 'inherit' });
136136
} else {
137-
await execa('gradle', ['-p', path.join(this.root, 'tools'), 'wrapper', '--gradle-version', gradleVersion], { stdio: 'inherit' });
137+
await execa('gradle', ['-p', path.join(this.root), 'wrapper', '--gradle-version', gradleVersion], { stdio: 'inherit' });
138138
}
139139
}
140140

lib/create.js

-8
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ function copyBuildRules (projectPath) {
120120
fs.cpSync(path.join(srcDir, 'app', 'build.gradle'), path.join(projectPath, 'app', 'build.gradle'));
121121
fs.cpSync(path.join(srcDir, 'app', 'repositories.gradle'), path.join(projectPath, 'app', 'repositories.gradle'));
122122
fs.cpSync(path.join(srcDir, 'repositories.gradle'), path.join(projectPath, 'repositories.gradle'));
123-
124-
copyGradleTools(projectPath);
125123
}
126124

127125
function copyScripts (projectPath) {
@@ -171,12 +169,6 @@ function validateProjectName (project_name) {
171169
return Promise.resolve();
172170
}
173171

174-
function copyGradleTools (projectPath) {
175-
const srcDir = path.join(ROOT, 'templates', 'project');
176-
177-
fs.cpSync(path.resolve(srcDir, 'tools'), path.resolve(projectPath, 'tools'), { recursive: true });
178-
}
179-
180172
/**
181173
* Creates an android application with the given options.
182174
*

spec/unit/builders/ProjectBuilder.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ describe('ProjectBuilder', () => {
136136

137137
it('should run gradle wrapper 8.7', async () => {
138138
await builder.installGradleWrapper('8.7');
139-
expect(execaSpy).toHaveBeenCalledWith('gradle', ['-p', path.normalize('/root/tools'), 'wrapper', '--gradle-version', '8.7'], jasmine.any(Object));
139+
expect(execaSpy).toHaveBeenCalledWith('gradle', ['-p', path.normalize('/root'), 'wrapper', '--gradle-version', '8.7'], jasmine.any(Object));
140140
});
141141

142142
it('CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL should override gradle version', async () => {
143143
process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL = 'https://dist.local';
144144
await builder.installGradleWrapper('8.7');
145145
delete process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL;
146-
expect(execaSpy).toHaveBeenCalledWith('gradle', ['-p', path.normalize('/root/tools'), 'wrapper', '--gradle-distribution-url', 'https://dist.local'], jasmine.any(Object));
146+
expect(execaSpy).toHaveBeenCalledWith('gradle', ['-p', path.normalize('/root'), 'wrapper', '--gradle-distribution-url', 'https://dist.local'], jasmine.any(Object));
147147
});
148148
});
149149

@@ -176,7 +176,7 @@ describe('ProjectBuilder', () => {
176176

177177
builder.build({});
178178

179-
let gradle = path.join(rootDir, 'tools', 'gradlew');
179+
let gradle = path.join(rootDir, 'gradlew');
180180
if (isWindows()) {
181181
gradle += '.bat';
182182
}
@@ -238,7 +238,7 @@ describe('ProjectBuilder', () => {
238238
const gradleArgs = ['test', 'args', '-f'];
239239
builder.getArgs.and.returnValue(gradleArgs);
240240

241-
let gradle = path.join(rootDir, 'tools', 'gradlew');
241+
let gradle = path.join(rootDir, 'gradlew');
242242
if (isWindows()) {
243243
gradle += '.bat';
244244
}

templates/project/tools/settings.gradle

-29
This file was deleted.

test/run_java_unit_tests.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AndroidTestRunner {
2828
constructor (testTitle, projectDir) {
2929
this.testTitle = testTitle;
3030
this.projectDir = projectDir;
31-
this.gradleWrapper = path.join(this.projectDir, 'tools/gradlew');
31+
this.gradleWrapper = path.join(this.projectDir, 'gradlew');
3232
}
3333

3434
_gradlew (...args) {
@@ -62,7 +62,6 @@ class AndroidTestRunner {
6262
.then(_ => {
6363
// TODO we should probably not only copy these files, but instead create a new project from scratch
6464
fs.copyFileSync(path.resolve(this.projectDir, '../../framework/cdv-gradle-config-defaults.json'), path.resolve(this.projectDir, 'cdv-gradle-config.json'));
65-
fs.cpSync(path.resolve(this.projectDir, '../../templates/project/tools'), path.resolve(this.projectDir, 'tools'), { recursive: true });
6665
fs.copyFileSync(
6766
path.join(__dirname, '../templates/project/assets/www/cordova.js'),
6867
path.join(this.projectDir, 'app/src/main/assets/www/cordova.js')

0 commit comments

Comments
 (0)