Skip to content

Instantly share code, notes, and snippets.

View martinbonnin's full-sized avatar
😃

Martin Bonnin martinbonnin

😃
View GitHub Profile
pluginManagement {
repositories {
// The repo where to look for
maven {url = uri("https://com.example/m2")}
}
}
pluginManagement {
resolutionStrategy {
// These plugins don't have a marker artifact, tell gradle were to look them up
eachPlugin {
if (requested.id.id == "com.android.application") {
useModule("com.android.tools.build:gradle:${requested.version}")
}
if (requested.id.id == "com.squareup.sqldelight") {
useModule("com.squareup.sqldelight:gradle-plugin:${requested.version}")
}
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jetbrains.kotlin.jvm</groupId>
<artifactId>org.jetbrains.kotlin.jvm.gradle.plugin</artifactId>
<version>1.3.60</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-gradle-plugin</artifactId>
// settings.gradle.kts
pluginManagement {
repositories {
mavenCentral()
google()
}
plugins {
id("com.android.application").version("3.5.2")
id("com.squareup.sqldelight").version("1.2.0")
// buildSrc/build.gradle.kts
repositories {
mavenCentral()
google()
}
dependencies {
// add all your plugins artifacts here
classpath("com.android.tools.build:gradle:3.5.2")
package com.example
class GreetingPlugin : Plugin<Project> {
override fun apply(project: Project) {
project.task("hello") {
doLast {
println("Hello from the GreetingPlugin")
}
}
}
// build.gradle
buildscript {
repositories {
google()
}
dependencies {
// add the plugin to the build classpath
classpath("com.android.tools.build:gradle:3.5.2")
}
tasks.withType<LintBaseTask>().configureEach {
// doFirst is required else we get a Null Pointer Exception on lintOption
doFirst {
// This will override the lintOptions from the android extension
lintOptions.run {
if (name.toLowerCase().contains("debug")) {
// Do your configuration here
// isAbortOnError = false
// etc...
}
<lint>
<issue id="UnusedAttribute" severity="warning">
<!-- Ignore the specified issue if the location matched this path -->
<ignore path="**/AndroidManifest.xml"/>
<!-- Ignore the specified issue if the message or the location matches the regex -->
<ignore regexp="networkSecurityConfig"/>
<!-- path takes precedence over regexp so it's no use adding both -->
<!--<ignore path="**/AndroidManifest.xml" regexp="networkSecurityConfig"/>-->
</issue>
lintOptions {
// aborts the build if an error is found
// severity is resolved at execution so once all the rules have been processed
isAbortOnError = true
// also check source code from included projects
isCheckDependencies = true
// automatically runs lint on release builds. If you run lint from your CI
// you can disable it here and save some time
isCheckReleaseBuilds = false
// also check the test sources