-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d722afb
commit 47be513
Showing
188 changed files
with
5,706 additions
and
2,519 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ snapshots | |
|
||
/examples/*/run/ # this is where the run files are stored | ||
/neoform/tests | ||
**/version.neogradle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
353 changes: 58 additions & 295 deletions
353
common/src/main/java/net/neoforged/gradle/common/CommonProjectPlugin.java
Large diffs are not rendered by default.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
...main/java/net/neoforged/gradle/common/accesstransformers/AccessTransformerPublishing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package net.neoforged.gradle.common.accesstransformers; | ||
|
||
import net.neoforged.gradle.common.extensions.AccessTransformersExtension; | ||
import net.neoforged.gradle.dsl.common.extensions.AccessTransformers; | ||
import org.gradle.api.Action; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.artifacts.Configuration; | ||
import org.gradle.api.attributes.AttributeContainer; | ||
import org.gradle.api.attributes.Category; | ||
import org.gradle.api.component.AdhocComponentWithVariants; | ||
|
||
public class AccessTransformerPublishing { | ||
|
||
public static final String ACCESS_TRANSFORMER_ELEMENTS_CONFIGURATION = "accessTransformerElements"; | ||
public static final String ACCESS_TRANSFORMER_API_CONFIGURATION = "accessTransformerApi"; | ||
public static final String ACCESS_TRANSFORMER_CONFIGURATION = "accessTransformer"; | ||
public static final String ACCESS_TRANSFORMER_CATEGORY = "accesstransformer"; | ||
|
||
public static void setup(Project project) { | ||
AccessTransformers accessTransformersExtension = project.getExtensions().getByType(AccessTransformers.class); | ||
|
||
Configuration accessTransformerElements = project.getConfigurations().maybeCreate(ACCESS_TRANSFORMER_ELEMENTS_CONFIGURATION); | ||
Configuration accessTransformerApi = project.getConfigurations().maybeCreate(ACCESS_TRANSFORMER_API_CONFIGURATION); | ||
Configuration accessTransformer = project.getConfigurations().maybeCreate(ACCESS_TRANSFORMER_CONFIGURATION); | ||
|
||
accessTransformerApi.setCanBeConsumed(false); | ||
accessTransformerApi.setCanBeResolved(false); | ||
|
||
accessTransformer.setCanBeConsumed(false); | ||
accessTransformer.setCanBeResolved(true); | ||
|
||
accessTransformerElements.setCanBeConsumed(true); | ||
accessTransformerElements.setCanBeResolved(false); | ||
accessTransformerElements.setCanBeDeclared(false); | ||
|
||
Action<AttributeContainer> action = attributes -> { | ||
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.getObjects().named(Category.class, ACCESS_TRANSFORMER_CATEGORY)); | ||
}; | ||
|
||
accessTransformerElements.attributes(action); | ||
accessTransformer.attributes(action); | ||
|
||
accessTransformer.extendsFrom(accessTransformerApi); | ||
accessTransformerElements.extendsFrom(accessTransformerApi); | ||
|
||
// Now we set up the component, conditionally | ||
AdhocComponentWithVariants java = (AdhocComponentWithVariants) project.getComponents().getByName("java"); | ||
Runnable enable = () -> java.addVariantsFromConfiguration(accessTransformerElements, variant -> { | ||
}); | ||
|
||
accessTransformerElements.getAllDependencies().configureEach(dep -> enable.run()); | ||
accessTransformerElements.getArtifacts().configureEach(artifact -> enable.run()); | ||
|
||
// And add resolved ATs to the extension | ||
accessTransformersExtension.getFiles().from(accessTransformer); | ||
} | ||
} |
Oops, something went wrong.