Caleb Cushing
04/03/2024, 12:14 PMsourceSets {
create("demoServer") {
java {
srcDir("src/demoServer/java")
}
}
}
java {
registerFeature("demoServer") {
usingSourceSet(sourceSets["demoServer"])
}
}
shouldn't I be able to do
dependencies { demoServerImplementation("something") }
because that doesn't compileVampire
04/03/2024, 12:37 PMplugins { ... }
block.
The type-safe accessors are necessary to compile the build script, so things you add in the build script cannot be added without the accessors, so you cannot execute it to know which accessors to generate.
Btw. just creating the source set is enough, as the source dir you configure anyway is the convention.
What you can do is
val demoServerImplementation by configurations.existing
dependencies { demoServerImplementation("something") }
Vampire
04/03/2024, 12:38 PMConfiguration
or Provider<Configuration>
that you then can use in the dependencies
block to declare dependencies.Vampire
04/03/2024, 12:39 PMProvider<Configuration>
though only works in recent Gradle versions and is incubating. So if you are shy to use incubating or are on an older Gradle version, you would use getting
, not existing
so that the variable is of type Configuration
.Caleb Cushing
04/03/2024, 12:39 PMBtw. just creating the source set is enough, as the source dir you configure anyway is the convention.are you saying I can delete code that I currently have?
Vampire
04/03/2024, 12:40 PMsourceSets {
create("demoServer") {
java {
srcDir("src/demoServer/java")
}
}
}
just
sourceSets {
create("demoServer")
}
Vampire
04/03/2024, 12:40 PMval demoServer by sourceSets.creating
Thomas Broyer
04/03/2024, 12:41 PMdependencies {
"demoServerImplementation"("something")
}
though obviously you don't have the benefits of type-safe accessors (i.e. a typo in the configuration name won't be caught in the IDE, only when running Gradle)Vampire
04/03/2024, 12:41 PMval demoServer by sourceSets.creating
java {
registerFeature("demoServer") {
usingSourceSet(demoServer)
}
}
Vampire
04/03/2024, 12:42 PMval demoServer by sourceSets.creating
java {
registerFeature("demoServer") {
usingSourceSet(demoServer)
}
}
val demoServerImplementation by configurations.existing
dependencies { demoServerImplementation("something") }
Caleb Cushing
04/03/2024, 12:45 PMCaleb Cushing
04/03/2024, 12:45 PMCaleb Cushing
04/03/2024, 12:53 PMdemoServerRuntimeOnly(testFixtures(project))
Thomas Broyer
04/03/2024, 12:57 PMtestFixtures(project())
would be "more correct" (I think)Vampire
04/03/2024, 12:57 PMCaleb Cushing
04/03/2024, 12:58 PMCaleb Cushing
04/03/2024, 12:59 PMCaleb Cushing
04/03/2024, 1:00 PMproject()
results in a compile time failureVampire
04/03/2024, 3:34 PMthis isn't a test suite, in fact it has to explicitly not beIt is. The default
test
task is coming from a test
test suite, whether you use the test suite DSL or not.
actually calling it as a functionHow aboutresults in a compile time failureproject()
testFixtures(project(project.path))
?Caleb Cushing
04/03/2024, 3:35 PMdemoServerRuntimeOnly(testFixtures(project))
?Vampire
04/03/2024, 3:35 PMVampire
04/03/2024, 3:36 PMVampire
04/03/2024, 3:37 PMtestFixtures(project)
also works just fine hereVampire
04/03/2024, 3:37 PMCaleb Cushing
04/03/2024, 3:37 PMCaleb Cushing
04/03/2024, 3:38 PMtestFixtures(project)
it seems to work, but sometimes things that seem to work have surprising behavior, or don'tVampire
04/03/2024, 3:38 PMVampire
04/03/2024, 3:39 PMtestFixtures(project)
is exactly right and Thomas was confused by using test suites DSL too much 😄Caleb Cushing
04/03/2024, 3:39 PMtestFixtures(project())
Vampire
04/03/2024, 3:40 PMVampire
04/03/2024, 3:41 PMtestFixtures(project)
or the more verbose testFixtures(project(project.path))
which should do the same in normal dependencies block,
testFixtures(project())
in the test suites DSL dependencies block.Caleb Cushing
04/03/2024, 3:48 PMVampire
04/03/2024, 3:55 PMCaleb Cushing
04/03/2024, 3:56 PMThomas Broyer
04/03/2024, 4:05 PMThomas Broyer
04/03/2024, 4:06 PMproject
vs project()
, I indeed worked quite a bit with testing suites recently 😇 )Caleb Cushing
04/03/2024, 4:07 PM