Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup cross-project dependencies #1923

Merged
merged 5 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private NeoDevConfigurations(Project project) {

// Libraries & module libraries & MC dependencies need to be available when compiling in NeoDev,
// and on the runtime classpath too for IDE debugging support.
configurations.getByName("implementation").extendsFrom(libraries, moduleLibraries, neoFormDependencies);
configurations.getByName("api").extendsFrom(libraries, moduleLibraries, neoFormDependencies);

// runtimeClasspath is our reference for all MC dependency versions.
// Make sure that any classpath we resolve is consistent with it.
Expand Down
8 changes: 7 additions & 1 deletion projects/neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ javaComponent.withVariantsFromConfiguration(configurations.runtimeElements) {

// Resolvable configurations only
configurations {
runtimeElements {
attributes {
// Add an attribute to disambiguate with the universalJar
attribute(Attribute.of("net.neoforged.neoforge.includes-minecraft", Boolean), true)
}
}
modDevBundle {
canBeDeclared = false
canBeResolved = false
Expand Down Expand Up @@ -313,7 +319,7 @@ configurations {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, JavaVersion.current().majorVersion.toInteger())
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, java_version as Integer)
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements, LibraryElements.JAR))
}
// Publish it
Expand Down
14 changes: 1 addition & 13 deletions testframework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ java.withSourcesJar()
apply plugin : net.neoforged.minecraftdependencies.MinecraftDependenciesPlugin

dependencies {
// TODO: is this leaking in the POM? (most likely yes)
// TODO: does this need to be changed back to runtimeDependencies?
// TODO: should use attributes to resolve the right variant instead of hardcoding
compileOnly project(path: ':neoforge', configuration: 'apiElements')
runtimeOnly project(path: ':neoforge', configuration: 'runtimeElements')
compileOnly project(path: ':neoforge')

compileOnly(platform("org.junit:junit-bom:${project.jupiter_api_version}"))
compileOnly "org.junit.jupiter:junit-jupiter-params"
Expand All @@ -23,14 +19,6 @@ dependencies {
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
}

sourceSets {
main {
// TODO: cursed
compileClasspath += project(':neoforge').sourceSets.main.compileClasspath
runtimeClasspath += project(':neoforge').sourceSets.main.runtimeClasspath
}
}

license {
header = rootProject.file('codeformat/HEADER.txt')
include '**/*.java'
Expand Down
13 changes: 11 additions & 2 deletions tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sourceSets {
}

dependencies {
implementation project(path: ':neoforge', configuration: 'runtimeElements')
implementation(neoforgeProject)
implementation(testframeworkProject)

junitImplementation(platform("org.junit:junit-bom:${project.jupiter_api_version}"))
Expand All @@ -31,12 +31,21 @@ dependencies {

junitImplementation("org.assertj:assertj-core:${project.assertj_core}")
junitImplementation "net.neoforged.fancymodloader:junit-fml:${project.fancy_mod_loader_version}"
junitImplementation project(path: ':neoforge', configuration: 'runtimeElements')
junitImplementation(neoforgeProject)
junitImplementation(testframeworkProject)

compileOnly "org.jetbrains:annotations:${project.jetbrains_annotations_version}"
}

// Select runtimeElements rather than universalJar from the neoforge project
sourceSets.each {
configurations.named(it.runtimeClasspathConfigurationName) {
attributes {
attribute(Attribute.of("net.neoforged.neoforge.includes-minecraft", Boolean), true)
}
}
}

junitTest {
useJUnitPlatform()
classpath = sourceSets.junit.output + sourceSets.junit.runtimeClasspath
Expand Down
Loading