mirror of
https://github.com/github/codeql.git
synced 2026-04-14 11:34:00 +02:00
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.
This commit is contained in:
committed by
Chris Smowton
parent
e664662df9
commit
b6df415fe8
@@ -0,0 +1,13 @@
|
||||
plugins {
|
||||
|
||||
/**
|
||||
* Use `apply false` in the top-level build.gradle file to add a Gradle
|
||||
* plugin as a build dependency but not apply it to the current (root)
|
||||
* project. Don't use `apply false` in sub-projects. For more information,
|
||||
* see Applying external plugins with same version to subprojects.
|
||||
*/
|
||||
|
||||
id 'com.android.application' version '7.3.1' apply false
|
||||
id 'com.android.library' version '7.3.1' apply false
|
||||
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* The first line in the build configuration applies the Android Gradle plugin
|
||||
* to this build and makes the android block available to specify
|
||||
* Android-specific build options.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
/**
|
||||
* The android block is where you configure all your Android-specific
|
||||
* build options.
|
||||
*/
|
||||
|
||||
android {
|
||||
|
||||
/**
|
||||
* The app's namespace. Used primarily to access app resources.
|
||||
*/
|
||||
|
||||
namespace 'com.github.androidsample'
|
||||
|
||||
/**
|
||||
* compileSdk specifies the Android API level Gradle should use to
|
||||
* compile your app. This means your app can use the API features included in
|
||||
* this API level and lower.
|
||||
*/
|
||||
|
||||
compileSdk 33
|
||||
|
||||
/**
|
||||
* The defaultConfig block encapsulates default settings and entries for all
|
||||
* build variants and can override some attributes in main/AndroidManifest.xml
|
||||
* dynamically from the build system. You can configure product flavors to override
|
||||
* these values for different versions of your app.
|
||||
*/
|
||||
|
||||
defaultConfig {
|
||||
|
||||
// Uniquely identifies the package for publishing.
|
||||
applicationId 'com.github.androidsample'
|
||||
|
||||
// Defines the minimum API level required to run the app.
|
||||
minSdk 21
|
||||
|
||||
// Specifies the API level used to test the app.
|
||||
targetSdk 33
|
||||
|
||||
// Defines the version number of your app.
|
||||
versionCode 1
|
||||
|
||||
// Defines a user-friendly version name for your app.
|
||||
versionName "1.0"
|
||||
}
|
||||
|
||||
variantFilter { variant -> if (variant.buildType.name == "debug") { setIgnore(true) } }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.github.androidsample">
|
||||
<application android:label="AndroidSample">
|
||||
<activity android:name="Main" android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.github.androidsample;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class Main extends Activity
|
||||
{
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
pluginManagement {
|
||||
|
||||
/**
|
||||
* The pluginManagement {repositories {...}} block configures the
|
||||
* repositories Gradle uses to search or download the Gradle plugins and
|
||||
* their transitive dependencies. Gradle pre-configures support for remote
|
||||
* repositories such as JCenter, Maven Central, and Ivy. You can also use
|
||||
* local repositories or define your own remote repositories. The code below
|
||||
* defines the Gradle Plugin Portal, Google's Maven repository,
|
||||
* and the Maven Central Repository as the repositories Gradle should use to look for its
|
||||
* dependencies.
|
||||
*/
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
|
||||
/**
|
||||
* The dependencyResolutionManagement {repositories {...}}
|
||||
* block is where you configure the repositories and dependencies used by
|
||||
* all modules in your project, such as libraries that you are using to
|
||||
* create your application. However, you should configure module-specific
|
||||
* dependencies in each module-level build.gradle file. For new projects,
|
||||
* Android Studio includes Google's Maven repository and the Maven Central
|
||||
* Repository by default, but it does not configure any dependencies (unless
|
||||
* you select a template that requires some).
|
||||
*/
|
||||
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
rootProject.name = "Android Sample"
|
||||
include ':project'
|
||||
@@ -0,0 +1,20 @@
|
||||
xmlFiles
|
||||
| project/build/intermediates/incremental/lintVitalAnalyzeRelease/module.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalAnalyzeRelease/module.xml |
|
||||
| project/build/intermediates/incremental/lintVitalAnalyzeRelease/release-mainArtifact-dependencies.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalAnalyzeRelease/release-mainArtifact-dependencies.xml |
|
||||
| project/build/intermediates/incremental/lintVitalAnalyzeRelease/release-mainArtifact-libraries.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalAnalyzeRelease/release-mainArtifact-libraries.xml |
|
||||
| project/build/intermediates/incremental/lintVitalAnalyzeRelease/release.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalAnalyzeRelease/release.xml |
|
||||
| project/build/intermediates/incremental/lintVitalReportRelease/module.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalReportRelease/module.xml |
|
||||
| project/build/intermediates/incremental/lintVitalReportRelease/release-mainArtifact-dependencies.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalReportRelease/release-mainArtifact-dependencies.xml |
|
||||
| project/build/intermediates/incremental/lintVitalReportRelease/release-mainArtifact-libraries.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalReportRelease/release-mainArtifact-libraries.xml |
|
||||
| project/build/intermediates/incremental/lintVitalReportRelease/release.xml:0:0:0:0 | project/build/intermediates/incremental/lintVitalReportRelease/release.xml |
|
||||
| project/build/intermediates/incremental/mergeReleaseAssets/merger.xml:0:0:0:0 | project/build/intermediates/incremental/mergeReleaseAssets/merger.xml |
|
||||
| project/build/intermediates/incremental/mergeReleaseJniLibFolders/merger.xml:0:0:0:0 | project/build/intermediates/incremental/mergeReleaseJniLibFolders/merger.xml |
|
||||
| project/build/intermediates/incremental/mergeReleaseShaders/merger.xml:0:0:0:0 | project/build/intermediates/incremental/mergeReleaseShaders/merger.xml |
|
||||
| project/build/intermediates/incremental/release/mergeReleaseResources/merger.xml:0:0:0:0 | project/build/intermediates/incremental/release/mergeReleaseResources/merger.xml |
|
||||
| project/build/intermediates/merged_manifest/release/AndroidManifest.xml:0:0:0:0 | project/build/intermediates/merged_manifest/release/AndroidManifest.xml |
|
||||
| project/build/intermediates/merged_manifests/release/AndroidManifest.xml:0:0:0:0 | project/build/intermediates/merged_manifests/release/AndroidManifest.xml |
|
||||
| project/build/intermediates/packaged_manifests/release/AndroidManifest.xml:0:0:0:0 | project/build/intermediates/packaged_manifests/release/AndroidManifest.xml |
|
||||
| project/src/main/AndroidManifest.xml:0:0:0:0 | project/src/main/AndroidManifest.xml |
|
||||
#select
|
||||
| project/build/generated/source/buildConfig/release/com/github/androidsample/BuildConfig.java:0:0:0:0 | BuildConfig |
|
||||
| project/src/main/java/com/github/androidsample/Main.java:0:0:0:0 | Main |
|
||||
@@ -0,0 +1,5 @@
|
||||
import sys
|
||||
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create([], lang="java")
|
||||
@@ -0,0 +1,7 @@
|
||||
import java
|
||||
|
||||
from File f
|
||||
where f.isSourceFile()
|
||||
select f
|
||||
|
||||
query predicate xmlFiles(XmlFile x) { any() }
|
||||
Reference in New Issue
Block a user