Jump to content

Recommended Posts

Posted

Hi,

 

by default, resources are load from path src/main/resources but I would like to have another location containing resource files, e.g. generated/resources. I need to separate this because in generated folder I have a lot of files and while development I often change them, rename and so on, so I can easely loose track of files which are not used anymore, but are still there. With this approach I can delete whole generated folder and re-generate it from script again

 

Is it possible to have them separated and on build/run merge this two folders?

Posted (edited)

I accomplished this through the use of a "generated" Gradle sourceset, then including that sourceSet in my run configurations (in runs -> mods -> <my mod name> under sourceSets.main)

To have this sourceset included in your built jar requires extra configuration to the jar task, adding from sourceSets.generated.output to it.

 

(This is all Gradle configuration, if you have further questions please try reading the Gradle Documentation)

Edited by DaemonUmbra
Added the bit about the built jar

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted (edited)

I tried it, but without success. I marked my folder as "Generated Sources Root", but when I add into build.gradle "from sourceSets.generated.output" it fails saying something that: 

Could not get unknown property 'generated' for SourceSet container of type org.gradle.api.internal.tasks.DefaultSourceSetContainer.

 

I spend few hours googling about gradle and sourceSets, but there is nothing helpfull. 

 

Can you please provide some example how to add it into gradle file?

 

Edit

 

I found simple solution to this, just extend sourceSet.main.resources.srcDirs:

 

...

        client {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            // Add generated resource files
            sourceSets.main.resources.srcDirs += ['src/generated/resources']

            mods {
                toomanyores {
                    source sourceSets.main
                }
            }
        }

...

 

Edited by Yanny7
Posted

The generated source set is one you have to create (easier than it sounds, all the defaults are correct for your usage), just look up how to create a Gradle source set

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.