Skip to content

Commit

Permalink
Merge pull request java-decompiler#54 from sschuberth/master
Browse files Browse the repository at this point in the history
Use the APPDATA directory for storing the config on Windows
  • Loading branch information
emmanue1 committed Jul 7, 2015
2 parents 53bcde9 + b1bcee4 commit aca069e
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 116 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ for instant access to methods and fields.

##How to build JD-GUI ?
```
> gradle build
> ./gradlew build
```
generate _"build/libs/jd-gui-x.y.z.jar"_
```
> gradle installOsxDist
> ./gradlew installOsxDist
```
generate _"build/install/jd-gui-osx/JD-GUI.app"_
```
> iexplore http://sourceforge.net/projects/launch4j/files/launch4j-3/3.7/launch4j-3.7-win32.zip/download
> unzip launch4j-3.7-win32.zip
> gradle -DLAUNCH4J_HOME=.../path/to/launch4j-3.7-win32 installWindowsDist
> ./gradlew -DLAUNCH4J_HOME=.../path/to/launch4j-3.7-win32 installWindowsDist
```
generate _"build/install/jd-gui-windows/jd-gui.exe"_
```
> gradle buildDeb
> ./gradlew buildDeb
```
generate Ubuntu/Debian installer
```
> gradle buildRpm
> ./gradlew buildRpm
```
generate RedHat/CentOS/Fedora installer

Expand All @@ -50,11 +50,11 @@ generate RedHat/CentOS/Fedora installer

##How to extend JD-GUI ?
```
> gradle idea
> ./gradlew idea
```
generate Idea Intellij project
```
> gradle eclipse
> ./gradlew eclipse
```
generate Eclipse project
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,21 @@ class ConfigurationXmlPersisterProvider implements ConfigurationPersister {
if (userConfigFile.exists()) {
return new File(userConfigFile, Constants.CONFIG_FILENAME)
}
} else if (PlatformService.instance.isWindows) {
// See: http://blogs.msdn.com/b/patricka/archive/2010/03/18/where-should-i-store-my-data-and-configuration-files-if-i-target-multiple-os-versions.aspx
def roamingConfigHome = System.getenv('APPDATA')
if (roamingConfigHome) {
def roamingConfigHomeFile = new File(roamingConfigHome)
if (roamingConfigHomeFile.exists()) {
return new File(roamingConfigHomeFile, Constants.CONFIG_FILENAME)
}
}
}

return new File(Constants.CONFIG_FILENAME)
}

