Skip to content

Commit

Permalink
Restructure, update Install4J
Browse files Browse the repository at this point in the history
- Release jars are on the top folder
- update Install4J
- icons now in buildres
  • Loading branch information
koppor committed Feb 8, 2018
1 parent 5058b36 commit e4e9e86
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
status.md

# Install4J
install4j6/
install4j7/

# Gradle
# generated when `gradlew --gui` is called
Expand Down
93 changes: 93 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,56 @@ plugins {
id 'nebula.lint' version '8.3.1'
id 'nebula.info' version '3.6.0'

id 'com.install4j.gradle' version '7.0.4'

id 'me.champeau.gradle.jmh' version '0.4.3'
id 'net.ltgt.errorprone' version '0.0.13'
id 'com.github.ben-manes.versions' version '0.17.0'
}

apply plugin: 'install4j'

group = "org.jabref"
version = "4.2-dev"
project.ext.threeDotVersion = "4.1.0.1"
project.ext.install4jDir = hasProperty("install4jDir") ? getProperty("install4jDir") : (org.gradle.internal.os.OperatingSystem.current().isWindows() ? 'C:/Program Files/install4j7' : 'install4j7')

/*
* Set releaseVersion to VERSION--snapshot--DATE--GIT_HASH
*/
def releaseVersion
if (project.hasProperty('dev')) {
String command = "git log --pretty=format:%cd--%h -n 1 --date=short"
String commitInfo = ""
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
commitInfo = "cmd /c $command".execute().in.text
} else {
commitInfo = command.execute().in.text
}

// determine branch
command = "git symbolic-ref -q --short HEAD"
String branchName = ""
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
branchName = "cmd /c $command".execute().in.text
} else {
branchName = command.execute().in.text
}
// A newline is returned. Remove it. (trim())
// In the context of github, the branch name could be something like "pull/277"
// "/" is an illegal character. To be safe, all illegal filename characters are replaced by "_"
// http://stackoverflow.com/a/15075907/873282 describes the used pattern.
branchName = branchName.trim().replaceAll("[^a-zA-Z0-9.-]", "_")

// hack string
// first the date (%cd), then the branch name, and finally the commit id (%h)
String infoString = commitInfo.substring(0, 10) + "--" + branchName + "--" + commitInfo.substring(12)

releaseVersion = project.version + "--snapshot--" + infoString
} else {
releaseVersion = project.version
}

// enable buildscan providing insights to our build (speed, ...)
// see https://gradle.com/build-scans for more information
buildScan { licenseAgreementUrl = 'https://gradle.com/terms-of-service'; licenseAgree = 'yes' }
Expand Down Expand Up @@ -176,3 +221,51 @@ allprojects {
}
}
}

install4j {
installDir = file(project.ext.install4jDir)
}

// has to be defined AFTER 'dev' things to have the correct releaseVersion
task releaseJar(dependsOn: ":org.jabref.gui:shadowJar") {
group = 'JabRef - Release'
description "Creates a Jar release."
doLast {
copy {
from("org.jabref.gui/build/libs/org.jabref.gui-${project.version}-fat.jar")
into("$buildDir/releases")
rename { String fileName -> "JabRef-${releaseVersion}.jar" }
}
// set executable with read permissions (first true) and for all (false)
file("$buildDir/releases/JabRef-${releaseVersion}.jar").setExecutable(true, false)
}
}

// has to be defined AFTER 'dev' things to have the correct releaseVersion
task media(type: com.install4j.gradle.Install4jTask, dependsOn: "releaseJar") {
projectFile = file('jabref.install4j')
release = releaseVersion
winKeystorePassword = System.getenv('CERTIFICATE_PW')
macKeystorePassword = System.getenv('CERTIFICATE_PW')
variables = [
versionFourDots: project.ext.threeDotVersion,
buildFileName : jar.archiveName,
version : releaseVersion
]

doLast {
copy {
from "build/install4j"
into "build/releases"
}
}
}

task release(dependsOn: "media") {
group = 'JabRef - Release'
description 'Creates a release for all target platforms.'
}

task snapJar(dependsOn: "releaseJar", type: Delete) {
delete fileTree(dir: "$buildDir/releases/", exclude: "JabRef-${releaseVersion}.jar")
}
Binary file added buildres/jabref.icns
Binary file not shown.
Binary file added buildres/jabref.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
# openssl aes-256-cbc -e -in ./buildres/jabref-cert-2016.p12 -out jabref-cert-2016.p12.enc -k {PASSWORD}
#- openssl aes-256-cbc -d -in ./buildres/jabref-cert-2016.p12.enc -out ./buildres/jabref-cert-2016.p12 -k $CERTIFICATE
- scripts/prepare-install4j.sh
- cd org.jabref.gui && install4j7/bin/install4jc --verbose --license=$INSTALL4J_KEY
- install4j7/bin/install4jc --verbose --license=$INSTALL4J_KEY
#--win-keystore-password $CERTIFICATE_PW --mac-keystore-password $CERTIFICATE_PW
override:
# We do this to decrease build time by using CircleCI's cache. See https://discuss.circleci.com/t/effective-caching-for-gradle/540 for a longer motivation.
Expand Down
12 changes: 6 additions & 6 deletions org.jabref.gui/jabref.install4j → jabref.install4j
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
<components />
</files>
<launchers>
<launcher name="JabRef" id="23" customizedId="" external="false" excludeFromMenu="false" unixMode="755" unixAutoStart="true" menuName="" icnsFile="./src/main/resources/icons/jabref.icns" customMacBundleIdentifier="false" macBundleIdentifier="" swtApp="false" fileset="" macBundleBinary="JavaApplicationStub" addMacEntitlements="false" macEntitlementsFile="" useCustomMacosExecutableName="false" customMacosExecutableName="" useJavaMinVersionOverride="false" javaMinVersionOverride="" useJavaMaxVersionOverride="false" javaMaxVersionOverride="" checkUpdater="false" updateExecutionMode="unattendedProgress" unattendedUpdateTitle="${i18n:updater.WindowTitle(&quot;${compiler:sys.fullName}&quot;)}">
<executable name="JabRef" type="1" iconSet="true" iconFile="./src/main/resources/icons/jabref.ico" executableDir="" redirectStderr="true" stderrFile="error.log" stderrMode="overwrite" redirectStdout="false" stdoutFile="output.log" stdoutMode="overwrite" failOnStderrOutput="true" executableMode="1" changeWorkingDirectory="true" workingDirectory="." singleInstance="false" serviceStartType="2" serviceDependencies="" serviceDescription="" jreLocation="" executionLevel="asInvoker" checkConsoleParameter="true" globalSingleInstance="false" singleInstanceActivate="true" dpiAware="false">
<launcher name="JabRef" id="23" customizedId="" external="false" excludeFromMenu="false" unixMode="755" unixAutoStart="true" menuName="" icnsFile="./buildres/jabref.icns" customMacBundleIdentifier="false" macBundleIdentifier="" swtApp="false" fileset="" macBundleBinary="JavaApplicationStub" addMacEntitlements="false" macEntitlementsFile="" useCustomMacosExecutableName="false" customMacosExecutableName="" useJavaMinVersionOverride="false" javaMinVersionOverride="" useJavaMaxVersionOverride="false" javaMaxVersionOverride="" checkUpdater="false" updateExecutionMode="unattendedProgress" unattendedUpdateTitle="${i18n:updater.WindowTitle(&quot;${compiler:sys.fullName}&quot;)}">
<executable name="JabRef" type="1" iconSet="true" iconFile="./buildres/jabref.ico" executableDir="" redirectStderr="true" stderrFile="error.log" stderrMode="overwrite" redirectStdout="false" stdoutFile="output.log" stdoutMode="overwrite" failOnStderrOutput="true" executableMode="1" changeWorkingDirectory="true" workingDirectory="." singleInstance="false" serviceStartType="2" serviceDependencies="" serviceDescription="" jreLocation="" executionLevel="asInvoker" checkConsoleParameter="true" globalSingleInstance="false" singleInstanceActivate="true" dpiAware="false">
<versionInfo include="true" fileVersion="${compiler:versionFourDots}" fileDescription="${compiler:sys.fullName}" legalCopyright="${compiler:sys.fullName}" internalName="${compiler:sys.fullName}" productName="" />
</executable>
<splashScreen show="false" width="0" height="0" bitmapFile="" textOverlay="false">
Expand Down Expand Up @@ -102,7 +102,7 @@
<customAttributes />
</autoUpdate>
<applications>
<application name="" id="installer" customizedId="" beanClass="com.install4j.runtime.beans.applications.InstallerApplication" enabled="true" commentSet="false" comment="" actionElevationType="none" styleId="" fileset="" customIcnsFile="./src/main/resources/icons/jabref.icns" customIcoFile="./src/main/resources/icons/jabref.ico" macEntitlementsFile="" automaticLauncherIntegration="false" launchMode="startupFirstWindow" launchInNewProcess="false" launchSchedule="updateSchedule" allLaunchers="true">
<application name="" id="installer" customizedId="" beanClass="com.install4j.runtime.beans.applications.InstallerApplication" enabled="true" commentSet="false" comment="" actionElevationType="none" styleId="" fileset="" customIcnsFile="./buildres/jabref.icns" customIcoFile="./buildres/jabref.ico" macEntitlementsFile="" automaticLauncherIntegration="false" launchMode="startupFirstWindow" launchInNewProcess="false" launchSchedule="updateSchedule" allLaunchers="true">
<serializedBean>
<java class="java.beans.XMLDecoder">
<object class="com.install4j.runtime.beans.applications.InstallerApplication">
Expand Down Expand Up @@ -183,7 +183,7 @@
context.setInstallationDirectory(new File(System.getenv("LOCALAPPDATA"), "JabRef"));
} else {
context.setInstallationDirectory(new File(System.getProperty("user.home"), "JabRef"));
}
}
}
return true;</string>
</void>
Expand Down Expand Up @@ -608,7 +608,7 @@ return console.askOkCancel(message, true);
</void>
<void property="macIconFile">
<object class="com.install4j.api.beans.ExternalFile">
<string>./src/main/resources/icons/jabref.icns</string>
<string>./icons/jabref.icns</string>
</object>
</void>
<void property="macRole">
Expand All @@ -622,7 +622,7 @@ return console.askOkCancel(message, true);
</void>
<void property="windowsIconFile">
<object class="com.install4j.api.beans.ExternalFile">
<string>./src/main/resources/icons/jabref.ico</string>
<string>./icons/jabref.ico</string>
</object>
</void>
</object>
Expand Down
92 changes: 0 additions & 92 deletions org.jabref.gui/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.gradle.internal.os.OperatingSystem

buildscript {
repositories {
mavenLocal()
Expand All @@ -14,57 +12,18 @@ buildscript {
}

plugins {
id 'com.install4j.gradle' version '7.0.3'
id 'com.github.johnrengelman.shadow' version '2.0.2'
id "de.sebastianboegl.shadow.transformer.log4j" version "2.1.1"
}

apply plugin: 'application'
apply plugin: 'install4j'

jacoco {
toolVersion = '0.8.0'
}

project.ext.threeDotVersion = "4.1.0.1"
project.ext.install4jDir = hasProperty("install4jDir") ? getProperty("install4jDir") : (OperatingSystem.current().isWindows() ? 'C:/Program Files/install4j6' : 'install4j6')
mainClassName = "org.jabref.JabRefMain"

/*
* Changes project.version to VERSION--snapshot--DATE--GIT_HASH
*
* This code has to stay in org.jabref.gui/build.gradle, because it has no effect if contained in /build.gradle.
*/
if (hasProperty('dev')) {
String command = "git log --pretty=format:%cd--%h -n 1 --date=short"
String commitInfo = ""
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
commitInfo = "cmd /c $command".execute().in.text
} else {
commitInfo = command.execute().in.text
}

// determine branch
command = "git symbolic-ref -q --short HEAD"
String branchName = ""
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
branchName = "cmd /c $command".execute().in.text
} else {
branchName = command.execute().in.text
}
// A newline is returned. Remove it. (trim())
// In the context of github, the branch name could be something like "pull/277"
// "/" is an illegal character. To be safe, all illegal filename characters are replaced by "_"
// http://stackoverflow.com/a/15075907/873282 describes the used pattern.
branchName = branchName.trim().replaceAll("[^a-zA-Z0-9.-]", "_")

// hack string
// first the date (%cd), then the branch name, and finally the commit id (%h)
String infoString = commitInfo.substring(0, 10) + "--" + branchName + "--" + commitInfo.substring(12)

project.version += "--snapshot--" + infoString
}

