71 lines
2.4 KiB
Java
71 lines
2.4 KiB
Java
package com.example;
|
|
|
|
import rife.bld.BuildCommand;
|
|
import rife.bld.Project;
|
|
import rife.bld.extension.CompileKotlinOperation;
|
|
|
|
import java.io.File;
|
|
import java.util.List;
|
|
import java.util.logging.ConsoleHandler;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
import static rife.bld.dependencies.Repository.*;
|
|
import static rife.bld.dependencies.Scope.compile;
|
|
import static rife.bld.dependencies.Scope.test;
|
|
|
|
public class ExampleBuild extends Project {
|
|
public ExampleBuild() {
|
|
pkg = "com.example";
|
|
name = "Example";
|
|
mainClass = "com.example.Example";
|
|
version = version(0, 1, 0);
|
|
|
|
javaRelease = 17;
|
|
|
|
downloadSources = true;
|
|
autoDownloadPurge = true;
|
|
|
|
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES);
|
|
|
|
final var kotlin = version(2, 0, 20);
|
|
scope(compile)
|
|
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin));
|
|
scope(test)
|
|
.include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin))
|
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 0)))
|
|
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 0)));
|
|
|
|
// Include the Kotlin source directory when creating or publishing sources Java Archives
|
|
jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin"));
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
// Enable detailed logging for the Kotlin extension
|
|
var level = Level.ALL;
|
|
var logger = Logger.getLogger("rife.bld.extension");
|
|
var consoleHandler = new ConsoleHandler();
|
|
|
|
consoleHandler.setLevel(level);
|
|
logger.addHandler(consoleHandler);
|
|
logger.setLevel(level);
|
|
logger.setUseParentHandlers(false);
|
|
|
|
new ExampleBuild().start(args);
|
|
}
|
|
|
|
@BuildCommand(summary = "Compiles the Kotlin project")
|
|
@Override
|
|
public void compile() throws Exception {
|
|
// The source code located in src/main/kotlin and src/test/kotlin will be compiled
|
|
new CompileKotlinOperation()
|
|
.fromProject(this)
|
|
// .kotlinHome("path/to/kotlin")
|
|
// .kotlinc("path/to/kotlinc")
|
|
.execute();
|
|
|
|
// var op = new CompileKotlinOperation().fromProject(this);
|
|
// op.compileOptions().verbose(true);
|
|
// op.execute();
|
|
}
|
|
}
|