1buildscript { 2 repositories { 3 jcenter() 4 } 5 dependencies { 6 classpath 'com.netflix.nebula:gradle-ospackage-plugin:5.3.0' // RPM & DEB support 7 classpath 'edu.sc.seis.gradle:launch4j:2.4.4' 8 classpath 'net.sf.proguard:proguard-gradle:6.1.0' 9 } 10} 11 12apply plugin: 'java' 13apply plugin: 'distribution' 14apply plugin: 'edu.sc.seis.launch4j' 15apply plugin: 'nebula.ospackage' 16 17// Common configuration // 18rootProject.version='1.6.6' 19rootProject.ext.set('jdCoreVersion', '1.1.3') 20targetCompatibility = '1.8' 21 22allprojects { 23 apply plugin: 'eclipse' 24 apply plugin: 'idea' 25 26 tasks.withType(JavaCompile) { 27 sourceCompatibility = targetCompatibility = '1.8' 28 options.compilerArgs << '-Xlint:deprecation' 29 options.compilerArgs << '-Xlint:unchecked' 30 options.encoding = 'UTF-8' 31 } 32 33 repositories { 34 jcenter() 35 } 36 37 configurations { 38 provided 39 compile.extendsFrom provided 40 } 41} 42 43// 'cleanIdea' task extension // 44cleanIdea.doFirst { 45 delete project.name + '.iws' 46 delete 'out' 47 followSymlinks = true 48} 49 50// All in one JAR file // 51subprojects.each { subproject -> 52 evaluationDependsOn(subproject.path) 53} 54 55jar { 56 dependsOn subprojects.tasks['jar'] 57 58 // Add SPI directory 59 def tmpSpiDir = file('build/tmp/spi') 60 from tmpSpiDir 61 // Add dependencies 62 def deps = [] 63 subprojects.each { subproject -> 64 from subproject.sourceSets.main.output.classesDirs 65 from subproject.sourceSets.main.output.resourcesDir 66 deps += subproject.configurations.runtime - subproject.configurations.provided 67 } 68 subprojects.each { subproject -> 69 deps -= subproject.jar.archivePath 70 } 71 deps = deps.unique().collect { it.isDirectory() ? it : zipTree(it) } 72 from deps 73 74 manifest { 75 attributes 'Main-Class': 'org.jd.gui.App', 76 'SplashScreen-Image': 'org/jd/gui/images/jd_icon_128.png', 77 'JD-GUI-Version': project.version, 78 'JD-Core-Version': project.jdCoreVersion 79 } 80 exclude 'META-INF/licenses/**', 'META-INF/maven/**', 'META-INF/INDEX.LIST' 81 exclude '**/ErrorStrip_*.properties', '**/RSyntaxTextArea_*.properties', '**/RTextArea_*.properties' 82 exclude '**/FocusableTip_*.properties', '**/RSyntaxTextArea_License.txt' 83 duplicatesStrategy DuplicatesStrategy.EXCLUDE 84 doFirst { 85 // Create SPI directory 86 tmpSpiDir.deleteDir() 87 def tmpSpiServicesDir = file(tmpSpiDir.path + '/META-INF/services') 88 tmpSpiServicesDir.mkdirs() 89 // Copy and merge SPI config files 90 subprojects.each { subproject -> 91 def servicesDir = file(subproject.sourceSets.main.output.resourcesDir.path + '/META-INF/services') 92 if (servicesDir.exists()) { 93 servicesDir.eachFile { serviceFile -> 94 def target = file(tmpSpiServicesDir.path + '/' + serviceFile.name) 95 target << serviceFile.text 96 } 97 } 98 } 99 } 100} 101 102// Minify JAR file // 103task proguard(type: proguard.gradle.ProGuardTask, dependsOn: 'jar') { 104 configuration 'src/proguard/resources/proguard.config.txt' 105 injars jar.archivePath 106 outjars 'build/libs/' + project.name + '-' + project.version + '-min.jar' 107 libraryjars System.getProperty('java.home') + '/lib/rt.jar' 108 libraryjars System.getProperty('java.home') + '/jmods/' 109} 110 111// Java executable wrapper for Windows // 112launch4j { 113 createExe.dependsOn 'proguard' 114 115 version = textVersion = project.version 116 fileDescription = productName = 'JD-GUI' 117 errTitle 'JD-GUI Windows Wrapper' 118 copyright 'JD-GUI (C) 2008-2019 Emmanuel Dupuy' 119 icon projectDir.path + '/src/launch4j/resources/images/jd-gui.ico' 120 jar projectDir.path + '/' + proguard.outJarFiles[0] 121 bundledJrePath = '%JAVA_HOME%' 122} 123 124// Packages for Linux // 125ospackage { 126 buildDeb.dependsOn 'proguard' 127 buildRpm.dependsOn 'proguard' 128 129 license = file('LICENSE') 130 maintainer 'Emmanuel Dupuy <emmanue1@users.noreply.github.com>' 131 os LINUX 132 packageDescription 'JD-GUI, a standalone graphical utility that displays Java sources from CLASS files' 133 packageGroup 'java' 134 packageName project.name 135 release '0' 136 summary 'A Java Decompiler' 137 url 'https://github.com/java-decompiler/jd-gui' 138 139 into '/opt/' + project.name 140 from (proguard.outJarFiles[0]) { 141 fileMode 0755 142 } 143 from ('src/linux/resources/') { 144 fileMode 0755 145 } 146 from 'LICENSE', 'NOTICE', 'README.md' 147 148 postInstall 'cd /opt/' + project.name + '; ln -s ./' + file(proguard.outJarFiles[0]).name + ' ./jd-gui.jar; xdg-icon-resource install --size 128 --novendor ./jd_icon_128.png jd-gui; xdg-desktop-menu install ./*.desktop' 149 preUninstall 'cd /opt/' + project.name + '; rm -f ./jd-gui.jar; rm -fr ./ext; xdg-desktop-menu uninstall ./*.desktop' 150} 151 152// Distributions for OSX and Windows // 153distributions { 154 osx.contents { 155 into('JD-GUI.app/Contents') { 156 from('src/osx/resources') { 157 include 'Info.plist' 158 expand VERSION: project.version, 159 JAR: file(proguard.outJarFiles[0]).name 160 } 161 } 162 into('JD-GUI.app/Contents/MacOS') { 163 from('src/osx/resources') { 164 include 'universalJavaApplicationStub.sh' 165 fileMode 0755 166 } 167 } 168 into('JD-GUI.app/Contents/Resources/Java') { 169 from proguard.outJarFiles[0] 170 } 171 from 'LICENSE', 'NOTICE', 'README.md' 172 } 173 windows.contents { 174 from 'build/launch4j/jd-gui.exe' 175 from 'LICENSE', 'NOTICE', 'README.md' 176 } 177 178 installWindowsDist.dependsOn createExe 179 windowsDistTar.dependsOn createExe 180 windowsDistZip.dependsOn createExe 181 182 installOsxDist.dependsOn 'proguard' 183 osxDistTar.dependsOn 'proguard' 184 osxDistZip.dependsOn 'proguard' 185} 186 187build.finalizedBy buildDeb 188build.finalizedBy buildRpm 189