-
Notifications
You must be signed in to change notification settings - Fork 132
/
build.gradle
223 lines (200 loc) · 7.36 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
plugins {
id 'java'
id 'maven-publish'
id 'java-gradle-plugin'
id 'com.gradle.plugin-publish' version '1.1.0'
id 'io.codearte.nexus-staging' version '0.21.2'
id 'eclipse'
id 'de.undercouch.download' version '5.0.4'
id 'signing'
}
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
gradlePlugin {
website = 'http://github.com/fvarrui/JavaPackager'
vcsUrl = 'http://github.com/fvarrui/JavaPackager.git'
description = 'Packages Java applications as native Windows, MacOS or GNU/Linux executables and creates installers for them'
plugins {
create("javaPackagerPlugin") {
id = 'io.github.fvarrui.javapackager.plugin'
displayName = 'JavaPackager'
implementationClass = 'io.github.fvarrui.javapackager.gradle.PackagePlugin'
tags.set(['java', 'packager', 'gradle-plugin', 'maven-plugin', 'native', 'installer', 'debian-packages', 'rpm-packages', 'dmg', 'maven', 'gradle', 'distribution', 'javapackager', 'linux-executables', 'deb', 'rpm', 'native-windows', 'java-applications', 'pkg', 'msi'])
}
}
}
configurations {
mavenEmbedder
}
dependencies {
implementation 'org.apache.maven:maven-plugin-api:3.6.0'
implementation 'org.codehaus.plexus:plexus-utils:3.5.1'
implementation 'org.twdata.maven:mojo-executor:2.3.0'
implementation 'commons-io:commons-io:2.16.1'
implementation 'org.apache.commons:commons-lang3:3.9'
implementation 'org.apache.commons:commons-collections4:4.3'
implementation 'org.apache.commons:commons-compress:1.21'
implementation 'org.apache.velocity:velocity-engine-core:2.3'
implementation 'org.vafer:jdeb:1.9'
implementation 'net.jsign:jsign-core:6.0'
implementation 'org.redline-rpm:redline:1.2.10'
implementation 'edu.sc.seis.launch4j:launch4j:3.0.5'
testImplementation 'junit:junit:4.13.1'
compileOnly 'org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.0'
mavenEmbedder 'org.apache.maven:maven-embedder:3.6.0'
mavenEmbedder 'org.apache.maven:maven-compat:3.6.0'
mavenEmbedder 'org.slf4j:slf4j-simple:1.7.30'
mavenEmbedder 'org.eclipse.aether:aether-connector-basic:1.1.0'
mavenEmbedder 'org.eclipse.aether:aether-transport-wagon:1.1.0'
mavenEmbedder 'org.apache.maven.wagon:wagon-http:3.4.1'
mavenEmbedder 'org.apache.maven.wagon:wagon-provider-api:3.4.1'
}
group = 'io.github.fvarrui'
version = '1.7.6'
description = 'Hybrid Maven/Gradle plugin to package Java applications as native Windows, Mac OS X or GNU/Linux executables and create installers for them'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
compileJava.options.encoding = 'UTF-8'
// suppress javadoc warnings
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
java {
withSourcesJar()
withJavadocJar()
}
// OSSRH publication
publishing {
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
name = "OSSRH"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = project.findProperty("ossrhUsername") ?: ''
password = project.findProperty("ossrhPassword") ?: ''
}
}
}
publications {
pluginMaven(MavenPublication) {
def directory = buildDir.canonicalPath
def outputDirectory = compileJava.destinationDirectory.asFile.get().canonicalPath
pom.withXml {
asNode().appendNode('build')
.with {
appendNode('directory', directory)
appendNode('outputDirectory', outputDirectory)
}
asNode().appendNode('repositories').appendNode('repository')
.with {
appendNode('id', 'gradle')
appendNode('name', 'Gradle Plugin Portal')
appendNode('url', 'https://plugins.gradle.org/m2/')
}
}
pom {
name = project.name
groupId = project.group
artifactId = project.name
packaging = 'maven-plugin'
}
}
}
afterEvaluate {
publications {
withType(MavenPublication) {
// customize all publications here
pom {
version = project.version
description = project.description
url = 'https://github.com/fvarrui/JavaPackager'
scm {
connection = 'scm:git:git://github.com/fvarrui/JavaPackager.git'
developerConnection = 'scm:git:[email protected]:fvarrui/fvarrui.git'
url = 'https://github.com/fvarrui/JavaPackager'
}
licenses {
license {
name = 'GPL-v3.0'
url = 'http://www.gnu.org/licenses/gpl-3.0.txt'
distribution = 'repo'
}
}
developers {
developer {
id = 'fvarrui'
name = 'Francisco Vargas Ruiz'
url = 'https://github.com/fvarrui'
}
}
}
}
}
}
}
// runs the plugin description generator
tasks.register('generatePluginDescriptor', JavaExec) {
dependsOn compileJava
def pluginDescriptorFile = new File(project.compileJava.destinationDirectory.asFile.get(), 'META-INF/maven/plugin.xml')
// FIXME: this does not seem to be working
inputs.files project.compileJava.outputs.files
outputs.file pluginDescriptorFile
classpath = configurations.mavenEmbedder
mainClass = 'org.apache.maven.cli.MavenCli'
systemProperties['maven.multiModuleProjectDirectory'] = projectDir
args = [
'--errors',
'--batch-mode',
'--file', generatePomFileForPluginMavenPublication.destination,
'org.apache.maven.plugins:maven-plugin-plugin:3.9.0:descriptor',
'-Dproject.build.sourceEncoding=' + compileJava.options.encoding
]
doLast {
assert pluginDescriptorFile.file, "${pluginDescriptorFile.canonicalPath}: was not generated"
logger.info("Plugin descriptor is generated in ${pluginDescriptorFile.canonicalPath}")
}
}
generatePluginDescriptor.dependsOn(generatePomFileForPluginMavenPublication)
project.classes.dependsOn(generatePluginDescriptor)
project.validatePlugins.dependsOn(generatePluginDescriptor)
publishToMavenLocal.dependsOn(build)
// Signature of publication
signing {
setRequired {
// signing is only required if the artifacts are to be published
gradle.taskGraph.allTasks.any { it instanceof PublishToMavenRepository }
}
sign publishing.publications.pluginMaven
}
nexusStaging {
username = project.findProperty('ossrhUsername') ?: ''
password = project.findProperty('ossrhPassword') ?: ''
}
tasks.register('updateUniversalJavaApplicationStub', Download) {
def version = '20230601.235708'
group 'Update assets'
description 'Downloads compiled and scripted versions of universalJavaApplicationStub to src/main/resources/mac overriding the existing ones.'
src([
"https://github.com/fvarrui/universalJavaApplicationStub/releases/download/${version}/universalJavaApplicationStub.sh",
"https://github.com/fvarrui/universalJavaApplicationStub/releases/download/${version}/universalJavaApplicationStub.x86_64",
"https://github.com/fvarrui/universalJavaApplicationStub/releases/download/${version}/universalJavaApplicationStub.arm64",
"https://github.com/fvarrui/universalJavaApplicationStub/releases/download/${version}/universalJavaApplicationStub"
])
dest file('src/main/resources/mac')
overwrite true
}
tasks.register('updateWhyJavaLauncher', Download) {
def version = '1.1.2'
group 'Update assets'
description 'Downloads JavaLauncher.exe to src/main/resources/windows and overwrites the existing one.'
src([
"https://github.com/AstroImageJ/Why/releases/download/${version}/JavaLauncher.exe"
])
dest file('src/main/resources/windows')
overwrite true
}