Skip to content

Commit

Permalink
Implement support for version catalogs using DependencyCollectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
marchermans committed Apr 28, 2024
1 parent d0e590b commit 260b3d4
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 14 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ group=net.neoforged.gradle
java_version=8

#Dependency versions
groovy_version=3.0.21
groovy_version=3.0.17
commons_io_version=2.11.0
commons_codec_version=1.15
gson_version=2.9.0
Expand All @@ -36,4 +36,4 @@ spock_version=2.1
spock_groovy_version=3.0
mockito_version=4.11.0
jimfs_version=1.2
trainingwheels_version=1.0.42
trainingwheels_version=1.0.43
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-rc-1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ pluginManagement {
repositories {
gradlePluginPortal()
}

includeBuild '../TrainingWheels'
}

plugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ class RunTests extends BuilderBasedTestSpecification {
injectIntoAllProject = true;
}

@Override
protected File getTestTempDirectory() {
return new File("build/runsTest");
}

def "userdev supports custom run dependencies"() {
given:
def project = create("run_with_custom_dependencies", {
Expand All @@ -37,24 +32,147 @@ class RunTests extends BuilderBasedTestSpecification {
runs {
client {
dependencies {
runtime 'org.jgrapht:jgrapht:1.5.1'
runtime 'org.jgrapht:jgrapht-core:+'
}
modSource project.sourceSets.main
}
}
""")
it.withToolchains()
})

when:
def run = project.run {
it.tasks(':writeMinecraftClasspathClient')
}

then:
run.task(':writeMinecraftClasspathClient').outcome == TaskOutcome.SUCCESS

def neoformDir = run.file(".gradle/configuration/neoForm")
def versionedNeoformDir = neoformDir.listFiles()[0]
def stepsDir = new File(versionedNeoformDir, "steps")
def stepDir = new File(stepsDir, "writeMinecraftClasspathClient")
def classpathFile = new File(stepDir, "classpath.txt")

classpathFile.exists()

classpathFile.text.contains("org.jgrapht/jgrapht-core")
}

def "userdev supports custom run dependencies from configuration"() {
given:
def project = create("run_with_custom_dependencies_from_configuration", {
it.build("""
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
mavenCentral()
}
configurations {
runRuntime
}
dependencies {
implementation 'net.neoforged:neoforge:+'
runRuntime 'org.jgrapht:jgrapht-core:+'
}
runs {
client {
dependencies {
runtime project.configurations.runRuntime
}
modSource project.sourceSets.main
}
}
""")
it.withToolchains()
it.maxMemory("4g")
})

when:
def run = project.run {
it.tasks(':writeMinecraftClasspathClient')
it.debug()
}

then:
run.task(':writeMinecraftClasspathClient').outcome == TaskOutcome.SUCCESS

def neoformDir = run.file(".gradle/configuration/neoForm")
def versionedNeoformDir = neoformDir.listFiles()[0]
def stepsDir = new File(versionedNeoformDir, "steps")
def stepDir = new File(stepsDir, "writeMinecraftClasspathClient")
def classpathFile = new File(stepDir, "classpath.txt")

classpathFile.exists()

classpathFile.text.contains("org.jgrapht/jgrapht-core")
}

def "userdev supports custom run dependencies from catalog"() {
given:
def project = create("run_with_custom_dependencies_from_configuration", {
it.file("gradle/libs.versions.toml",
"""
[libraries]
jgrapht = { group = "org.jgrapht", name = "jgrapht-core", version = "+" }
""".trim())

it.build("""
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
mavenCentral()
}
configurations {
runRuntime
}
dependencies {
implementation 'net.neoforged:neoforge:+'
}
runs {
client {
dependencies {
runtime libs.jgrapht
}
modSource project.sourceSets.main
}
}
""")
it.withToolchains()
})

when:
def run = project.run {
it.tasks(':writeMinecraftClasspathClient')
}

then:
run.task(':writeMinecraftClasspathClient').outcome == TaskOutcome.SUCCESS

def neoformDir = run.file(".gradle/configuration/neoForm")
def versionedNeoformDir = neoformDir.listFiles()[0]
def stepsDir = new File(versionedNeoformDir, "steps")
def stepDir = new File(stepsDir, "writeMinecraftClasspathClient")
def classpathFile = new File(stepDir, "classpath.txt")

classpathFile.exists()

classpathFile.text.contains("org.jgrapht/jgrapht-core")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public void run() throws Exception {
.collect(Collectors.toSet()),
StandardCharsets.UTF_8
);

getLogger().lifecycle("Serialized classpath to: {}", out.getAbsolutePath());
}

@InputFiles
Expand Down

0 comments on commit 260b3d4

Please sign in to comment.