gradle: JMH plugin, XML test results, add benchmark target

This commit is contained in:
Daniel Langbein 2024-12-09 13:30:18 +00:00
parent 9d67b48215
commit 9a99716a0a
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
3 changed files with 24 additions and 35 deletions

View File

@ -1,13 +1,13 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.7/userguide/building_java_projects.html in the Gradle documentation.
*/
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
application
// JMH Gradle Plugin
id("me.champeau.jmh") version "0.7.2"
}
repositories {
@ -22,7 +22,7 @@ dependencies {
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// This dependency is used by the application.
implementation(libs.guava)
//implementation(libs.guava)
}
// Apply a specific Java toolchain to ease working on different environments.
@ -32,12 +32,29 @@ java {
}
}
application {
// Define the main class for the application.
mainClass = "de.uni_marburg.powersort.App"
// The `application` plugin provides the `JavaExec` task.
// It automatically creates one task of that type called `run`.
// It is not possible to rename it.
// Thus, we remove it and add two custom named `JavaExec` tasks instead.
tasks.getByName("run") {
enabled = false
description = "This task has been disabled. It does nothing o.O"
}
tasks.register<JavaExec>("runCustomBenchmark") {
group = "application"
classpath = sourceSets["main"].runtimeClasspath
mainClass = "de.uni_marburg.powersort.benchmark.Main"
}
tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
reports {
// XML reports for GitLab CI.
junitXml.required.set(true)
// HTML reports to view with a webbrowser.
html.required.set(true)
}
}

View File

@ -1,14 +0,0 @@
/*
* This source file was generated by the Gradle 'init' task
*/
package de.uni_marburg.powersort;
public class App {
public String getGreeting() {
return "Let's bring Powersort to Java!";
}
public static void main(String[] args) {
System.out.println(new App().getGreeting());
}
}

View File

@ -1,14 +0,0 @@
/*
* This source file was generated by the Gradle 'init' task
*/
package de.uni_marburg.powersort;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class AppTest {
@Test void appHasAGreeting() {
App classUnderTest = new App();
assertNotNull(classUnderTest.getGreeting(), "app should have a greeting");
}
}