Skip to content

Commit

Permalink
Add userdevCompileOnly configuration and allow JarJar usage in the …
Browse files Browse the repository at this point in the history
…platform `universalJar` (#60)
  • Loading branch information
Technici4n authored Dec 1, 2023
1 parent d09a284 commit 0c49067
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 59 deletions.
2 changes: 2 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ dependencies {
api "codechicken:DiffPatch:${project.diffpatch_version}"
api "commons-codec:commons-codec:${project.commons_codec_version}"
api "net.neoforged:EclipseLaunchConfigs:${project.eclipse_launch_configs_version}"
api "net.neoforged:JarJarMetadata:${project.jarjar_version}"
api "net.neoforged:JarJarSelector:${project.jarjar_version}"

// IDE support
api "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:${project.gradle_idea_extension_version}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.neoforged.gradle.userdev.dependency;
package net.neoforged.gradle.common.dependency;

import groovy.lang.Closure;
import net.neoforged.gradle.dsl.userdev.dependency.DependencyManagementObject;
import net.neoforged.gradle.dsl.common.dependency.DependencyManagementObject;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.ModuleDependency;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.neoforged.gradle.userdev.dependency;
package net.neoforged.gradle.common.dependency;

import net.neoforged.gradle.dsl.userdev.dependency.DependencyFilter;
import net.neoforged.gradle.dsl.userdev.dependency.DependencyManagementObject;
import net.neoforged.gradle.dsl.common.dependency.DependencyFilter;
import org.gradle.api.Project;
import org.gradle.api.artifacts.ModuleDependency;
import org.gradle.api.artifacts.ResolvedDependency;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package net.neoforged.gradle.userdev.dependency;
package net.neoforged.gradle.common.dependency;

import com.google.common.collect.Maps;
import net.neoforged.gradle.dsl.userdev.dependency.DependencyManagementObject;
import net.neoforged.gradle.dsl.userdev.dependency.DependencyVersionInformationHandler;
import net.neoforged.gradle.dsl.common.dependency.DependencyVersionInformationHandler;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.VersionRange;
import org.gradle.api.Project;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.neoforged.gradle.userdev.jarjar;
package net.neoforged.gradle.common.extensions;

import net.neoforged.gradle.dsl.userdev.dependency.DependencyFilter;
import net.neoforged.gradle.dsl.userdev.dependency.DependencyVersionInformationHandler;
import net.neoforged.gradle.userdev.tasks.JarJar;
import net.neoforged.gradle.dsl.common.dependency.DependencyFilter;
import net.neoforged.gradle.dsl.common.dependency.DependencyVersionInformationHandler;
import net.neoforged.gradle.common.tasks.JarJar;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.Task;
Expand All @@ -14,7 +14,7 @@
import javax.inject.Inject;
import java.util.Optional;

public class JarJarExtension implements net.neoforged.gradle.dsl.userdev.extension.JarJar {
public class JarJarExtension implements net.neoforged.gradle.dsl.common.extensions.JarJar {

private final Attribute<String> fixedJarJarVersionAttribute = Attribute.of("fixedJarJarVersion", String.class);
private final Attribute<String> jarJarRangeAttribute = Attribute.of("jarJarRange", String.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/

package net.neoforged.gradle.userdev.manifest;
package net.neoforged.gradle.common.manifest;

import groovy.lang.Closure;
import org.gradle.api.Action;
Expand All @@ -21,7 +21,7 @@

public class DefaultInheritManifest implements InheritManifest {

private List<DefaultManifestMergeSpec> inheritMergeSpecs = new ArrayList<>();
private final List<DefaultManifestMergeSpec> inheritMergeSpecs = new ArrayList<>();
private final FileResolver fileResolver;
private final Manifest internalManifest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/

package net.neoforged.gradle.userdev.manifest;
package net.neoforged.gradle.common.manifest;

import org.gradle.api.Action;
import org.gradle.api.java.archives.Manifest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package net.neoforged.gradle.userdev.tasks;

import net.minecraftforge.jarjar.metadata.*;
import net.neoforged.gradle.dsl.userdev.dependency.DependencyFilter;
import net.neoforged.gradle.dsl.userdev.dependency.DependencyVersionInformationHandler;
import net.neoforged.gradle.userdev.dependency.DefaultDependencyFilter;
import net.neoforged.gradle.userdev.dependency.DefaultDependencyVersionInformationHandler;
import net.neoforged.gradle.userdev.jarjar.JarJarExtension;
import net.neoforged.gradle.userdev.manifest.DefaultInheritManifest;
import net.neoforged.gradle.userdev.manifest.InheritManifest;
package net.neoforged.gradle.common.tasks;

import net.neoforged.jarjar.metadata.*;
import net.neoforged.gradle.dsl.common.dependency.DependencyFilter;
import net.neoforged.gradle.dsl.common.dependency.DependencyVersionInformationHandler;
import net.neoforged.gradle.common.dependency.DefaultDependencyFilter;
import net.neoforged.gradle.common.dependency.DefaultDependencyVersionInformationHandler;
import net.neoforged.gradle.common.manifest.DefaultInheritManifest;
import net.neoforged.gradle.common.manifest.InheritManifest;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
Expand Down Expand Up @@ -83,7 +82,10 @@ public InheritManifest getManifest() {
@TaskAction
protected void copy() {
this.jarJarCopySpec.from(getIncludedDependencies());
this.jarJarCopySpec.from(getMetadata());
if (!createMetadata().jars().isEmpty()) {
// Only copy metadata if not empty.
this.jarJarCopySpec.from(getJarJarMetadataPath().toFile());
}
super.copy();
}

Expand Down Expand Up @@ -222,7 +224,7 @@ private String getVersionRangeFrom(final ModuleDependency dependency) {
if (versionRange.isPresent()) {
return versionRange.get();
}
final Optional<String> attributeVersion = getProject().getExtensions().getByType(net.neoforged.gradle.dsl.userdev.extension.JarJar.class).getRange(dependency);
final Optional<String> attributeVersion = getProject().getExtensions().getByType(net.neoforged.gradle.dsl.common.extensions.JarJar.class).getRange(dependency);

return attributeVersion.orElseGet(() -> Objects.requireNonNull(dependency.getVersion()));
}
Expand All @@ -232,7 +234,7 @@ private String getVersionFrom(final ModuleDependency dependency) {
if (version.isPresent()) {
return version.get();
}
final Optional<String> attributeVersion = getProject().getExtensions().getByType(net.neoforged.gradle.dsl.userdev.extension.JarJar.class).getPin(dependency);
final Optional<String> attributeVersion = getProject().getExtensions().getByType(net.neoforged.gradle.dsl.common.extensions.JarJar.class).getPin(dependency);

return attributeVersion.orElseGet(() -> Objects.requireNonNull(dependency.getVersion()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.neoforged.gradle.dsl.userdev.dependency
package net.neoforged.gradle.dsl.common.dependency

import groovy.transform.CompileStatic
import org.gradle.api.artifacts.ModuleDependency
Expand Down Expand Up @@ -49,4 +49,4 @@ interface DependencyFilter extends DependencyManagementObject {
* @return The result of the filter.
*/
boolean isIncluded(ArtifactIdentifier identifier);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.neoforged.gradle.dsl.userdev.dependency
package net.neoforged.gradle.dsl.common.dependency

import groovy.transform.CompileStatic
import org.gradle.api.artifacts.Dependency
Expand Down Expand Up @@ -80,4 +80,4 @@ interface DependencyManagementObject {
return version;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.neoforged.gradle.dsl.userdev.dependency
package net.neoforged.gradle.dsl.common.dependency

import groovy.transform.CompileStatic
import org.apache.maven.artifact.versioning.ArtifactVersion
Expand Down Expand Up @@ -64,4 +64,4 @@ interface DependencyVersionInformationHandler extends DependencyManagementObject
* @return The version, if any.
*/
Optional<String> getVersion(ModuleDependency dependency);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.neoforged.gradle.dsl.userdev.extension
package net.neoforged.gradle.dsl.common.extensions

import net.neoforged.gradle.dsl.userdev.dependency.DependencyFilter
import net.neoforged.gradle.dsl.userdev.dependency.DependencyVersionInformationHandler
import net.neoforged.gradle.dsl.common.dependency.DependencyFilter
import net.neoforged.gradle.dsl.common.dependency.DependencyVersionInformationHandler
import org.gradle.api.Action
import org.gradle.api.artifacts.Dependency
import org.gradle.api.publish.maven.MavenPublication
Expand Down Expand Up @@ -38,4 +38,4 @@ interface JarJar {

MavenPublication component(MavenPublication mavenPublication);

}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ivy_artifact_version=2.5.1
httpclient_version=4.5.13
srgutils_version=0.4.13
diffpatch_version=1.5.0.29
jarjar_version=0.3.19
jarjar_version=0.4.1
jetbrains_annotations_version=23.0.0
gradle_idea_extension_version=1.1.6
groovy_dsl_improver_version=1.0.10
Expand Down
Loading

0 comments on commit 0c49067

Please sign in to comment.