// These are the Java version requirements we will check on each start of JabRef
ext.minRequiredJavaVersion = "1.8.0_144"
ext.allowJava9 = false
Expand Down Expand Up @@ -256,57 +215,6 @@ afterEvaluate {
}
}

// Release tasks
shadowJar {
classifier 'fat'
}

install4j {
installDir = file(project.ext.install4jDir)
}

// has to be defined AFTER 'dev' things to have the correct project.version
task media(type: com.install4j.gradle.Install4jTask, dependsOn: "releaseJar") {
projectFile = file('jabref.install4j')
release = project.version
winKeystorePassword = System.getenv('CERTIFICATE_PW')
macKeystorePassword = System.getenv('CERTIFICATE_PW')
variables = [
versionFourDots: project.ext.threeDotVersion,
buildFileName : jar.archiveName,
version : project.version
]

doLast {
copy {
from "build/install4j"
into "build/releases"
}
}
}


task release(dependsOn: ["media", "releaseJar"]) {
group = 'JabRef - Release'
description 'Creates a release for all target platforms.'
}

task releaseJar(dependsOn: "shadowJar") {
group = 'JabRef - Release'
description "Creates a Jar release."
doLast {
copy {
from("build/libs/org.jabref.gui-${project.version}-fat.jar")
into("build/releases")
rename { String fileName ->
fileName.replace('-fat', '').replace('org.jabref.gui', 'JabRef')
}
}
// set executable with read permissions (first true) and for all (false)
file("$buildDir/releases/JabRef-${project.version}.jar").setExecutable(true, false)
}
}

task snapJar(dependsOn: "releaseJar", type: Delete) {
delete fileTree(dir: "$buildDir/releases/", exclude: "JabRef-${project.version}.jar")
}
6 changes: 3 additions & 3 deletions scripts/prepare-install4j.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ fi

# ensure that tar archive of install4j exists
cd ~/downloads
wget --quiet -nc http://download-keycdn.ej-technologies.com/install4j/install4j_unix_7_0_3.tar.gz
wget --quiet -nc http://download-keycdn.ej-technologies.com/install4j/install4j_unix_7_0_4.tar.gz

# extract tar archive of install4j into the source directory of JabRef
cd ~/jabref
# version 7.0.1 is NOT zipped any more - old command line: "-xzf"
tar -xf ~/downloads/install4j_unix_7_0_3.tar.gz
tar -xf ~/downloads/install4j_unix_7_0_4.tar.gz
# fix directory name (until install4j 6.1.5 it was install4j6
mv install4j7.0.3 org.jabref.gui/install4j7
mv install4j7.0.4 install4j7

# fetch JREs
if [ ! -d ~/.install4j7/jres/ ]; then
Expand Down
6 changes: 3 additions & 3 deletions scripts/upload-to-builds.jabref.org.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ branch="snapshot"

# simple solution to treat first file matching a pattern
# hint by http://unix.stackexchange.com/a/156207/18033
for buildfile in org.jabref.gui/build/releases/*--snapshot--*; do
for buildfile in build/releases/*--snapshot--*; do
# the last "--" part is the branch name
branch=`echo $buildfile | sed "sX.*--\(.*\)--.*X\1X"`
break;
done

for buildfile in org.jabref.gui/build/releases/*--snapshot--*.jar; do
for buildfile in build/releases/*--snapshot--*.jar; do
# remove build/releases/ from the filename
jarname=`echo $buildfile | sed "sXbuild/releases/XX"`
break;
Expand All @@ -33,7 +33,7 @@ if [ "snapshot" != "$branch" ] ; then
fi

# only upload JabRef*, not md5sums, updates.xml, etc.
command="${command}mput org.jabref.gui/build/releases/JabRef*\n"
command="${command}mput build/releases/JabRef*\n"

# create symlink ...--latest.jar to latest version
command="${command}symlink ${jarname} /www/${branch}/JabRef--${branch}--latest.jar\n"
Expand Down

0 comments on commit e4e9e86

Please sign in to comment.