Skip to content

Commit

Permalink
[Fix]: Many tiny bugs (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
marchermans authored Aug 11, 2024
1 parent d722afb commit 47be513
Show file tree
Hide file tree
Showing 188 changed files with 5,706 additions and 2,519 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ snapshots

/examples/*/run/ # this is where the run files are stored
/neoform/tests
**/version.neogradle
407 changes: 347 additions & 60 deletions README.md

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ plugins {
id 'java-gradle-plugin'
}

sourceSets {
main {
java {
resources {
srcDir 'src/main/generated'
}
}
}
}

dependencies {
api project(':utils')
api project(':dsl-common')
Expand All @@ -29,3 +39,10 @@ dependencies {
api "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:${project.gradle_idea_extension_version}"
}

def versionFile = file('src/main/generated/version.neogradle')
if (versionFile.exists()) {
versionFile.delete()
} else {
versionFile.parentFile.mkdirs()
}
versionFile << project.version.toString()

Large diffs are not rendered by default.

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);
}
}
Loading

0 comments on commit 47be513

Please sign in to comment.