11import java.util.regex.Matcher
22
33buildscript {
4- repositories {
5- maven { url ' https://plugins.gradle.org/m2/' }
6- }
4+ repositories {
5+ maven { url ' https://plugins.gradle.org/m2/' }
6+ }
77}
88
99plugins {
10- id " java"
11- id " java-library"
12- id " application"
13- id " nebula.ospackage-application" version " 8.0.3"
14- id " idea"
10+ id " java"
11+ id " java-library"
12+ id " application"
13+ id " nebula.ospackage-application" version " 8.0.3"
14+ id " idea"
1515}
1616
1717idea. module. outputDir file(" out/production/classes" )
@@ -28,115 +28,114 @@ def jvmVersion = System.getProperty('java.version').split('\\.')[0] as Integer
2828def useModules = jvmVersion >= 9 && ! project. hasProperty(' no-modules' )
2929
3030repositories {
31- mavenCentral()
32- maven { url ' https://swimos.bintray.com/maven/' }
33- maven { url ' http://packages.confluent.io/maven/' }
31+ mavenCentral()
32+ maven { url ' https://swimos.bintray.com/maven/' }
3433}
3534
3635dependencies {
37- api group : ' org.swimos' , name : ' swim-server' , version : version
38- api group : ' org.swimos' , name : ' swim-client' , version : version
36+ api group : ' org.swimos' , name : ' swim-server' , version : version
37+ api group : ' org.swimos' , name : ' swim-client' , version : version
3938}
4039
4140afterEvaluate {
42- compileJava {
43- if (useModules) {
44- doFirst {
45- options. compilerArgs + = [
46- ' --module-path' , classpath. asPath,
47- ]
48- classpath = files()
49- }
50- }
51- options. compilerArgs + = [' -Xlint' ]
52- options. encoding = ' UTF-8'
41+ compileJava {
42+ if (useModules) {
43+ doFirst {
44+ options. compilerArgs + = [
45+ ' --module-path' , classpath. asPath,
46+ ]
47+ classpath = files()
48+ }
5349 }
54-
55- jar {
56- inputs. property(' moduleName' , moduleName)
57- manifest {
58- attributes(
59- ' Implementation-Title' : moduleName,
60- ' Implementation-Version' : version,
61- ' Main-Class' : mainClassName)
62- }
50+ options. compilerArgs + = [' -Xlint' ]
51+ options. encoding = ' UTF-8'
52+ }
53+
54+ jar {
55+ inputs. property(' moduleName' , moduleName)
56+ manifest {
57+ attributes(
58+ ' Implementation-Title' : moduleName,
59+ ' Implementation-Version' : version,
60+ ' Main-Class' : mainClassName)
6361 }
62+ }
6463
65- tasks. withType(JavaCompile ) {
66- options. encoding = ' UTF-8'
67- if (! useModules) {
68- exclude ' *module-info*'
69- }
64+ tasks. withType(JavaCompile ) {
65+ options. encoding = ' UTF-8'
66+ if (! useModules) {
67+ exclude ' *module-info*'
7068 }
71-
72- run {
73- dependsOn jar
74- doFirst {
75- jvmArgs + = [
76- ' --module-path ' , files(configurations . runtimeClasspath, jar . archiveFile) . asPath,
77- ' --module' , " ${ moduleName } / ${ mainClassName } "
78- ]
79- classpath = files()
80- }
69+ }
70+
71+ run {
72+ dependsOn jar
73+ doFirst {
74+ jvmArgs + = [
75+ ' --module-path ' , files(configurations . runtimeClasspath, jar . archiveFile) . asPath,
76+ ' --module ' , " ${ moduleName } / ${ mainClassName } "
77+ ]
78+ classpath = files()
8179 }
82-
83- startScripts {
84- inputs. property(" moduleName" , moduleName)
85- doFirst {
86- classpath = files()
87- defaultJvmOpts = [
88- ' -Dswim.config=/server.recon' ,
89- ' -Xms3g' ,
90- ' -Xmx3g' ,
91- ' --module-path' , ' APP_HOME_LIBS' ,
92- ' --module' , " ${ moduleName} /${ mainClassName} "
93- ]
94- }
95- doLast {
96- def bashFile = new File (outputDir, applicationName)
97- String bashContent = bashFile. text
98- bashFile. text = bashContent. replaceFirst(' APP_HOME_LIBS' , Matcher . quoteReplacement(' $APP_HOME/lib' ))
99-
100- def batFile = new File (outputDir, applicationName + " .bat" )
101- String batContent = batFile. text
102- batFile. text = batContent. replaceFirst(' APP_HOME_LIBS' , Matcher . quoteReplacement(' %APP_HOME%\\ lib' ))
103- }
80+ }
81+
82+ startScripts {
83+ inputs. property(" moduleName" , moduleName)
84+ doFirst {
85+ classpath = files()
86+ defaultJvmOpts = [
87+ ' -Dswim.config=/server.recon' ,
88+ ' -Xms3g' ,
89+ ' -Xmx3g' ,
90+ ' --module-path' , ' APP_HOME_LIBS' ,
91+ ' --module' , " ${ moduleName} /${ mainClassName} "
92+ ]
10493 }
105-
106- ospackage {
107- release ' 1'
108- prefix ' /opt/swim-tutorial'
94+ doLast {
95+ def bashFile = new File (outputDir, applicationName)
96+ String bashContent = bashFile. text
97+ bashFile. text = bashContent. replaceFirst(' APP_HOME_LIBS' , Matcher . quoteReplacement(' $APP_HOME/lib' ))
98+
99+ def batFile = new File (outputDir, applicationName + " .bat" )
100+ String batContent = batFile. text
101+ batFile. text = batContent. replaceFirst(' APP_HOME_LIBS' , Matcher . quoteReplacement(' %APP_HOME%\\ lib' ))
102+ }
103+ }
104+
105+ ospackage {
106+ release ' 1'
107+ prefix ' /opt/swim-tutorial'
108+ }
109+
110+ task packageDeb(type : Deb ) {
111+ maintainer = ' developer@swim.ai'
112+
113+ configurationFile(" /etc/sysconfig/${ project.name} " )
114+ preInstall " addgroup --quiet --system ${ project.name} "
115+ preInstall " adduser --quiet --system --ingroup ${ project.name} --no-create-home --disabled-password ${ project.name} "
116+ postInstall " systemctl preset ${ project.name} > /dev/null 2>&1"
117+ postInstall " systemctl start ${ project.name} > /dev/null 2>&1"
118+ preUninstall " systemctl disable ${ project.name} > /dev/null 2>&1"
119+ preUninstall " systemctl stop ${ project.name} > /dev/null 2>&1"
120+ postUninstall " systemctl daemon-reload > /dev/null 2>&1"
121+
122+ from(' pkg' ) {
123+ into ' /etc/systemd/system'
124+ include ' *.service'
125+ addParentDirs false
126+ expand project. properties
127+ user ' root'
128+ permissionGroup ' root'
129+ fileMode = 0644
109130 }
110131
111- task packageDeb(type : Deb ) {
112- maintainer = ' developer@swim.ai'
113-
114- configurationFile(" /etc/sysconfig/${ project.name} " )
115- preInstall " addgroup --quiet --system ${ project.name} "
116- preInstall " adduser --quiet --system --ingroup ${ project.name} --no-create-home --disabled-password ${ project.name} "
117- postInstall " systemctl preset ${ project.name} > /dev/null 2>&1"
118- postInstall " systemctl start ${ project.name} > /dev/null 2>&1"
119- preUninstall " systemctl disable ${ project.name} > /dev/null 2>&1"
120- preUninstall " systemctl stop ${ project.name} > /dev/null 2>&1"
121- postUninstall " systemctl daemon-reload > /dev/null 2>&1"
122-
123- from(' pkg' ) {
124- into ' /etc/systemd/system'
125- include ' *.service'
126- addParentDirs false
127- expand project. properties
128- user ' root'
129- permissionGroup ' root'
130- fileMode = 0644
131- }
132-
133- from(' pkg' ) {
134- into ' /etc/sysconfig'
135- include " ${ project.name} "
136- user ' root'
137- permissionGroup ' root'
138- fileMode = 0644
139- fileType CONFIG | NOREPLACE
140- }
132+ from(' pkg' ) {
133+ into ' /etc/sysconfig'
134+ include " ${ project.name} "
135+ user ' root'
136+ permissionGroup ' root'
137+ fileMode = 0644
138+ fileType CONFIG | NOREPLACE
141139 }
140+ }
142141}
0 commit comments