Skip to content

Commit

Permalink
Enable creation of an Ubuntu snap
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Jul 23, 2017
1 parent 8730d02 commit af78a63
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ ui/
node_modules/
npm-debug.log

# snapcraft
parts/

# UNKNWON
jabref.xml
*.sonargraph
Expand Down
Binary file added .snapcraft/travis_snapcraft.cfg
Binary file not shown.
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ sudo: required
services:
- postgresql
- mysql
- docker

env:
global:
- GRADLE_OPTS=-Dorg.gradle.daemon=false
- TERM=dumb
matrix:
- TEST_SUITE=check OPTIONS=modernizer
- TEST_SUITE=fetcherTest
- TEST_SUITE=databaseTest
- TEST_SUITE=guiTest
- TEST_SUITE=checkstyle
- TEST_SUITE=snapcraft

matrix:
fast_finish: true
Expand All @@ -40,14 +43,14 @@ before_script:
script:
# --scan enables the Gradle build scan, which can be used to investiage the time each action consumes
# For more information see https://gradle.com/scans/get-started
- if [ "$TEST_SUITE" != "guiTest" ] && [ "$TEST_SUITE" != "checkstyle" ]; then ./gradlew $TEST_SUITE $OPTIONS --scan; fi
- if [ "$TEST_SUITE" != "checkstyle" ] && [ "$TEST_SUITE" != "guiTest" ] && [ "$TEST_SUITE" != "snapcraft" ]; then ./gradlew $TEST_SUITE $OPTIONS --scan; fi
- if [ "$TEST_SUITE" == "checkstyle" ]; then ./gradlew checkstyleMain checkstyleTest checkstyleJmh; fi
- if [ "$TEST_SUITE" == "guiTest" ]; then ./buildres/gui-tests.sh; fi

after_success:
# enable codecov report
- ./gradlew jacocoTestReport
- bash <(curl -s https://codecov.io/bash)
- if [ "$TEST_SUITE" != "checkstyle" ] && [ "$TEST_SUITE" != "snapcraft" ]; then ./gradlew jacocoTestReport && bash <(curl -s https://codecov.io/bash); fi
- if [ "$TRAVIS_BRANCH" == "snapcraft" ] && [ "$TEST_SUITE" == "snapcraft" ]; then openssl aes-256-cbc -K $encrypted_5f91cda8b19d_key -iv $encrypted_5f91cda8b19d_iv -in .snapcraft/travis_snapcraft.cfg -out .snapcraft/snapcraft.cfg -d && sh ./scripts/run-snapcraft.sh; fi

after_failure:
# show test results if build fails
Expand Down
10 changes: 7 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ sourceSets {
}

processResources {
filteringCharset = 'UTF-8'

filesMatching("build.properties") {
expand(version: project.version,
"year": String.valueOf(Calendar.getInstance().get(Calendar.YEAR)),
Expand All @@ -161,7 +163,6 @@ processResources {
"azureInstrumentationKey": System.getenv('AzureInstrumentationKey'))
filteringCharset = 'UTF-8'
}
filteringCharset = 'UTF-8'

filesMatching("resource/**/meta.xml") {
expand version: project.version
Expand Down Expand Up @@ -368,19 +369,22 @@ task release(dependsOn: ["media", "releaseJar"]) {
task releaseJar(dependsOn: "shadowJar") {
group = 'JabRef - Release'
description "Creates a Jar release."

doLast {
copy {
from("$buildDir/libs/JabRef-${project.version}-fat.jar")
into("$buildDir/releases")

rename { String fileName ->
fileName.replace('-fat', '')
}
}
file("$buildDir/releases/JabRef-${project.version}.jar").setExecutable(true, true);
}
}

task snapJar(dependsOn: "releaseJar", type: Delete) {
delete fileTree(dir: "$buildDir/releases/", exclude: "JabRef-${project.version}.jar")
}

jmh {
warmupIterations = 5
iterations = 10
Expand Down
4 changes: 4 additions & 0 deletions scripts/run-snapcraft.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#/bin/bash
VERSION=`grep "^version =" build.gradle | sed "s/^version = \"\(.*\)\".*/\1/"`
sed -i "s/4.0-dev/$VERSION/" snapcraft.yaml
docker run -v $(pwd):$(pwd) -t koppor/docker-snapcraft-java-de:v1.2.0 sh -c "cd $(pwd) && LANG=C.UTF-8 LC_ALL=C.UTF-8 snapcraft && LANG=C.UTF-8 LC_ALL=C.UTF-8 snapcraft push *.snap --release edge"
22 changes: 22 additions & 0 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# based on https://github.com/snapcore/snapcraft/blob/master/demos/gradle/snap/snapcraft.yaml

name: jabref
version: '4.0-dev'
summary: Bibliography manager
icon: src/main/resources/images/external/JabRef-icon-128.png
description: JabRef is an open source bibliography reference manager. The native file format used by JabRef is BibTeX, the standard LaTeX bibliography format.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

apps:
jabref:
command: java -jar $SNAP/jar/JabRef-4.0-dev.jar

parts:
jabref:
plugin: gradle
source: .
stage-packages: [default-jre, openjfx]
gradle-options: [snapJar]
gradle-output-dir: 'build/releases'

0 comments on commit af78a63

Please sign in to comment.