Fix `namedElements` not extending from api (#533)
* Fix `namedElements` not extending from api Fix artifact not waiting for remapAllJars with shared caches * Use apiElements * Add a better test for this. * Also add remapped api mods to namedElementsdev/0.11
parent
2994c2d488
commit
35afda4398
|
@ -45,6 +45,7 @@ import org.gradle.api.artifacts.result.ComponentArtifactsResult;
|
|||
import org.gradle.api.artifacts.result.ResolvedArtifactResult;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
import org.gradle.api.logging.Logger;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.jvm.JvmLibrary;
|
||||
import org.gradle.language.base.artifact.SourcesArtifact;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -156,6 +157,11 @@ public class ModCompileRemapper {
|
|||
if (entry.replacedWith() != null && !modDependencies.isEmpty()) {
|
||||
extension.getDeprecationHelper().replaceWithInLoom0_11(entry.sourceConfiguration(), entry.replacedWith());
|
||||
}
|
||||
|
||||
// Export to other projects
|
||||
if (entry.targetConfiguration().equals(JavaPlugin.API_CONFIGURATION_NAME)) {
|
||||
project.getConfigurations().getByName(Constants.Configurations.NAMED_ELEMENTS).extendsFrom(remappedConfig);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ public final class CompileConfiguration {
|
|||
extension.createLazyConfiguration(Constants.Configurations.NAMED_ELEMENTS).configure(configuration -> {
|
||||
configuration.setCanBeConsumed(true);
|
||||
configuration.setCanBeResolved(false);
|
||||
configuration.extendsFrom(project.getConfigurations().getByName(JavaPlugin.API_CONFIGURATION_NAME));
|
||||
});
|
||||
|
||||
extendsFrom(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, Constants.Configurations.MAPPING_CONSTANTS, project);
|
||||
|
|
|
@ -73,7 +73,15 @@ public class RemapConfiguration {
|
|||
return;
|
||||
}
|
||||
|
||||
PublishArtifact artifact = artifacts.add(JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME, task.getOutput());
|
||||
PublishArtifact artifact = artifacts.add(JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME, task.getOutput(), configurablePublishArtifact -> {
|
||||
Task remapJarTask = task;
|
||||
|
||||
if (extension.getShareRemapCaches().get()) {
|
||||
remapJarTask = project.getRootProject().getTasks().getByName(DEFAULT_REMAP_ALL_JARS_TASK_NAME);
|
||||
}
|
||||
|
||||
configurablePublishArtifact.builtBy(remapJarTask);
|
||||
});
|
||||
|
||||
// Remove the existing artifact that does not run remapSourcesJar.
|
||||
// It doesn't seem to hurt, but I'm not sure if the file-level duplicates cause issues.
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.gradle.util.GradleVersion
|
|||
|
||||
class LoomTestConstants {
|
||||
public final static String DEFAULT_GRADLE = GradleVersion.current().getVersion()
|
||||
public final static String PRE_RELEASE_GRADLE = "7.4-20211108233000+0000"
|
||||
public final static String PRE_RELEASE_GRADLE = "7.4-20211110232442+0000"
|
||||
|
||||
public final static String[] STANDARD_TEST_VERSIONS = [DEFAULT_GRADLE, PRE_RELEASE_GRADLE]
|
||||
}
|
||||
|
|
|
@ -43,14 +43,14 @@ class FabricAPITest extends Specification implements GradleProjectTestTrait {
|
|||
def "build and run (gradle #version)"() {
|
||||
setup:
|
||||
def gradle = gradleProject(
|
||||
repo: "https://github.com/FabricMC/fabric.git",
|
||||
commit: "46582230fb580d4c1f71e4b0737df27417ec9cb1",
|
||||
repo: "https://github.com/modmuss50/fabric.git",
|
||||
commit: "e954edb6069e36139fd70428cfe4cddb5826c498",
|
||||
version: version,
|
||||
patch: "fabric_api"
|
||||
// patch: "fabric_api"
|
||||
)
|
||||
|
||||
// Set the version to something constant
|
||||
gradle.buildGradle.text = gradle.buildGradle.text.replace('Globals.baseVersion + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()', "\"$API_VERSION\"")
|
||||
gradle.buildGradle.text = gradle.buildGradle.text.replace('project.version + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()', "\"$API_VERSION\"")
|
||||
|
||||
def server = ServerRunner.create(gradle.projectDir, "1.17.1")
|
||||
.withMod(gradle.getOutputFile("fabric-api-${API_VERSION}.jar"))
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
diff --git a/build.gradle b/build.gradle
|
||||
--- a/build.gradle (revision fc40aa9d88e9457957bdf3f8cec9698846828cd3)
|
||||
+++ b/build.gradle (date 1631009569915)
|
||||
@@ -257,6 +257,9 @@
|
||||
setupRepositories(repositories)
|
||||
}
|
||||
|
||||
+ // Required as moduleDependencies modifies the pom
|
||||
+ loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
|
||||
+
|
||||
javadoc.enabled = false
|
||||
}
|
||||
|
||||
@@ -296,6 +299,8 @@
|
||||
setupRepositories(repositories)
|
||||
}
|
||||
|
||||
+loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
|
||||
+
|
||||
void setupRepositories(RepositoryHandler repositories) {
|
||||
//repositories.mavenLocal() // uncomment for testing
|
||||
def ENV = System.getenv()
|
|
@ -1 +1,6 @@
|
|||
archivesBaseName = "core"
|
||||
|
||||
dependencies {
|
||||
// An example api dep to be used by the other sub project.
|
||||
modApi "TechReborn:TechReborn-1.16:3.8.4+build.236"
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package net.fabricmc.example;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import techreborn.blocks.cable.CableShapeUtil;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
|
||||
public class ExampleMod implements ModInitializer {
|
||||
@Override
|
||||
|
@ -10,5 +13,11 @@ public class ExampleMod implements ModInitializer {
|
|||
// Proceed with mild caution.
|
||||
|
||||
System.out.println("Hello Fabric world!");
|
||||
|
||||
if (false) {
|
||||
// Just here to make sure it compiles as named, not to test it runs
|
||||
BlockState state = null;
|
||||
VoxelShape shape = new CableShapeUtil(null).getShape(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue