Initial javapackager task: currently builds RPMs.

This commit is contained in:
Chris Rankin 2017-02-08 16:40:06 +00:00
parent d3cdb2af67
commit 8b77068eb0
2 changed files with 130 additions and 0 deletions

View File

@ -7,6 +7,12 @@ buildscript {
ext.slf4j_version = '1.7.22'
ext.logback_version = '1.1.3'
ext.java_home = System.properties.'java.home'
ext.pkg_source = 'build/packagesrc'
ext.dist_name = "demobench-${version}"
ext.dist_source = "${pkg_source}/${dist_name}"
ext.pkg_version = "$version".indexOf('-') >= 0 ? "$version".substring(0, "$version".indexOf('-')) : "$version"
repositories {
mavenCentral()
}
@ -112,3 +118,57 @@ distributions {
}
}
}
/*
* Invokes the JavaPackager Ant task, using the ZIP distribution as source.
*/
task javapackage {
doLast {
ant.taskdef(
resource: 'com/sun/javafx/tools/ant/antlib.xml',
classpath: "${pkg_source}:${java_home}/../lib/ant-javafx.jar"
)
ant.delete(dir: "${pkg_source}")
ant.delete(dir: 'build/exedir')
ant.unzip(src: "build/distributions/${dist_name}.zip", dest: "${pkg_source}")
ant.copy(todir: "${pkg_source}/package", filtering: 'true') {
fileset(dir: 'package')
filterset(begintoken: '@', endtoken: '@') {
filter(token: 'pkg_version', value: "${pkg_version}")
}
}
ant.deploy(nativeBundles: 'rpm', outdir: 'build/exedir', outfile: 'DemoBench', verbose: 'true') {
application(name: 'DemoBench', version: "$pkg_version", mainClass: "$mainClassName")
resources {
fileset(dir: "${dist_source}/lib", type: 'jar') {
include(name: '*.jar')
}
fileset(dir: "${dist_source}/lib", type: 'native') {
include(name: "macosx/**/*.dylib")
include(name: "win/**/*.dll")
include(name: "win/**/*.exe")
include(name: "linux/**/*.so")
}
fileset(dir: "$dist_source", type: 'data') {
include(name: 'corda/*.jar')
include(name: 'plugins/*.jar')
include(name: 'explorer/*.jar')
}
}
platform {
property(name: 'java.util.logging.config.class', value: 'net.corda.demobench.config.LoggingConfig')
}
preferences(install: false)
}
}
}

View File

@ -0,0 +1,70 @@
Summary: DemoBench
Name: demobench
Version: @pkg_version@
Release: 1
License: Unknown
Vendor: Unknown
Prefix: /opt
Provides: demobench
Requires: ld-linux.so.2 libX11.so.6 libXext.so.6 libXi.so.6 libXrender.so.1 libXtst.so.6 libasound.so.2 libc.so.6 libdl.so.2 libgcc_s.so.1 libm.so.6 libpthread.so.0 libthread_db.so.1
Autoprov: 0
Autoreq: 0
#avoid ARCH subfolder
%define _rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
#comment line below to enable effective jar compression
#it could easily get your package size from 40 to 15Mb but
#build time will substantially increase and it may require unpack200/system java to install
%define __jar_repack %{nil}
%define _javaHome %{getenv:JAVA_HOME}
%description
DemoBench
%prep
%build
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/opt
cp -r %{_sourcedir}/DemoBench %{buildroot}/opt
mkdir -p %{buildroot}/opt/DemoBench/runtime/bin
cp %{_javaHome}/bin/java %{buildroot}/opt/DemoBench/runtime/bin
%files
/opt/DemoBench
%post
xdg-desktop-menu install --novendor /opt/DemoBench/DemoBench.desktop
if [ "false" = "true" ]; then
cp /opt/DemoBench/demobench.init /etc/init.d/demobench
if [ -x "/etc/init.d/demobench" ]; then
/sbin/chkconfig --add demobench
if [ "false" = "true" ]; then
/etc/init.d/demobench start
fi
fi
fi
%preun
xdg-desktop-menu uninstall --novendor /opt/DemoBench/DemoBench.desktop
if [ "false" = "true" ]; then
if [ -x "/etc/init.d/demobench" ]; then
if [ "true" = "true" ]; then
/etc/init.d/demobench stop
fi
/sbin/chkconfig --del demobench
rm -f /etc/init.d/demobench
fi
fi
%clean