Skip to content

Commit

Permalink
Migrate to gradle.kts (Gradle Kotlin DSL) (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
will-molloy committed Jul 2, 2023
1 parent 155d0b6 commit bc8f84b
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 184 deletions.
27 changes: 0 additions & 27 deletions auto-handbrake-cfr/build.gradle

This file was deleted.

37 changes: 37 additions & 0 deletions auto-handbrake-cfr/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import org.ajoberstar.grgit.Grgit
import org.unbrokendome.gradle.plugins.testsets.dsl.testSets

plugins {
id("org.unbroken-dome.test-sets") version "4.0.0"
id("com.google.cloud.tools.jib") version "3.3.2"
id("org.ajoberstar.grgit") version "5.2.0"
}

testSets {
create("integrationTest")
}

jib {
from {
image = "docker://handbrake-java-base"
}
to {
image = "ghcr.io/will-molloy/auto-handbrake-cfr"
}
container {
mainClass = "com.willmolloy.handbrake.cfr.Main"
args = listOf("/input", "/output", "/archive")
creationTime.set(gitCommitTime())
jvmFlags = listOf("--enable-preview")
}
}

fun gitCommitTime(): String {
Grgit.open(mapOf("currentDir" to rootProject.rootDir)).use {
return it.head().dateTime.toInstant().toString()
}
}

dependencies {
implementation(project(":auto-handbrake-core"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Random;
import java.util.stream.Stream;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -37,10 +38,11 @@ abstract class BaseIntegrationTest {
protected static Path encodedVideo1;
protected static Path unencodedVideo2;
protected static Path encodedVideo2;
private static final Random RANDOM = new Random();

@BeforeAll
static void setUp() throws Exception {
testParentDirectory = Path.of("Test");
testParentDirectory = Path.of("out/Test" + RANDOM.nextLong());
unencodedVideo1 = Path.of(Resources.getResource("Big_Buck_Bunny_360_10s_1MB.mp4").toURI());
encodedVideo1 = Path.of(Resources.getResource("Big_Buck_Bunny_360_10s_1MB.cfr.mp4").toURI());
unencodedVideo2 = Path.of(Resources.getResource("Big_Buck_Bunny_360_10s_2MB.mp4").toURI());
Expand Down
File renamed without changes.
153 changes: 0 additions & 153 deletions build.gradle

This file was deleted.

128 changes: 128 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import com.diffplug.gradle.spotless.SpotlessExtension
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsExtension
import com.github.spotbugs.snom.SpotBugsTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

logger.quiet("Java version: ${JavaVersion.current()}")
logger.quiet("Gradle version: ${gradle.gradleVersion}")

plugins {
id("java-library")
id("com.diffplug.gradle.spotless") version "6.19.0" apply (false)
id("com.github.spotbugs") version "5.0.14" apply (false)
id("com.asarkar.gradle.build-time-tracker") version "4.3.0"
}

allprojects {
group = "com.willmolloy"
repositories {
mavenCentral()
}
}

subprojects {
apply(plugin = "java")
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
}

apply(plugin = "com.diffplug.spotless")
configure<SpotlessExtension> {
java {
removeUnusedImports()
googleJavaFormat()
}
}

apply(plugin = "checkstyle")
configure<CheckstyleExtension> {
toolVersion = "10.12.0"
configFile = rootProject.file("./checkstyle.xml")
maxErrors = 0
maxWarnings = 0
isIgnoreFailures = false
}

apply(plugin = "com.github.spotbugs")
configure<SpotBugsExtension> {
effort.set(Effort.MAX)
reportLevel.set(Confidence.LOW)
ignoreFailures.set(false)
excludeFilter.set(rootProject.file("./spotbugs-exclude.xml"))
}
tasks.withType<SpotBugsTask> {
reports.create("html").required.set(true)
}

tasks.withType<Test> {
maxParallelForks = Runtime.getRuntime().availableProcessors()
useJUnitPlatform()
testLogging {
events = setOf(TestLogEvent.FAILED, TestLogEvent.SKIPPED)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
afterSuite(KotlinClosure2({ desc: TestDescriptor, result: TestResult ->
if (desc.parent == null) {
println(
"Results: ${result.resultType} " +
"(${result.testCount} test${if (result.testCount > 1) "s" else ""}, " +
"${result.successfulTestCount} passed, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped)"
)
}
}))
}
finalizedBy(tasks.withType<JacocoReport>())
}

apply(plugin = "jacoco")
tasks.withType<JacocoReport> {
reports {
xml.required.set(true)
}
}

val previewFeatures = listOf("--enable-preview")
tasks.withType<JavaCompile> {
options.compilerArgs = previewFeatures
}
tasks.withType<Test> {
jvmArgs = previewFeatures
}
tasks.withType<JavaExec> {
jvmArgs = previewFeatures
}

dependencies {
val log4jVersion = "2.20.0"
val guavaVersion = "32.0.1-jre"
implementation("org.apache.logging.log4j:log4j-core:$log4jVersion")
implementation("com.github.spotbugs:spotbugs-annotations:4.7.3")
implementation("com.google.guava:guava:$guavaVersion")

val junitVersion = "5.9.3"
val truthVersion = "1.1.5"
val mockitoVersion = "5.4.0"
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
testImplementation("com.google.truth:truth:$truthVersion")
testImplementation("com.google.truth.extensions:truth-java8-extension:$truthVersion")
testImplementation("org.mockito:mockito-core:$mockitoVersion")
testImplementation("org.mockito:mockito-junit-jupiter:$mockitoVersion")
testImplementation("com.google.jimfs:jimfs:1.2")

configurations.all {
exclude("org.assertj")
exclude("junit")
resolutionStrategy {
force("com.google.guava:guava:$guavaVersion") // exclude android version
}
}
}
}
3 changes: 0 additions & 3 deletions settings.gradle

This file was deleted.

3 changes: 3 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rootProject.name = "auto-handbrake-encoding"
include("auto-handbrake-core")
include("auto-handbrake-cfr")

0 comments on commit bc8f84b

Please sign in to comment.