Skip to content

Commit b55c615

Browse files
committed
chore: minor changes
Signed-off-by: ale5000 <15793015+ale5000-git@users.noreply.github.com>
1 parent 73ac890 commit b55c615

2 files changed

Lines changed: 38 additions & 28 deletions

File tree

build.gradle

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ configure(project) {
3232
lazyVersion = moduleProps.map { it.getProperty('version', 'v0.0.0-unknown').trim().toLowerCase(Locale.ROOT) }
3333
lazyGroup = moduleProps.map { it.getProperty('group', 'unknown').trim() }
3434
lazyProjectId = moduleProps.map { it.getProperty('id', '').trim() }
35+
lazyOsName = providers.systemProperty('os.name')
3536
}
3637

3738
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
@@ -41,32 +42,39 @@ configure(project) {
4142

4243
/* ===HEADER=== */
4344

44-
interface HeaderParams extends FlowParameters {
45+
interface HeaderParams extends ValueSourceParameters {
4546
@Input Property<String> getProjectName()
4647
@Input Property<String> getVersion()
48+
@Input Property<String> getOsName()
4749
}
4850

49-
abstract class HeaderAction implements FlowAction<HeaderParams> {
50-
private static final log = Logging.getLogger(HeaderAction)
51+
abstract class HeaderPrinter implements ValueSource<String, HeaderParams> {
52+
private static final log = Logging.getLogger(HeaderPrinter)
5153

52-
void execute(FlowParameters p) {
54+
@Override String obtain() {
5355
log.lifecycle '=' * 36
54-
log.lifecycle "Project: ${p.projectName.get()}"
55-
log.lifecycle "Version: ${p.version.get()}"
56-
log.lifecycle "OS: ${System.getProperty('os.name')}"
56+
log.lifecycle "Project: ${parameters.projectName.get()}"
57+
log.lifecycle "Version: ${parameters.version.get()}"
58+
log.lifecycle "OS: ${parameters.osName.get()}"
5759
log.lifecycle '=' * 36
60+
''
5861
}
5962
}
6063

61-
services.get(FlowScope).always(HeaderAction) {
62-
parameters.projectName.set(project.name)
63-
parameters.version.set(ext.lazyVersion)
64+
def headerTrigger = providers.of(HeaderPrinter) {
65+
parameters.projectName.set project.name
66+
parameters.version.set ext.lazyVersion
67+
parameters.osName.set ext.lazyOsName
68+
}
69+
70+
gradle.taskGraph.whenReady {
71+
{ headerTrigger.get() }
6472
}
6573

6674
/* ===FUNCTIONS=== */
6775

68-
private static String getScriptExt() {
69-
System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows') ? '.bat' : '.sh'
76+
private Provider<String> getScriptExt() {
77+
ext.lazyOsName.map { it.toLowerCase(Locale.ROOT).contains('windows') ? '.bat' : '.sh' }
7078
}
7179

7280
private Provider<String> getMavenVersion() {
@@ -101,7 +109,7 @@ private Provider<String> getZipName(String variant = '*') {
101109
if(!keystorePropsFile.exists()) return
102110
if(android == null) throw new GradleException('android is null inside configureSigning()')
103111
104-
println 'Signed build'
112+
logger.lifecycle 'Signed build'
105113
106114
Properties keystoreProps = new Properties()
107115
keystoreProps.load(new FileInputStream(keystorePropsFile))
@@ -132,7 +140,7 @@ private Provider<String> getZipName(String variant = '*') {
132140
/* ===BLOCKS=== */
133141

134142
base {
135-
archivesName.set(getProjectId())
143+
archivesName.set getProjectId()
136144
}
137145

138146
project.afterEvaluate {
@@ -183,14 +191,13 @@ tasks.register('distClean') {
183191
dependsOn tasks.named('clean'), tasks.named('cleanCache')
184192

185193
doLast {
186-
def gitDir = layout.projectDirectory.dir('.git').asFile
187-
if(gitDir.exists()) {
194+
if (layout.projectDirectory.dir('.git').asFile.exists()) {
188195
exec {
189196
commandLine 'git', 'clean', '-xdf'
190197
ignoreExitValue = true
191198
}
192199
} else {
193-
logger.warn('WARNING: Skipping git clean: .git directory not found.')
200+
logger.warn 'WARNING: Skipping git clean: .git directory not found.'
194201
}
195202
}
196203
}
@@ -211,15 +218,15 @@ tasks.register('buildOta', Exec) {
211218
outputs.file(layout.buildDirectory.file(getZipName('full')))
212219

213220
workingDir = layout.projectDirectory
214-
executable = layout.projectDirectory.file("build${getScriptExt()}")
221+
executable = "${-> layout.projectDirectory.file("build${getScriptExt().get()}") }"
215222

216223
environment([
217224
'BUILD_TYPE': 'full',
218225
'NO_PAUSE' : '1'
219226
])
220227

221228
doFirst {
222-
println 'Building the flashable zip with Gradle...'
229+
logger.lifecycle 'Building the flashable zip with Gradle...'
223230
}
224231
}
225232

@@ -239,15 +246,15 @@ tasks.register('buildOtaOSS', Exec) {
239246
outputs.file(layout.buildDirectory.file(getZipName('oss')))
240247

241248
workingDir = layout.projectDirectory
242-
executable = layout.projectDirectory.file("build${getScriptExt()}")
249+
executable = "${-> layout.projectDirectory.file("build${getScriptExt().get()}") }"
243250

244251
environment([
245252
'BUILD_TYPE': 'oss',
246253
'NO_PAUSE' : '1'
247254
])
248255

249256
doFirst {
250-
println 'Building the flashable zip (open-source components only) with Gradle...'
257+
logger.lifecycle 'Building the flashable zip (open-source components only) with Gradle...'
251258
}
252259
}
253260

@@ -288,7 +295,7 @@ tasks.named('wrapper') {
288295
distributionSha256Sum = gradleSha256Sum
289296

290297
doFirst {
291-
logger.lifecycle("Gradle: ${gradleVersionTarget}")
298+
logger.lifecycle "Gradle: ${gradleVersionTarget}"
292299
}
293300
}
294301

settings.gradle

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ pluginManagement {
88
99
plugins { id 'com.gradle.develocity' }
1010
11-
develocity.buildScan {
12-
termsOfUseUrl.set 'https://gradle.com/help/legal-terms-of-use'
13-
termsOfUseAgree.set 'yes'
14-
publishing.onlyIf { providers.environmentVariable('UPLOAD_BUILD_SCAN').getOrElse('').toBoolean() }
15-
}
11+
rootProject.name = 'Google sync add-on'
1612
17-
rootProject.name = 'microG unofficial installer'
13+
// Initialize the provider early to ensure compatibility with the Gradle configuration cache
14+
providers.environmentVariable('UPLOAD_BUILD_SCAN').with { uploadBuildScan ->
15+
develocity.buildScan {
16+
termsOfUseUrl.set 'https://gradle.com/help/legal-terms-of-use'
17+
termsOfUseAgree.set 'yes'
18+
publishing.onlyIf { uploadBuildScan.getOrElse('').toBoolean() }
19+
}
20+
}

0 commit comments

Comments
 (0)