Configuration load() {
Configuration load() {
// Default values
def screenSize = Toolkit.defaultToolkit.screenSize

Expand Down Expand Up @@ -100,10 +109,10 @@ class ConfigurationXmlPersisterProvider implements ConfigurationPersister {
config.preferences.put(ERROR_BACKGROUND_COLOR, '0xFF6666')
}

return config
}
void save(Configuration configuration) {
return config
}

void save(Configuration configuration) {
Point l = configuration.mainWindowLocation
Dimension s = configuration.mainWindowSize
Writer writer = new StringWriter()
Expand Down
208 changes: 104 additions & 104 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,98 +15,98 @@ apply plugin: 'nebula.os-package'

// Common configuration //
allprojects {
version='1.2.0'

apply plugin: 'eclipse'
apply plugin: 'idea'

tasks.withType(JavaCompile) {
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
}
tasks.withType(GroovyCompile) {
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
}

repositories {
mavenCentral()
maven {
url 'https://raw.github.com/java-decompiler/mvn-repo/master'
}
}

configurations {
provided
compile.extendsFrom provided
}
version='1.2.0'

apply plugin: 'eclipse'
apply plugin: 'idea'

tasks.withType(JavaCompile) {
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
}
tasks.withType(GroovyCompile) {
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
}

repositories {
mavenCentral()
maven {
url 'https://raw.github.com/java-decompiler/mvn-repo/master'
}
}

configurations {
provided
compile.extendsFrom provided
}
}

// 'cleanIdea' task extension //
cleanIdea {
file(project.name + '.iws').delete()
ant.delete(dir: 'out')
file(project.name + '.iws').delete()
ant.delete(dir: 'out')
}

// All in one JAR //
subprojects.each { subproject ->
evaluationDependsOn(subproject.path)
evaluationDependsOn(subproject.path)
}

jar {
dependsOn subprojects.tasks['jar']

def deps = []
subprojects.each { subproject ->
from subproject.sourceSets.main.output.classesDir
from subproject.sourceSets.main.output.resourcesDir
deps += subproject.configurations.runtime - subproject.configurations.provided
}
subprojects.each { subproject ->
deps -= subproject.jar.archivePath
}
deps = deps.unique().collect { it.isDirectory() ? it : zipTree(it) }

manifest {
attributes 'Main-Class': 'org.jd.gui.App',
dependsOn subprojects.tasks['jar']

def deps = []
subprojects.each { subproject ->
from subproject.sourceSets.main.output.classesDir
from subproject.sourceSets.main.output.resourcesDir
deps += subproject.configurations.runtime - subproject.configurations.provided
}
subprojects.each { subproject ->
deps -= subproject.jar.archivePath
}
deps = deps.unique().collect { it.isDirectory() ? it : zipTree(it) }

manifest {
attributes 'Main-Class': 'org.jd.gui.App',
'SplashScreen-Image': 'org/jd/gui/images/jd_icon_128.png',
'JD-GUI-Version': project.version,
'JD-Core-Version': '0.7.1'
}
from deps
exclude 'META-INF/services/org.jd.gui.spi.*'
duplicatesStrategy DuplicatesStrategy.EXCLUDE
doFirst {
// Create temporary directory
def tmpSpiDir = file('build/tmp/spi')
tmpSpiDir.deleteDir()
tmpSpiDir.mkdirs()
// Copy and merge SPI config files
subprojects.each { subproject ->
def servicesDir = file(subproject.sourceSets.main.output.resourcesDir.path + File.separator + 'META-INF' + File.separator + 'services')
if (servicesDir.exists()) {
servicesDir.eachFile { source ->
def target = file(tmpSpiDir.path + File.separator + source.name)
target << source.text
}
}
}
// Add to JAR file
into('META-INF/services') {
from tmpSpiDir
}
}
}
from deps
exclude 'META-INF/services/org.jd.gui.spi.*'
duplicatesStrategy DuplicatesStrategy.EXCLUDE
doFirst {
// Create temporary directory
def tmpSpiDir = file('build/tmp/spi')
tmpSpiDir.deleteDir()
tmpSpiDir.mkdirs()
// Copy and merge SPI config files
subprojects.each { subproject ->
def servicesDir = file(subproject.sourceSets.main.output.resourcesDir.path + File.separator + 'META-INF' + File.separator + 'services')
if (servicesDir.exists()) {
servicesDir.eachFile { source ->
def target = file(tmpSpiDir.path + File.separator + source.name)
target << source.text
}
}
}
// Add to JAR file
into('META-INF/services') {
from tmpSpiDir
}
}
}

// Windows wrapper configuration to generate "jd-gui.exe" //
task launch4jConfig(type: Copy) {
from 'src/launch4j/resources/config/launch4j.xml'
into 'build/launch4j'
expand(
JAR_FILE: project.jar.archivePath,
VERSION: project.version,
ICON: file('src/launch4j/resources/images/jd-gui.ico')
)
JAR_FILE: project.jar.archivePath,
VERSION: project.version,
ICON: file('src/launch4j/resources/images/jd-gui.ico')
)
}

task launch4j(type: Exec, dependsOn: [':jar', ':launch4jConfig']) {
Expand Down Expand Up @@ -137,45 +137,45 @@ task copyAndReplaceVariablesInInfoPlist(type: Copy) {
}

distributions {
osx.contents {
into('JD-GUI.app/Contents') {
from 'build/tmp/distributions/osx'
}
into('JD-GUI.app/Contents/Resources/Java') {
from jar.archivePath
}
from 'LICENSE', 'NOTICE', 'README.md'
doFirst {
ant.chmod(file:'src/osx/dist/JD-GUI.app/Contents/MacOS/universalJavaApplicationStub.sh', perm:'+x')
}
}
windows.contents {
from 'build/launch4j/jd-gui.exe'
from 'LICENSE', 'NOTICE', 'README.md'
}
osx.contents {
into('JD-GUI.app/Contents') {
from 'build/tmp/distributions/osx'
}
into('JD-GUI.app/Contents/Resources/Java') {
from jar.archivePath
}
from 'LICENSE', 'NOTICE', 'README.md'
doFirst {
ant.chmod(file:'src/osx/dist/JD-GUI.app/Contents/MacOS/universalJavaApplicationStub.sh', perm:'+x')
}
}
windows.contents {
from 'build/launch4j/jd-gui.exe'
from 'LICENSE', 'NOTICE', 'README.md'
}
}

ospackage {
packageName = project.name
description = 'A Java Decompiler'
packageName = project.name
description = 'A Java Decompiler'
os = LINUX
url = 'https://github.com/java-decompiler/jd-gui'
license = file('LICENSE')

into '/opt/' + project.name
from ('build/libs/') {
fileMode = 0755
}
from ('src/linux/resources/') {
fileMode = 0755
}
from ('app/src/main/resources/images/jd_icon_128.png') {
fileMode = 0755
}
from 'LICENSE', 'NOTICE', 'README.md'

postInstall 'cd /opt/'+ project.name+'; ln -s ./jd-gui-'+project.version+'.jar ./jd-gui.jar; xdg-icon-resource install --size 128 --novendor ./jd_icon_128.png jd-gui ; xdg-desktop-menu install ./*.desktop'
preUninstall 'cd /opt/'+ project.name+'; rm -f ./jd-gui.jar; xdg-desktop-menu uninstall ./*.desktop'
into '/opt/' + project.name
from ('build/libs/') {
fileMode = 0755
}
from ('src/linux/resources/') {
fileMode = 0755
}
from ('app/src/main/resources/images/jd_icon_128.png') {
fileMode = 0755
}
from 'LICENSE', 'NOTICE', 'README.md'

postInstall 'cd /opt/'+ project.name+'; ln -s ./jd-gui-'+project.version+'.jar ./jd-gui.jar; xdg-icon-resource install --size 128 --novendor ./jd_icon_128.png jd-gui ; xdg-desktop-menu install ./*.desktop'
preUninstall 'cd /opt/'+ project.name+'; rm -f ./jd-gui.jar; xdg-desktop-menu uninstall ./*.desktop'
}

installOsxDist.dependsOn jar, copyAndReplaceVariablesInInfoPlist
Expand All @@ -187,4 +187,4 @@ windowsDistTar.dependsOn launch4j
windowsDistZip.dependsOn launch4j

buildDeb.dependsOn jar
buildRpm.dependsOn jar
buildRpm.dependsOn jar

0 comments on commit aca069e

Please sign in to comment.