Last active
November 17, 2023 08:33
-
-
Save iurysza/8b1dfb998bb9054cd708043a55f8e227 to your computer and use it in GitHub Desktop.
Revisions
-
iurysza revised this gist
Dec 27, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ version = "$libraryVersion" publishing { publications { create("main", MavenPublication) { artifactId = libraryArtifactId it.artifact("$buildDir/obfuscated/${libraryArtifactId}-${version}.jar") { builtBy obfuscateArtifact } -
iurysza created this gist
Dec 23, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ libraryVersion=0.1.0 libraryArtifactId=kotlin-library proguardVersion=7.0.1 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ import proguard.gradle.ProGuardTask buildscript { repositories { jcenter() google() } dependencies { classpath "com.guardsquare:proguard-gradle:$proguardVersion" } } task("obfuscateArtifact", type: ProGuardTask, dependsOn: jar) { description = "Obfuscates source files" def artifactName = "$libraryArtifactId-${libraryVersion}.jar" def obfuscatedFolder = "$buildDir/obfuscated" injars "$buildDir/libs/$artifactName" outjars "$obfuscatedFolder/$artifactName" // For de-obfuscating stack traces later on printseeds "$obfuscatedFolder/seeds.txt" printmapping "$obfuscatedFolder/mapping.txt" // dependencies libraryjars "${System.getProperty('java.home')}/lib/rt.jar" //works for java 8 libraryjars configurations.runtime libraryjars sourceSets.main.compileClasspath configuration files("$projectDir/gradle/configuration.pro") } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ group = "com.group" version = "$libraryVersion" publishing { publications { create("main", MavenPublication) { artifactId = decoderArtifactId it.artifact("$buildDir/obfuscated/${libraryArtifactId}-${version}.jar") { builtBy obfuscateArtifact } addLibInfoToPom(it) addDependenciesToPom(it) } create("unobfuscated", MavenPublication) { artifactId = "$libraryArtifactId-unobfuscated" from components["java"] addLibInfoToPom(it) } } repositories { maven { name = "LocalBuild" url = "file://$buildDir/repo" } maven { name = "NexusName" url = "https://nexus/repository/releases/" credentials { username = System.getenv("NEXUS_USERNAME") password = System.getenv("NEXUS_PASSWORD") } } } } private addLibInfoToPom(Publication publication) { publication.pom { name = "My obfuscated library" description = "Does stuff that I want to hide" } } private addDependenciesToPom(MavenPublication publication) { publication.pom.withXml { def dependencies = asNode().appendNode("dependencies") configurations.implementation.allDependencies.each { dep -> def depNode = dependencies.appendNode("dependency") depNode.appendNode("groupId", dep.group) depNode.appendNode("artifactId", dep.name) depNode.appendNode("version", dep.version) } } }