Skip to content

Commit

Permalink
Android plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohannes committed Dec 4, 2023
1 parent 9a033b1 commit 5e88df1
Show file tree
Hide file tree
Showing 24 changed files with 157 additions and 200 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.gradle
.idea
build
local.properties
19 changes: 4 additions & 15 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
plugins {
id("org.example.application")
}

application {
mainClass.set("org.example.product.app.Application")
id("org.example.android-application")
}

dependencies {
providedCompile("jakarta.servlet:jakarta.servlet-api")

implementation(project(":bespin"))
implementation(project(":corellia"))
implementation(project(":kamino"))
implementation(project(":kashyyyk"))
implementation(project(":naboo"))
implementation(project(":tatooine"))
implementation("androidx.appcompat:appcompat")
implementation("com.google.android.material:material")
implementation("com.google.inject.extensions:guice-servlet")
implementation("com.google.inject:guice")
implementation("org.slf4j:slf4j-api")

mockApiImplementation(project(path))
mockApiImplementation("com.google.guava:guava")

testImplementation("org.junit.jupiter:junit-jupiter-api")

endToEndTestImplementation(project(path)) { capabilities { requireCapabilities("${project.group}:${project.name}-mock-api") } }
endToEndTestImplementation("com.google.guava:guava")
endToEndTestImplementation("org.junit.jupiter:junit-jupiter-api")

runtimeOnly("org.slf4j:slf4j-simple")
androidTestImplementation("androidx.test.ext:junit")
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ org.gradle.configuration-cache=true

# activate Gradle build cache - switch between branches/commits without rebuilding every time
org.gradle.caching=true

android.useAndroidX=true
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pluginManagement {
// Get community plugins from the Gradle Plugin Portal
repositories.gradlePluginPortal()
// And Android plugins from Google
repositories.google()

// Get our own convention plugins from 'gradle/plugins'
if (File(rootDir, "gradle/plugins").exists()) {
Expand All @@ -15,6 +17,8 @@ pluginManagement {
dependencyResolutionManagement {
// Get components from Maven Central
repositories.mavenCentral()
// And Android components from Google
repositories.google()
// In the main build, find the platform in 'gradle/platform'
if (File(rootDir, "gradle/platform").exists()) {
includeBuild("gradle/platform")
Expand Down
7 changes: 7 additions & 0 deletions gradle/platform/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ dependencies {
}

dependencies.constraints {
api("androidx.appcompat:appcompat:1.4.1")
api("androidx.constraintlayout:constraintlayout:2.1.2")
api("androidx.navigation:navigation-fragment:2.3.5")
api("androidx.navigation:navigation-ui:2.3.5")
api("androidx.test.espresso:espresso-core:3.4.0")
api("androidx.test.ext:junit:1.1.3")
api("com.github.racc:typesafeconfig-guice:0.1.0")
api("com.google.android.material:material:1.6.0")
api("com.sun.activation:jakarta.activation:1.2.2") { version { reject("[2.0.0,)") } } // Upgrade to 2.x requires newer Jakarta APIs
api("com.sun.mail:jakarta.mail:1.6.7") { version { reject("[2.0.0,)") } } // Upgrade to 2.x requires newer Jakarta APIs
api("jakarta.inject:jakarta.inject-api:1.0.5") { version { reject("[2.0.0,)") } } // Upgrade to 2.x requires newer Jakarta APIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies {
implementation(platform(project(":plugins-platform")))

implementation(project(":java-base-plugins"))
implementation("org.example:build-parameters-plugins")
implementation("com.android.tools.build:gradle")
implementation("org.owasp:dependency-check-gradle")
implementation("io.fuchs.gradle.classpath-collision-detector:classpath-collision-detector")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
plugins {
id("org.example.base")
id("com.android.application")
id("org.example.consistent-resolution-android-application")
id("org.owasp.dependencycheck")
}

val versionString = version as String
val versionInt = versionString.split(".")[0].toInt() * 1000 + versionString.split(".")[1].toInt()

android {
compileSdk = 31
namespace = "org.example.product.${project.name}"
defaultConfig {
applicationId = "org.example.product.app"
minSdk = 26
targetSdk = 31
versionCode = versionInt
versionName = versionString

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes.getByName("release") {
minifyEnabled(false)
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

packaging {
resources.excludes.add("META-INF/**")
}
}

// Configure common test runtime dependencies for android application projects
dependencies {
androidTestRuntimeOnly("androidx.test.espresso:espresso-core")
}

dependencyCheck {
scanConfigurations = listOf("releaseRuntimeClasspath")
autoUpdate = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
id("com.android.application")
id("org.example.consistent-resolution")
}

android {
applicationVariants.all {
dependencies.add(runtimeConfiguration.name, dependencies.platform("org.example.product:platform"))
compileConfiguration.shouldResolveConsistentlyWith(runtimeConfiguration)

unitTestVariant.compileConfiguration.shouldResolveConsistentlyWith(runtimeConfiguration)
unitTestVariant.runtimeConfiguration.shouldResolveConsistentlyWith(runtimeConfiguration)
dependencies.add(unitTestVariant.compileConfiguration.name, dependencies.platform("org.example.product:platform"))
dependencies.add(unitTestVariant.runtimeConfiguration.name, dependencies.platform("org.example.product:platform"))

if (testVariant != null) {
testVariant.compileConfiguration.shouldResolveConsistentlyWith(runtimeConfiguration)
testVariant.runtimeConfiguration.shouldResolveConsistentlyWith(runtimeConfiguration)
dependencies.add(testVariant.compileConfiguration.name, dependencies.platform("org.example.product:platform"))
dependencies.add(testVariant.runtimeConfiguration.name, dependencies.platform("org.example.product:platform"))
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.example.application.tasks
package org.example.android.tasks

import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
Expand Down
10 changes: 10 additions & 0 deletions gradle/plugins/android-library-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
`kotlin-dsl`
}

dependencies {
implementation(platform(project(":plugins-platform")))

implementation(project(":java-base-plugins"))
implementation("com.android.tools.build:gradle")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
id("org.example.base")
id("com.android.library")
id("org.example.consistent-resolution-android-library")
}

android {
compileSdk = 30
namespace = "org.example.product.${project.name}"

defaultConfig {
minSdk = 26
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
plugins {
id("com.android.library")
id("org.example.consistent-resolution")
}

android {
val appRuntimeClasspath = configurations["appRuntimeClasspath"]
libraryVariants.all {
compileConfiguration.shouldResolveConsistentlyWith(appRuntimeClasspath)
runtimeConfiguration.shouldResolveConsistentlyWith(appRuntimeClasspath)

unitTestVariant.compileConfiguration.shouldResolveConsistentlyWith(appRuntimeClasspath)
unitTestVariant.runtimeConfiguration.shouldResolveConsistentlyWith(appRuntimeClasspath)
dependencies.add(unitTestVariant.compileConfiguration.name, dependencies.platform("org.example.product:platform"))
dependencies.add(unitTestVariant.runtimeConfiguration.name, dependencies.platform("org.example.product:platform"))

if (testVariant != null) {
testVariant.compileConfiguration.shouldResolveConsistentlyWith(appRuntimeClasspath)
testVariant.runtimeConfiguration.shouldResolveConsistentlyWith(appRuntimeClasspath)
dependencies.add(testVariant.compileConfiguration.name, dependencies.platform("org.example.product:platform"))
dependencies.add(testVariant.runtimeConfiguration.name, dependencies.platform("org.example.product:platform"))
}
}
}
2 changes: 2 additions & 0 deletions gradle/plugins/base-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ dependencies {

implementation(project(":dependency-analysis-plugins"))
implementation(project(":dependency-rules-plugins"))

implementation("com.android.tools.build:gradle")
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,14 @@ dependencies.components {
// Make parents usable as pure 'Alignment Platforms' - remove all constraints that do not concern the alignment
withModule<ParentPomAsPlatformRule>(HttpComponentsPlatformRule.HTTP_COMPONENTS_CLIENT)
withModule<ParentPomAsPlatformRule>(Slf4jPlatformRule.SLF4J_PARENT)

// Avoid conflict between 'javax.activation' and 'jakarta.activation-api' in the detachedConfiguration that is input to AndroidLintTask.lintTool.classpath
withModule("com.android.tools:repository") {
allVariants {
withDependencies {
removeIf { it.name == "javax.activation" }
add("jakarta.activation:jakarta.activation-api")
}
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5e88df1

Please sign in to comment.