Skip to content

Commit

Permalink
Merge pull request #923 from mhsmith/kts
Browse files Browse the repository at this point in the history
Support Kotlin build scripts (KTS)
  • Loading branch information
mhsmith committed Aug 8, 2023
2 parents d337641 + 87c8ade commit 6699367
Show file tree
Hide file tree
Showing 39 changed files with 1,699 additions and 1,490 deletions.
2 changes: 1 addition & 1 deletion product/.idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions product/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 40 additions & 2 deletions product/.idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions product/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion product/.idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions product/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions product/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ subprojects {

repositories {
mavenCentral()
google()
}

// Maven Central requires every JAR to come with javadoc and sources JARs.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.chaquo.python.internal;

import org.gradle.api.*;

/** Constants and utilities shared between multiple build scripts */
public class BuildCommon {

// The following properties file should be created manually, as described in
// product/README.md. It's also used in test_gradle_plugin.py.
public static String localProperty(Project project, String key, String defaultValue = null) {
def localProps = new Properties()
localProps.load(project.rootProject.file('local.properties').newDataInputStream())
def result = localProps.getProperty(key, defaultValue)
if (result == null) {
throw new GradleException("'$key' is missing from local.properties")
}
return result
}

public static String androidHome(Project project) {
def home = System.getenv("ANDROID_HOME")
if (home != null) {
return home
}

try {
return localProperty(project, "sdk.dir")
} catch (GradleException e) {
throw new GradleException(
"SDK location not found. Define location with sdk.dir in the " +
"local.properties file or with an ANDROID_HOME environment variable.")
}
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.chaquo.python.internal;

import java.io.*;
import java.util.*;


/** Constants and utilities shared between the Gradle plugin, the runtime, and their
* respective build scripts. */
public class Common {
// Minimum Android Gradle plugin version
public static final String MIN_AGP_VERSION = "7.0.0";

// This should match api_level in target/build-common.sh.
public static final int MIN_SDK_VERSION = 21;

Expand Down Expand Up @@ -74,4 +80,26 @@ public static String assetZip(String type, String abi) {
public static final String ASSET_BOOTSTRAP_NATIVE = "bootstrap-native";
public static final String ASSET_BUILD_JSON = "build.json";
public static final String ASSET_CACERT = "cacert.pem";

// The default PATH on Mac is /usr/bin:/bin:/usr/sbin:/sbin. However, apps can't
// install anything into these locations, so the python.org installers use
// /usr/local/bin instead. This directory may also appear to be on the default PATH,
// but this is because it's listed in /etc/paths, which only affects shells, not
// other apps like Android Studio, or its Gradle subprocesses.
public static String findOnPath(String basename) throws FileNotFoundException {
List<String> path = new ArrayList<>();
Collections.addAll(path, System.getenv("PATH").split(File.pathSeparator));
if (System.getProperty("os.name").toLowerCase().startsWith("mac")) {
path.add("/usr/local/bin");
}

for (String dir : path) {
File file = new File(dir, basename);
if (file.exists()) {
return file.toString();
}
}
throw new FileNotFoundException("Couldn't find '" + basename + "' on PATH");
}

}
2 changes: 1 addition & 1 deletion product/gradle-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ After stable release:
## Removing support for an Android Gradle plugin version

* Increment Chaquopy major version if not already done.
* Update MIN_ANDROID_PLUGIN_VER in PythonPlugin.
* Update MIN_AGP_VERSION in Common.java.
* Check if there's any version-dependent code in the plugin or the tests which can now
be removed.
* Integration tests:
Expand Down
144 changes: 0 additions & 144 deletions product/gradle-plugin/build.gradle

This file was deleted.

Loading

0 comments on commit 6699367

Please sign in to comment.