Replace OSS licenses plugin with Licensee and some manually done UI.

This should fix both configuration cache and reproducible F-droid builds.

Cleanup and remove gplay/fdroid diff on open source licenses.

Co-authored by @jmartinesp
This commit is contained in:
Benoit Marty 2024-09-02 20:02:06 +02:00 committed by Benoit Marty
parent 941c762cff
commit 965e445d04
38 changed files with 983 additions and 309 deletions

View file

@ -0,0 +1,55 @@
/*
* Copyright (c) 2024 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package extension
import java.io.File
import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
@CacheableTask
abstract class AssetCopyTask : DefaultTask() {
@get:OutputDirectory
abstract val outputDirectory: DirectoryProperty
@get:PathSensitive(PathSensitivity.RELATIVE)
@get:InputFile
abstract val inputFile: RegularFileProperty
@get:Input
abstract val targetFileName: Property<String>
@TaskAction
fun action() {
println("Copying ${inputFile.get()} to ${outputDirectory.get().asFile}/${targetFileName.get()}")
inputFile.get().asFile.copyTo(
target = File(
outputDirectory.get().asFile,
targetFileName.get(),
),
overwrite = true,
)
}
}

View file

@ -17,13 +17,35 @@
package extension
import org.gradle.api.Project
import org.gradle.api.provider.ValueSource
import org.gradle.api.provider.ValueSourceParameters
import org.gradle.process.ExecOperations
import java.io.ByteArrayOutputStream
import java.io.IOException
import javax.inject.Inject
private fun Project.runCommand(cmd: String): String {
abstract class GitRevisionValueSource : ValueSource<String, ValueSourceParameters.None> {
@get:Inject
abstract val execOperations: ExecOperations
override fun obtain(): String? {
return execOperations.runCommand("git rev-parse --short=8 HEAD")
}
}
abstract class GitBranchNameValueSource : ValueSource<String, ValueSourceParameters.None> {
@get:Inject
abstract val execOperations: ExecOperations
override fun obtain(): String? {
return execOperations.runCommand("git rev-parse --abbrev-ref HEAD")
}
}
private fun ExecOperations.runCommand(cmd: String): String {
val outputStream = ByteArrayOutputStream()
val errorStream = ByteArrayOutputStream()
project.exec {
exec {
commandLine = cmd.split(" ")
standardOutput = outputStream
errorOutput = errorStream
@ -34,7 +56,3 @@ private fun Project.runCommand(cmd: String): String {
}
return String(outputStream.toByteArray()).trim()
}
fun Project.gitRevision() = runCommand("git rev-parse --short=8 HEAD")
fun Project.gitBranchName() = runCommand("git rev-parse --abbrev-ref HEAD")