import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { id 'com.github.johnrengelman.shadow' id 'java-gradle-plugin' id 'org.jetbrains.kotlin.jvm' id 'maven-publish' id 'org.jlleitschuh.gradle.ktlint' version '12.1.2' } repositories { google() mavenCentral() } def agpVersion = '4.1.0' gradlePlugin { plugins { proguardPlugin { id = 'com.guardsquare.proguard' implementationClass = 'proguard.gradle.plugin.ProGuardPlugin' } } } compileKotlin { kotlinOptions.jvmTarget = "1.8" } compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } configurations { fatJar.extendsFrom(compile) } dependencies { api project(':base') // TODO update to 4.2 or 7.0 API compileOnly ("com.android.tools.build:gradle:$agpVersion") { exclude module: 'proguard-gradle' exclude module: 'proguard-base' } implementation 'com.github.zafarkhaja:java-semver:0.10.2' testCompileOnly ("com.android.tools.build:gradle:$agpVersion") { exclude module: 'proguard-gradle' exclude module: 'proguard-base' } testImplementation 'io.kotest:kotest-runner-junit5-jvm:5.9.1' // for kotest framework testImplementation 'io.kotest:kotest-assertions-core-jvm:5.9.1' // for kotest core jvm assertions testImplementation 'io.kotest:kotest-property-jvm:5.9.1' // for kotest property test testImplementation 'io.mockk:mockk:1.13.13' // for mocking testImplementation "commons-io:commons-io:2.18.0" fatJar project(":base") // This library is used to parse the android gradle plugin version at runtime. fatJar 'com.github.zafarkhaja:java-semver:0.10.2' } test { useJUnitPlatform() } def localRepo = file("$buildDir/local-repo") task fatJar(type: ShadowJar) { destinationDirectory.set(localRepo) archiveFileName.set("proguard-gradle-${version}.jar") from sourceSets.main.output configurations = [project.configurations.fatJar] manifest { attributes( 'Main-Class': 'proguard.ProGuard', 'Implementation-Version': archiveVersion.get()) } } tasks.withType(Test).configureEach { dependsOn fatJar systemProperty "local.repo", localRepo.toURI() systemProperty "proguard.version", version systemProperty "agp.version", agpVersion } sourceSets.test { resources { srcDirs += "$buildDir/fixtures" } } // Copies selected directories from examples into the test resources to compile during an integration test. def copyExamples = tasks.register('copyExamples', Copy) { from("$rootProject.rootDir/examples") { include 'spring-boot/**' include 'gradle-kotlin-dsl/**' include 'application/**' } into "$buildDir/fixtures" } tasks.named('processTestResources', ProcessResources) { dependsOn copyExamples } tasks.withType(Test).configureEach { dependsOn copyExamples } afterEvaluate { /* This project gets two publications: - "pluginMaven" is the default from `java-gradle-plugin` and must not be automatically published. - "" is created by ProGuard custom logic and should have its artifact ID adjusted. - we also disable publishing of plugin markers. */ tasks.withType(AbstractPublishToMaven).matching { task -> task.publication.name == 'pluginMaven' || task.name =~ /^publish(.*)PluginMarkerMavenPublicationTo(GithubRepository|MavenLocal|SonatypeRepository)$/ } each {task -> task.enabled = false } publishing { publications.getByName(project.name) { pom { description = 'Gradle plugin for ProGuard, the free shrinker, optimizer, obfuscator, and preverifier for Java bytecode' } } } }