Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue1973 Add gradle tasks to generate Deb and RPM packages #1974

Merged
merged 17 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
134 changes: 134 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ buildscript {

plugins {
id 'org.ajoberstar.grgit' version '3.0.0'
id 'nebula.ospackage' version '9.1.1'
}

ext {
Expand Down Expand Up @@ -86,6 +87,10 @@ def buildAliases = [
'packageAllJars',
'compileUmpleSelf',
'deployUmpleonline'
],
'genPackages' : [
'packageDeb',
'packageRpm'
]
]
def expandedTaskList = []
Expand Down Expand Up @@ -549,6 +554,135 @@ task packageAllJars {
dependsOn packageRunner
}

// =======
// Generate Deb/RPM packages
// =======

// Generate options text from help message
task genOptions(type:Exec) {
workingDir "${rootProject.projectDir.toString()}/dist/"
commandLine 'java', '-jar', 'umple.jar', '-help'
standardOutput = new ByteArrayOutputStream()
doLast {
def strings = standardOutput.toString().split('-----------')
def options = ""
if (strings.size() > 1) {
options = strings[1]
}

for (line in options.split('\n')) {
line = line.trim()

if (line.startsWith('-')) {
if (!manOptions.isEmpty())
genOptions.ext.manOptions += '\n.PP\n\\fB\\'

def tokens = ""
if (line.contains(', -'))
tokens = line.split('(?<!,)\\s+', 2)
else
tokens = line.split('\\s+', 2)

if (tokens.size() > 1) {
genOptions.ext.manOptions += tokens[0].trim()
genOptions.ext.manOptions += '\\FR\n.IP\n'
genOptions.ext.manOptions += tokens[1].trim() + ' '
}

} else {
genOptions.ext.manOptions += line + ' '
}
}
genOptions.ext.manOptions += '\n.PP\n'
}
}

genOptions.ext.manOptions = ""

// Create man page file from template with updated options
task genManpage(dependsOn: genOptions, type: Copy) {
from "${rootProject.projectDir.toString()}/dev-tools/files/template.1"
into "${rootProject.projectDir.toString()}/dev-tools/files/"
rename { 'umple.1' }

doLast {
def file = new File("${rootProject.projectDir.toString()}/dev-tools/files/umple.1")
file.text = file.text.replace('.SH OPTIONS', '.SH OPTIONS' + genOptions.ext.manOptions)
ant.gzip(src: "${rootProject.projectDir.toString()}/dev-tools/files/umple.1", zipfile: "${rootProject.projectDir.toString()}/dev-tools/files/umple.1.gz")
}
}

// Create DEB package
task packageDeb(dependsOn: genManpage, type: Deb) {
packageName = 'umple'
packageDescription = 'Modeling tool/programming language that enables Model-Oriented Programming'
maintainer = 'Umple Team <umple-help@googlegroups.com>'
url = 'https://www.umple.org'
version = "${rootProject.ext.umpleMajorVersion}"
release = 1
arch= 'all'

requires('default-jre-headless')

from("${rootProject.projectDir.toString()}/dist/") {
include "umple-*.jar"
into 'usr/local/lib/umple'
rename {'umple.jar'}
}
from("${rootProject.projectDir.toString()}/dev-tools/files/umple") {
into 'usr/local/bin'
fileMode 0550
}
from("${rootProject.projectDir.toString()}/dev-tools/files/copyright") {
into 'usr/share/doc/umple'
}
from("${rootProject.projectDir.toString()}/README.md") {
into 'usr/share/doc/umple'
}
from("${rootProject.projectDir.toString()}/dev-tools/files/umple.1.gz") {
into 'usr/share/man/man1'
}
}

// Create RPM package
task packageRpm(dependsOn: genManpage, type: Rpm) {
packageName = 'umple'
packageDescription = 'Modeling tool/programming language that enables Model-Oriented Programming'
maintainer = 'Umple Team <tcltcl@uottawa.ca>'
url = 'https://www.umple.org'
version = "${rootProject.ext.umpleMajorVersion}"
release = 1
arch = 'noarch'
os = 'LINUX'
license = 'MIT'

requires('jre-headless')

from("${rootProject.projectDir.toString()}/dist/") {
include "umple-*.jar"
into 'usr/local/lib/umple'
rename {'umple.jar'}
}
from("${rootProject.projectDir.toString()}/dev-tools/files/umple") {
into 'usr/local/bin'
fileMode 0550
}
from("${rootProject.projectDir.toString()}/dev-tools/files/copyright") {
addParentDirs = false
into 'usr/share/doc/umple'
}
from("${rootProject.projectDir.toString()}/README.md") {
addParentDirs = false
into 'usr/share/doc/umple'
}
from("${rootProject.projectDir.toString()}/dev-tools/files/umple.1.gz") {
addParentDirs = false
into 'usr/share/man/man1'
}
}



// =======
// Build
// =======
Expand Down
27 changes: 27 additions & 0 deletions dev-tools/files/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: umple
Upstream-Contact: Timothy.Lethbridge <Timothy.Lethbridge@uottawa.ca>
Source: https://cruise.umple.org/umple/

Files: *
Copyright: 2018 Umple Model-Oriented Technology

License: Expat

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
44 changes: 44 additions & 0 deletions dev-tools/files/template.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.TH UMPLE "1" "September 2022" "Compiling using /usr/local/lib/umple/umple.jar" "User Commands"
.SH NAME
Umple \- compile or generate code from umple files
.SH SYNOPSIS
.B umple
[\fI\,options\/\fR]... \fI\,filename\/\fR
.SH DESCRIPTION
Umple is a modeling tool/programming language that enables Model-Oriented programming.
.PP
For more detailed information go to https://manual.umple.org
.PP
Example:
.B umple
airline.ump
.PP
Version: 1.31.1
.PP
.SH OPTIONS
.SH "COPYRIGHT"
Copyright (c) 2018 Umple Model-Oriented Technology
.PP
License: MIT
.PP
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
.PP
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
.PP
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
.PP
.SH "SEE ALSO"
https://manual.umple.org

5 changes: 5 additions & 0 deletions dev-tools/files/umple
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
JAR=/usr/local/lib/umple/umple.jar
echo Compiling using $JAR
java -jar $JAR "$@"
exit $?