Skip to content

Commit

Permalink
fix: move build gradle wrapper for Android Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu committed May 13, 2024
1 parent 59f7d0d commit 409fe93
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/builders/ProjectBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ProjectBuilder {
}

getGradleWrapperPath () {
let wrapper = path.join(this.root, 'tools', 'gradlew');
let wrapper = path.join(this.root, 'gradlew');

if (isWindows()) {
wrapper += '.bat';
Expand Down
47 changes: 47 additions & 0 deletions templates/project/tools/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

// Move the generated wrapper up one directory for Android Studio to work

task moveWrapperForAndroidStudio {
doLast {
def currentDir = projectDir
def parentDir = new File(currentDir.parent)

// Move gradle directory up
def gradleDir = new File(currentDir, 'gradle')
if (gradleDir.exists()) {
gradleDir.renameTo(new File(parentDir, 'gradle'))
}

// Move gradlew file up
def gradlewFile = new File(currentDir, 'gradlew')
if (gradlewFile.exists()) {
gradlewFile.renameTo(new File(parentDir, 'gradlew'))
}

// Move gradlew.bat file up
def gradlewBatFile = new File(currentDir, 'gradlew.bat')
if (gradlewBatFile.exists()) {
gradlewBatFile.renameTo(new File(parentDir, 'gradlew.bat'))
}
}
}

tasks.wrapper.finalizedBy(moveWrapperForAndroidStudio)

0 comments on commit 409fe93

Please sign in to comment.