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

Create Conventions subsystem #170

Merged
merged 12 commits into from
May 14, 2024
Merged

Create Conventions subsystem #170

merged 12 commits into from
May 14, 2024

Conversation

marchermans
Copy link
Contributor

@marchermans marchermans commented May 14, 2024

TLDR

This new subsystem (allthough only partially configurable via DSL), allows the management of NeoForge resources via conventions over configurations, runs and sourcesets.

The buildscript as such can be shorted to the following:

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(21)
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'net.neoforged:neoforge:+'
}

Obviously the version for neoforge can still be hand set.
This shorter variant will configure the same setup, including runs, configurations and all setup as usual. A reference to the neoforge implementation is still needed.


Conventions

Within the gradle community there is a heavy emphasis on conventions, configurations are named in certain patterns, source sets trigger the creation of configurations, and main exists always, etc.

NeoGradle followed some of these, but not others. The goal of this PR is to follow these more, specifically when it comes to configurations, runs, and sourcesets.

This entire new subsystem is configurable like any other via the gradle properties, or the DSL.

Warning

Some properties of the new subsystem are only configurable via the gradle properties, as they are read as soon as the project is applied, others can be modified later, or when they are modified later, then the new value with only effect configurations, runs or sourcesets from the moment that it was set.

Configurations:

Per source set we now create the following configurations, using test as an example the name for the main sourceset can be found in brackets:

  • testLocalRuntime (localRuntime) -> A configuration that exists so that you can add dependencies to the runtimeClasspath without them showing up externally in the runtimeElements of your sourceset or project.
  • testLocalRunRuntime (localRunRuntime) -> A configuration that exists so that you can add dependencies to the runs runtime your sourceset is added to, as long as you have the relevant convention enabled (see below).

Per run we now also create the following configurations, using client as an example:

  • clientRun -> A configuration to add dependencies to your runs runtime.

Globally we now also create 2 configurations:

  • runs -> A configuration to add your dependency as a runtime element to any run.

Sourceset management:

We now add the main sourceset to any run in the project by default.
Additionally if you add a sourceset to the mod sources of a run, its localRunRuntime (so for example testLocalRunRuntime for test) configuration is also added to the runs runtime.

Note

We currently do not offer a sourceset scoped mod configuration, but if the community requests one, we can trivially add it

Run management:

Automatic creation of runs based on available run types.
Most modders run with exactly one version of neoforge (either in one or more sourcesets), and they create all available runs; client, server, datagen, and gameTestServer. So this convention configures the runs accordingly, automatically creating a run based on the given run type found. If you run with multiple different NeoForge versions in different sourcesets, please dissable this convention via gradle.properties to prevent issues.

Note

If you are effected by this, let us know so that we can gauge the community use and interest of the multi-neoforge version feature and possibly improve compatibilty.

IDE Integrations:

This PR only offers conventions for the IDEA plugin:
We now automatically detect if you are running NeoGradle in an IDEA instance with "Compile with IDEA" enabled. If this is the case different output paths are emitted.
We also now offer a direct convention property to set the output directory of the compiler. By default this is out. We do not yet automatically detect this from your configuration.

Properties

If you want to disable any of these functionalities, please see the new readme.md entries for them, or visit the NeoGradle documentation, once it is added there.


Other changes:

  • Due to modifications in the way the plugin initializes you can now configure the runs before the dependencies (usefull for if you want to use configuration based setups that add dependencies that way to the runs runtime or mods setup)
  • NeoGradle will now always create a LocalRuntime configuration for all sourcesets, you do not need to create one yourself.

@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented May 14, 2024

  • Publish PR to GitHub Packages

Last commit published: 3e9c63a900233e7ce9367ed749e9a6a3c4d6fdaf.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven {
        name 'Maven for PR #170' // https://github.com/neoforged/NeoGradle/pull/170
        url 'https://prmaven.neoforged.net/NeoGradle/pr170'
        content {
            includeModule('net.neoforged.gradle', 'common')
            includeModule('net.neoforged.gradle', 'neoform')
            includeModule('net.neoforged.gradle', 'dsl-neoform')
            includeModule('net.neoforged.gradle.common', 'net.neoforged.gradle.common.gradle.plugin')
            includeModule('net.neoforged.gradle.userdev', 'net.neoforged.gradle.userdev.gradle.plugin')
            includeModule('net.neoforged.gradle', 'dsl-common')
            includeModule('net.neoforged.gradle.neoform', 'net.neoforged.gradle.neoform.gradle.plugin')
            includeModule('net.neoforged.gradle', 'platform')
            includeModule('net.neoforged.gradle', 'dsl-vanilla')
            includeModule('net.neoforged.gradle', 'dsl-platform')
            includeModule('net.neoforged.gradle.platform', 'net.neoforged.gradle.platform.gradle.plugin')
            includeModule('net.neoforged.gradle', 'dsl-mixin')
            includeModule('net.neoforged.gradle.vanilla', 'net.neoforged.gradle.vanilla.gradle.plugin')
            includeModule('net.neoforged.gradle.mixin', 'net.neoforged.gradle.mixin.gradle.plugin')
            includeModule('net.neoforged.gradle', 'userdev')
            includeModule('net.neoforged.gradle', 'mixin')
            includeModule('net.neoforged.gradle', 'vanilla')
            includeModule('net.neoforged.gradle', 'utils')
            includeModule('net.neoforged.gradle', 'dsl-userdev')
        }
    }
}

@marchermans marchermans enabled auto-merge (squash) May 14, 2024 21:04
@marchermans marchermans merged commit bbeaf0c into NG_7.0 May 14, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants