Skip to content

Gradle and Java builds ​

The CLI controls the MCFPP build. Gradle resolves MNI Java dependencies, compiles Java, and runs tests. mcfpp init demo --mni creates the user configuration.

Project files ​

File or directoryPurpose
mcfpp.tomlProject and MNI configuration
mcfpp-packages.jsonMCFPP and Java dependency declarations
src/main/javaMNI implementations
src/test/javaJUnit tests
.mcfpp/gradleGradle project generated by the CLI
build/.mcfpp/mniJava build output

The CLI generates Gradle files when it prepares MNI. Keep custom settings in your project's extension scripts.

Add a Java dependency ​

This coordinate identifies a public Java library:

sh
mcfpp add --mni org.apache.commons:commons-lang3:3.14.0
mcfpp build
mcfpp test

Use a configuration for test dependencies:

sh
mcfpp add --mni org.junit.jupiter:junit-jupiter:5.10.1 --configuration testImplementation

Configure an extension script ​

mcfpp.toml:

toml
[mni]
enabled = true
repositories = ["https://repo.maven.apache.org/maven2/"]
extensions = ["mni.gradle.kts"]

Create mni.gradle.kts in the project root:

kotlin
tasks.withType<JavaCompile>().configureEach {
    options.encoding = "UTF-8"
}

tasks.withType<Test>().configureEach {
    testLogging {
        events("passed", "failed", "skipped")
    }
}

Declare extra Gradle plugins by ID and version in [mni.plugins]. IDEA synchronization reads the source directories and dependencies after extensions apply.

JDK and repeatable builds ​

MNI builds use JDK 21. The CLI checks MCFPP_JAVA_HOME, JDK21_HOME, JAVA_HOME, and the current Java installation in that order.

Prepare dependencies online before a cached build:

sh
mcfpp install
mcfpp build --locked --offline

--locked uses existing valid lockfiles. --offline uses cached Gradle files and dependencies. mcfpp test runs Java tests. src/test/mcfpp is reserved for source tests.