Skip to content

Commit

Permalink
Correctly build artifact manifest for NFRT
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed May 24, 2024
1 parent e5428a3 commit 7d9b257
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.gradle.api.attributes.Attribute;
import org.gradle.api.attributes.Bundling;
import org.gradle.api.attributes.Category;
import org.gradle.api.attributes.DocsType;
import org.gradle.api.attributes.LibraryElements;
import org.gradle.api.attributes.Usage;
import org.gradle.api.attributes.java.TargetJvmVersion;
Expand Down Expand Up @@ -83,10 +84,46 @@ public void apply(Project project) {
addTemporaryRepositories(repositories);

var configurations = project.getConfigurations();
var neoForgeModDev = configurations.create("neoForgeModDev", files -> {
files.setCanBeConsumed(false);
files.setCanBeResolved(true);
//files.defaultDependencies(spec -> spec.addLater(neoForgeUserdevDependency));
// Configuration for all artifact that should be passed to NFRT for preventing repeated downloads
var neoFormRuntimeArtifactManifestNeoForgeClasses = configurations.create("neoFormRuntimeArtifactManifestNeoForgeClasses", spec -> {
spec.setCanBeConsumed(false);
spec.setCanBeResolved(true);
spec.withDependencies(dependencies -> {
// Add the dep on NeoForge itself
dependencies.addLater(extension.getVersion().map(version -> {
return dependencyFactory.create("net.neoforged:neoforge:" + version)
.capabilities(caps -> {
caps.requireCapability("net.neoforged:neoforge-moddev-bundle");
});
}));
});
});
// Configuration for all artifact that should be passed to NFRT for preventing repeated downloads
var neoFormRuntimeArtifactManifestNeoForgeSources = configurations.create("neoFormRuntimeArtifactManifestNeoForgeSources", spec -> {
spec.setCanBeConsumed(false);
spec.setCanBeResolved(true);
spec.withDependencies(dependencies -> {
// Add the dep on NeoForge itself
dependencies.addLater(extension.getVersion().map(version -> {
return dependencyFactory.create("net.neoforged:neoforge:" + version)
. attributes(attributes -> {
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.getObjects().named(Category.class, Category.DOCUMENTATION));
attributes.attribute(DocsType.DOCS_TYPE_ATTRIBUTE, project.getObjects().named(DocsType.class, DocsType.SOURCES));
});
}));
});
});
var neoFormRuntimeArtifactManifestNeoForm = configurations.create("neoFormRuntimeArtifactManifestNeoForm", spec -> {
spec.setCanBeConsumed(false);
spec.setCanBeResolved(true);
spec.withDependencies(dependencies -> {
dependencies.addLater(extension.getVersion().map(version -> {
return dependencyFactory.create("net.neoforged:neoforge:" + version)
.capabilities(caps -> {
caps.requireCapability("net.neoforged:neoforge-dependencies");
});
}));
});
});
var neoFormRuntimeConfig = configurations.create("neoFormRuntime", files -> {
files.setCanBeConsumed(false);
Expand Down Expand Up @@ -130,7 +167,25 @@ public void apply(Project project) {
var tasks = project.getTasks();

var createManifest = tasks.register("createArtifactManifest", CreateArtifactManifestTask.class, task -> {
task.getNeoForgeModDevArtifacts().set(neoForgeModDev.getIncoming().getArtifacts().getResolvedArtifacts().map(results -> {
task.getNeoForgeModDevArtifacts().addAll(neoFormRuntimeArtifactManifestNeoForgeClasses.getIncoming().getArtifacts().getResolvedArtifacts().map(results -> {
return results.stream().map(result -> {
var gav = guessMavenGav(result);
return new ArtifactManifestEntry(
gav,
result.getFile()
);
}).collect(Collectors.toSet());
}));
task.getNeoForgeModDevArtifacts().addAll(neoFormRuntimeArtifactManifestNeoForgeSources.getIncoming().getArtifacts().getResolvedArtifacts().map(results -> {
return results.stream().map(result -> {
var gav = guessMavenGav(result);
return new ArtifactManifestEntry(
gav,
result.getFile()
);
}).collect(Collectors.toSet());
}));
task.getNeoForgeModDevArtifacts().addAll(neoFormRuntimeArtifactManifestNeoForm.getIncoming().getArtifacts().getResolvedArtifacts().map(results -> {
return results.stream().map(result -> {
var gav = guessMavenGav(result);
return new ArtifactManifestEntry(
Expand Down
3 changes: 2 additions & 1 deletion testproject/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ org.gradle.configuration-cache=true
org.gradle.warning.mode=fail

# Dependency versions
neoforge_version=20.6.53-beta-features-gradle-metadata
neoforge_version=20.6.84-beta-pr-959-features-gradle-metadata

0 comments on commit 7d9b257

Please sign in to comment.