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

Move test books to the test source directory [Fabric] #428

Open
wants to merge 2 commits into
base: 1.17-fabric
Choose a base branch
from

Conversation

eutro
Copy link

@eutro eutro commented Jul 22, 2021

Equivalent of #427 for Fabric.

This might help IDEs innocently trying to guess where things are supposed to be
@@ -77,6 +77,8 @@ test {
useJUnitPlatform()
}

sourceSets.main.resources.srcDirs(sourceSets.test.resources.srcDirs) // include test books
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. I thought you were going to move the test data to the test sourceset, then remove the ad-hoc exclude directives from the jar task below. Not sure what this change is supposed to do.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way directories are scanned (this on Fabric) requires that book resources are in the same directory as the mod metadata file mods.toml/fabric.mod.json.

So, without code changes, the test resources have to be in the resource dir that the mod metadata file is in.

Some options are:

  • Add test source set resources to the main source set. This still requires the resources to be excluded from the final jar. (current)
  • Make a new source set, include test and main classes and resources, and run from that. Possible, but slightly hacky and loader dependent.
  • Make code changes so books can be scanned in additional directories. Possibly by environmental variables or such.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or you can make the test source set depend on main and run with the test source set when you want the test data

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see much benefit of either of the other approaches compared to what we have now, which is a bit of a hassle to exclude at build time but it works.

Especially now that we have RP-based books, most of our test books should probably be moved there anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants