Skip to content

Commit b6df415

Browse files
committed
Add Android and Kotlin build script tests
This adds a single plain Gradle project that uses a modern Kotlin build script (i.e. settings.gradle.kts and no build.gradle.kts), plus basic Android samples exercising the possible permutations of: (old vs. new-style build script, Groovy vs. Kotlin build script, wrapper present vs. absent) Old vs. new style tests our recognition of different cues that this is likely a Droid project and requires `gradle assemble` not `gradle testClasses` (the example given at https://developer.android.com/studio/build/#top-level changed style as of plugin version ~7.3.0). Groovy vs. Kotlin build script language checks that the regexes recognising Android dependencies and versions work for both build script kinds. Wrapper present vs. absent exercises the autobuilder logic that guesses an appropriate Gradle version and sets it up in the event the Gradle wrapper isn't provided.
1 parent e664662 commit b6df415

File tree

101 files changed

+3143
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+3143
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
3+
/**
4+
* Use `apply false` in the top-level build.gradle file to add a Gradle
5+
* plugin as a build dependency but not apply it to the current (root)
6+
* project. Don't use `apply false` in sub-projects. For more information,
7+
* see Applying external plugins with same version to subprojects.
8+
*/
9+
10+
id("com.android.application") version "7.3.1" apply false
11+
id("com.android.library") version "7.3.1" apply false
12+
id("org.jetbrains.kotlin.android") version "1.7.20" apply false
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* The first line in the build configuration applies the Android Gradle plugin
3+
* to this build and makes the android block available to specify
4+
* Android-specific build options.
5+
*/
6+
7+
plugins {
8+
id("com.android.application")
9+
}
10+
11+
/**
12+
* The android block is where you configure all your Android-specific
13+
* build options.
14+
*/
15+
16+
android {
17+
18+
/**
19+
* The app's namespace. Used primarily to access app resources.
20+
*/
21+
22+
namespace = "com.github.androidsample"
23+
24+
/**
25+
* compileSdk specifies the Android API level Gradle should use to
26+
* compile your app. This means your app can use the API features included in
27+
* this API level and lower.
28+
*/
29+
30+
compileSdk = 33
31+
32+
/**
33+
* The defaultConfig block encapsulates default settings and entries for all
34+
* build variants and can override some attributes in main/AndroidManifest.xml
35+
* dynamically from the build system. You can configure product flavors to override
36+
* these values for different versions of your app.
37+
*/
38+
39+
defaultConfig {
40+
41+
// Uniquely identifies the package for publishing.
42+
applicationId = "com.github.androidsample"
43+
44+
// Defines the minimum API level required to run the app.
45+
minSdk = 21
46+
47+
// Specifies the API level used to test the app.
48+
targetSdk = 33
49+
50+
// Defines the version number of your app.
51+
versionCode = 1
52+
53+
// Defines a user-friendly version name for your app.
54+
versionName = "1.0"
55+
}
56+
57+
}
58+
59+
androidComponents {
60+
beforeVariants { variantBuilder ->
61+
if (variantBuilder.buildType == "debug") {
62+
variantBuilder.enable = false
63+
}
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.github.androidsample">
4+
<application android:label="AndroidSample">
5+
<activity android:name="Main" android:exported="true">
6+
<intent-filter>
7+
<action android:name="android.intent.action.MAIN" />
8+
<category android:name="android.intent.category.LAUNCHER" />
9+
</intent-filter>
10+
</activity>
11+
</application>
12+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.github.androidsample;
2+
3+
import android.app.Activity;
4+
import android.os.Bundle;
5+
6+
public class Main extends Activity
7+
{
8+
@Override
9+
public void onCreate(Bundle savedInstanceState) {
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
pluginManagement {
2+
3+
/**
4+
* The pluginManagement {repositories {...}} block configures the
5+
* repositories Gradle uses to search or download the Gradle plugins and
6+
* their transitive dependencies. Gradle pre-configures support for remote
7+
* repositories such as JCenter, Maven Central, and Ivy. You can also use
8+
* local repositories or define your own remote repositories. The code below
9+
* defines the Gradle Plugin Portal, Google's Maven repository,
10+
* and the Maven Central Repository as the repositories Gradle should use to look for its
11+
* dependencies.
12+
*/
13+
14+
repositories {
15+
gradlePluginPortal()
16+
google()
17+
mavenCentral()
18+
}
19+
}
20+
dependencyResolutionManagement {
21+
22+
/**
23+
* The dependencyResolutionManagement {repositories {...}}
24+
* block is where you configure the repositories and dependencies used by
25+
* all modules in your project, such as libraries that you are using to
26+
* create your application. However, you should configure module-specific
27+
* dependencies in each module-level build.gradle file. For new projects,
28+
* Android Studio includes Google's Maven repository and the Maven Central
29+
* Repository by default, but it does not configure any dependencies (unless
30+
* you select a template that requires some).
31+
*/
32+
33+
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
34+
repositories {
35+
google()
36+
mavenCentral()
37+
}
38+
}
39+
rootProject.name = "Android Sample"
40+
include(":project")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
xmlFiles
2+
| project/build/intermediates/incremental/lintVitalAnalyzeRelease/module.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalAnalyzeRelease/module.xml |
3+
| project/build/intermediates/incremental/lintVitalAnalyzeRelease/release-mainArtifact-dependencies.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalAnalyzeRelease/release-mainArtifact-dependencies.xml |
4+
| project/build/intermediates/incremental/lintVitalAnalyzeRelease/release-mainArtifact-libraries.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalAnalyzeRelease/release-mainArtifact-libraries.xml |
5+
| project/build/intermediates/incremental/lintVitalAnalyzeRelease/release.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalAnalyzeRelease/release.xml |
6+
| project/build/intermediates/incremental/lintVitalReportRelease/module.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalReportRelease/module.xml |
7+
| project/build/intermediates/incremental/lintVitalReportRelease/release-mainArtifact-dependencies.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalReportRelease/release-mainArtifact-dependencies.xml |
8+
| project/build/intermediates/incremental/lintVitalReportRelease/release-mainArtifact-libraries.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalReportRelease/release-mainArtifact-libraries.xml |
9+
| project/build/intermediates/incremental/lintVitalReportRelease/release.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalReportRelease/release.xml |
10+
| project/build/intermediates/incremental/mergeReleaseAssets/merger.xml:0:0:0:0 | project/build/intermediates/incremental/mergeReleaseAssets/merger.xml |
11+
| project/build/intermediates/incremental/mergeReleaseJniLibFolders/merger.xml:0:0:0:0 | project/build/intermediates/incremental/mergeReleaseJniLibFolders/merger.xml |
12+
| project/build/intermediates/incremental/mergeReleaseShaders/merger.xml:0:0:0:0 | project/build/intermediates/incremental/mergeReleaseShaders/merger.xml |
13+
| project/build/intermediates/incremental/release/mergeReleaseResources/merger.xml:0:0:0:0 | project/build/intermediates/incremental/release/mergeReleaseResources/merger.xml |
14+
| project/build/intermediates/merged_manifest/release/AndroidManifest.xml:0:0:0:0 | project/build/intermediates/merged_manifest/release/AndroidManifest.xml |
15+
| project/build/intermediates/merged_manifests/release/AndroidManifest.xml:0:0:0:0 | project/build/intermediates/merged_manifests/release/AndroidManifest.xml |
16+
| project/build/intermediates/packaged_manifests/release/AndroidManifest.xml:0:0:0:0 | project/build/intermediates/packaged_manifests/release/AndroidManifest.xml |
17+
| project/src/main/AndroidManifest.xml:0:0:0:0 | project/src/main/AndroidManifest.xml |
18+
#select
19+
| project/build/generated/source/buildConfig/release/com/github/androidsample/BuildConfig.java:0:0:0:0 | BuildConfig |
20+
| project/src/main/java/com/github/androidsample/Main.java:0:0:0:0 | Main |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import sys
2+
3+
from create_database_utils import *
4+
5+
run_codeql_database_create([], lang="java")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import java
2+
3+
from File f
4+
where f.isSourceFile()
5+
select f
6+
7+
query predicate xmlFiles(XmlFile x) { any() }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# These are explicitly windows files and should use crlf
5+
*.bat text eol=crlf
6+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
3+
/**
4+
* Use `apply false` in the top-level build.gradle file to add a Gradle
5+
* plugin as a build dependency but not apply it to the current (root)
6+
* project. Don't use `apply false` in sub-projects. For more information,
7+
* see Applying external plugins with same version to subprojects.
8+
*/
9+
10+
id("com.android.application") version "7.3.1" apply false
11+
id("com.android.library") version "7.3.1" apply false
12+
id("org.jetbrains.kotlin.android") version "1.7.20" apply false
13+
}

0 commit comments

Comments
 (0)