-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
199 lines (174 loc) · 5.56 KB
/
build.gradle
File metadata and controls
199 lines (174 loc) · 5.56 KB
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
plugins {
id 'java'
id 'application'
}
group = 'br.com.bibyte'
version = (findProperty('projVersion') ?: '1.9.3')
java {
toolchain {
def targetVer = (findProperty('javaTarget') ?: '25') as String
languageVersion = JavaLanguageVersion.of(Integer.parseInt(targetVer))
}
}
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.3'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.3'
}
test {
useJUnitPlatform()
}
application {
// Gradle 7/8 style
mainClass = 'bitbyte.MyJFrame'
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
jar {
manifest {
attributes(
'Main-Class': 'bitbyte.MyJFrame'
)
}
}
// Packaging helpers using jpackage (requires JDK with jpackage on PATH)
def appName = 'BiByte'
def mainClassFqn = 'bitbyte.MyJFrame'
def jarFile = { "${appName}-${project.version}.jar" }
tasks.register('packageWinExe', Exec) {
dependsOn(tasks.named('build'))
commandLine 'jpackage',
'--type', 'exe',
'--name', appName,
'--app-version', project.version,
'--input', 'build/libs',
'--main-jar', jarFile(),
'--main-class', mainClassFqn,
'--dest', 'out/win',
'--icon', 'process-icon1.ico'
}
tasks.register('packageWinMsi', Exec) {
dependsOn(tasks.named('build'))
commandLine 'jpackage',
'--type', 'msi',
'--name', appName,
'--app-version', project.version,
'--input', 'build/libs',
'--main-jar', jarFile(),
'--main-class', mainClassFqn,
'--dest', 'out/win',
'--icon', 'process-icon1.ico'
}
tasks.register('packageMacDmg', Exec) {
dependsOn(tasks.named('build'))
commandLine 'jpackage',
'--type', 'dmg',
'--name', appName,
'--app-version', project.version,
'--input', 'build/libs',
'--main-jar', jarFile(),
'--main-class', mainClassFqn,
'--dest', 'out/mac',
'--icon', 'process-icon1.ico'
}
tasks.register('packageDeb', Exec) {
dependsOn(tasks.named('build'))
commandLine 'jpackage',
'--type', 'deb',
'--name', appName,
'--app-version', project.version,
'--input', 'build/libs',
'--main-jar', jarFile(),
'--main-class', mainClassFqn,
'--dest', 'out/deb',
'--icon', 'process-icon1.ico'
}
// Portable JRE + slim EXE (Windows, Launch4j)
def isWindows = System.getProperty('os.name').toLowerCase().contains('win')
tasks.register('jlinkWin', Exec) {
group = 'distribution'
description = 'Create portable JRE in out/win/jre (Windows) using jlink.'
onlyIf { isWindows }
environment 'JAVA_HOME', System.getenv('JAVA_HOME')
commandLine 'powershell', '-NoProfile', '-ExecutionPolicy', 'Bypass', './scripts/jlink-win.ps1'
}
tasks.register('packageWinExeSlim', Exec) {
group = 'distribution'
description = 'Build slim Windows EXE via Launch4j using portable JRE (out/win/jre).'
onlyIf { isWindows }
dependsOn(tasks.named('build'))
dependsOn(tasks.named('jlinkWin'))
environment 'VERSION', project.version
commandLine 'powershell', '-NoProfile', '-ExecutionPolicy', 'Bypass', './scripts/launch4j-win.ps1'
}
tasks.register('packageWinSlimAll') {
group = 'distribution'
description = 'One-shot: build, jlink (portable JRE), and Launch4j EXE (Windows).'
onlyIf { isWindows }
dependsOn(tasks.named('build'))
dependsOn(tasks.named('jlinkWin'))
dependsOn(tasks.named('packageWinExeSlim'))
}
// Collect local release assets into release/<version>
tasks.register('prepareRelease') {
group = 'distribution'
description = 'Collect JAR and native packages into release/<version> with BiByte-latest.jar copy.'
dependsOn(tasks.named('build'))
doLast {
def ver = (project.findProperty('releaseVersion') ?: project.version).toString()
def dest = file("release/${ver}")
dest.mkdirs()
def builtJar = file("build/libs/${appName}-${project.version}.jar")
if (builtJar.exists()) {
copy { from builtJar; into dest }
copy { from builtJar; into dest; rename { String n -> 'BiByte-latest.jar' } }
}
[ 'out/win', 'out/mac', 'out/deb' ].each { p ->
def d = file(p)
if (d.exists()) {
copy { from d; into new File(dest, new File(p).name) }
}
}
def notes = new File(dest, 'RELEASE-NOTES-TEMPLATE.md')
if (!notes.exists()) {
notes.text = """
# BiByte ${ver}
## Highlights
- Conversões BitByte/PTNO estáveis
- Empacotamento: JAR, Windows EXE/MSI, macOS DMG, Debian DEB (opcionais)
## Artefatos
- JAR: BiByte-${ver}.jar
- Latest alias: BiByte-latest.jar
- Windows: out/win/* (se gerado)
- macOS: out/mac/* (se gerado)
- Debian: out/deb/* (se gerado)
## Como usar
- Java: `java -jar BiByte-${ver}.jar`
- Windows EXE (slim): executar BiByte-${ver}.exe (requer pasta jre/ ao lado)
- Windows MSI/EXE (auto-contidos): instalar/rodar
""".stripIndent()
}
}
}
sourceSets {
main {
java {
setSrcDirs(['src'])
}
resources {
setSrcDirs([])
}
}
test {
java {
setSrcDirs(['test'])
}
resources {
setSrcDirs([])
}
}
}