Skip to content

Commit

Permalink
Merge branch 'plugin'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamebuster19901 committed Aug 1, 2024
2 parents ab50034 + e685372 commit 8323110
Show file tree
Hide file tree
Showing 11 changed files with 498 additions and 15 deletions.
35 changes: 31 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,47 @@ task processSource(type: Sync) {
from sourceSets.main.java.srcDirs
into "$buildDir/processedSrc"

//The version of the WilderWorkspace gradle plugin
inputs.property 'workspaceVersion', workspaceVersion
inputs.property 'commonsLangVersion', commonsLangVersion

inputs.property 'accessWidenerVersion', accessWidenerVersion
inputs.property 'tinyMappingsVersion', tinyMappingsVersion
inputs.property 'mixinVersion', mixinVersion
inputs.property 'guavaVersion', guavaVersion
inputs.property 'gsonVersion', gsonVersion
inputs.property 'providerVersion', providerVersion
inputs.property 'asmVersion', asmVersion
inputs.property 'fabricLoaderVersion', fabricLoaderVersion
inputs.property 'wilderLoaderVersion', wilderLoaderVersion

//dependencies for building and running WilderWorkspace gradle plugin itself
inputs.property 'commonsIOVersion', commonsIOVersion
inputs.property 'commonsLangVersion', commonsLangVersion
inputs.property 'commonsTextVersion', commonsTextVersion
inputs.property 'loomVersion', loomVersion
inputs.property 'vineFlowerVersion', vineFlowerVersion
inputs.property 'loomVersion', loomVersion

filter(ReplaceTokens, tokens: [
//The version of the WilderWorkspace gradle plugin
workspaceVersion: workspaceVersion,

//dependencies that projects using WilderWorkspace will need in order to mod Wildermyth
accessWidenerVersion: accessWidenerVersion,
tinyMappingsVersion: tinyMappingsVersion,
mixinVersion: mixinVersion,
guavaVersion: guavaVersion,
gsonVersion: gsonVersion,
providerVersion: providerVersion,
asmVersion: asmVersion,
fabricLoaderVersion: fabricLoaderVersion,
wilderLoaderVersion: wilderLoaderVersion,

//dependencies for building and running WilderWorkspace gradle plugin itself
commonsIOVersion: commonsIOVersion,
commonsLangVersion: commonsLangVersion,
commonsTextVersion: commonsTextVersion,
commonsIOVersion: commonsIOVersion,
vineFlowerVersion: vineFlowerVersion,
loomVersion: loomVersion,
vineFlowerVersion: vineFlowerVersion
])
}

Expand Down
17 changes: 15 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
#The version of the WilderWorkspace gradle plugin
workspaceVersion = 4.0.0.0

#dependencies that projects using WilderWorkspace will need in order to mod Wildermyth
accessWidenerVersion = 2.1.0
tinyMappingsVersion = 0.3.0+
mixinVersion = 0.8.5
guavaVersion = 33.2.1-jre
gsonVersion = 2.11.0
providerVersion = 1.2.0.1
asmVersion = 9.7
fabricLoaderVersion = 0.16.0
wilderLoaderVersion = 1.1.0.0

#dependencies for building and running WilderWorkspace gradle plugin itself
commonsIOVersion = 2.16.1
commonsLangVersion = 3.14.0
commonsTextVersion = 1.12.0
commonsIOVersion = 2.16.1
fernFlowerVersion = 2.0.0
vineFlowerVersion = 1.10.1
loomVersion = 1.7.2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

import org.gradle.api.artifacts.Dependency;

enum Dependencies implements Dependency {
/**
* A PluginDependency represents a dependency that is required to build and run
* the WilderWorkspace gradle plugin itself.
*
* @see {@link WWProjectDependency} for dependencies that modded environments made
* using WilderWorkspace will need in order to run
*/
enum PluginDependency implements Dependency {

COMMONS_IO("commons-io", "commons-io", "@commonsIOVersion@"),
COMMONS_LANG("org.apache.commons", "commons-lang3", "@commonsLangVersion@"),
Expand All @@ -19,7 +26,7 @@ enum Dependencies implements Dependency {
private String reason;


private Dependencies(String groupID, String artifact, String version) {
private PluginDependency(String groupID, String artifact, String version) {
this.groupID = groupID;
this.artifact = artifact;
this.version = version;
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/wildermods/workspace/ProjectDependencyType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.wildermods.workspace;

public enum ProjectDependencyType {

/**
* normal gradle compile time only dependencies
*/
compileOnly,

/**
* normal gradle implementation dependencies
*/
implementation,

/**
* dependencies that fabric requires to be in the "fabricDependencyPath" at runtime. {@code ./bin/fabric/} is
* the default location of where these dependencies are located.
*/
fabricDep,

/**
* dependencies that are required to be in the "fabricPath" at runtime. Usually {@code ./bin/} is the default
* location of where these dependencies are located
*/
fabricImpl;

}
25 changes: 25 additions & 0 deletions src/main/java/com/wildermods/workspace/WWProjectContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,45 @@

import org.gradle.api.Project;

/**
* Represents the context of a WilderWorkspace project.
* <p>
* This class encapsulates the project and the WilderWorkspace extension
* to provide a unified interface for interacting with project-specific
* settings and configurations within the plugin.
* </p>
*/
public class WWProjectContext {

private final Project project;
private final WilderWorkspaceExtension extension;

/**
* Constructs a new {@code WWProjectContext} with the specified project
* and WilderWorkspace extension.
*
* @param project the Gradle project associated with this context
* @param extension the WilderWorkspace extension associated with this context
*/
public WWProjectContext(Project project, WilderWorkspaceExtension extension) {
this.project = project;
this.extension = extension;
}

/**
* Returns the Gradle project associated with this context.
*
* @return the Gradle project
*/
public Project getProject() {
return project;
}

/**
* Returns the WilderWorkspace extension associated with this context.
*
* @return the WilderWorkspace extension
*/
public WilderWorkspaceExtension getWWExtension() {
return extension;
}
Expand Down
170 changes: 170 additions & 0 deletions src/main/java/com/wildermods/workspace/WWProjectDependency.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
package com.wildermods.workspace;

import org.gradle.api.artifacts.Dependency;
import static com.wildermods.workspace.ProjectDependencyType.*;

import java.net.URI;
import java.net.URISyntaxException;

/**
* A WWProject dependency represents a dependency common to all projects made
* using WilderWorkspace.
* <p>
* Each constant in this enum corresponds to a specific dependency required for projects
* using WilderWorkspace. These dependencies are essential for consistent compilation
* and execution of projects that share the same version of the WilderWorkspace plugin.
* <p>
* Dependencies are categorized into two types:
* <ul>
* <li>{@code fabricDep}: Dependencies that Fabric requires to be in the "fabricDependencyPath" at runtime.
* {@code ./bin/fabric/} is the default location where these dependencies are located.</li>
* <li>{@code fabricImpl}: Dependencies that are required to be in the "fabricPath" at runtime.
* {@code ./bin/} is the default location where these dependencies are located.</li>
* </ul>
* <p>
* The {@code gitRepo} field, if specified, indicates a Git repository URL from which
* the dependency can be obtained. This is used to set up source control repositories
* for project dependencies during plugin application. See the {@link WilderWorkspacePlugin#apply(Settings)}
* method for details on how these repositories are configured.
* <p>
* For additional information about the dependencies needed by the WilderWorkspace
* gradle plugin itself, see {@link PluginDependency}.
* </p>
*/
public enum WWProjectDependency implements Dependency {

commonsText(fabricDep, "org.apache.commons", "commons-text", "@commonsTextVersion@"),
accessWidener(fabricDep, "net.fabricmc", "access-widener", "@accessWidenerVersion@"),
tinyMappingsParser(fabricDep, "net.fabricmc", "tiny-mappings-parser", "@tinyMappingsVersion@"),
mixin(fabricDep, "org.spongepowered", "mixin", "@mixinVersion@"),
guava(fabricDep, "com.google.guava", "guava", "@guavaVersion@"),
gson(fabricDep, "com.google.code.gson", "gson", "@gsonVersion@"),
gameProvider(fabricDep, "com.wildermods", "provider", "@providerVersion@", "https://wildermods.com/WildermythGameProvider.git"),

asm(fabricDep, "org.ow2.asm", "asm", "@asmVersion@"),
asmAnalysis(fabricDep, "org.ow2.asm", "asm-analysis", "@asmVersion@"),
asmCommons(fabricDep, "org.ow2.asm", "asm-commons", "@asmVersion@"),
asmTree(fabricDep, "org.ow2.asm", "asm-tree", "@asmVersion@"),
asmUtil(fabricDep, "org.ow2.asm", "asm-util", "@asmVersion@"),


fabricLoader(fabricImpl, "net.fabricmc", "fabric-loader", "@fabricLoaderVersion@"),
wilderLoader(fabricImpl, "com.wildermods", "wilderloader", "@wilderLoaderVersion@", "https://wildermods.com/WilderLoader.git")

;

private final ProjectDependencyType type;
private final String groupID;
private final String artifact;
private final String version;
private final String dependencyString;
private final URI gitRepo;
private String reason;

/**
* Constructs a new {@code WWProjectDependency} with the specified parameters.
*
* @param type the type of the project dependency
* @param groupID the group ID of the dependency
* @param artifact the artifact ID of the dependency
* @param version the version of the dependency
*/
private WWProjectDependency(ProjectDependencyType type, String groupID, String artifact, String version) {
this(type, groupID, artifact, version, null);
}

/**
* Constructs a new {@code WWProjectDependency} with the specified parameters and optional Git repository.
*
* @param type the type of the project dependency
* @param groupID the group ID of the dependency
* @param artifact the artifact ID of the dependency
* @param version the version of the dependency
* @param gitRepo the URL of the Git repository associated with the dependency, or {@code null} if not applicable
*/
private WWProjectDependency(ProjectDependencyType type, String groupID, String artifact, String version, String gitRepo) {
this.type = type;
this.groupID = groupID;
this.artifact = artifact;
this.version = version;
this.dependencyString = String.join(":", groupID, artifact, version);
try {
if(gitRepo != null) {
this.gitRepo = new URI(gitRepo);
}
else {
this.gitRepo = null;
}
} catch (URISyntaxException e) {
throw new AssertionError(e);
}
}

public String toString() {
return dependencyString;
}

@Override
public void because(String reason) {
this.reason = reason;
}

@Override
public boolean contentEquals(Dependency dependency) {
return dependency == this;
}

@Override
public Dependency copy() {
throw new AssertionError();
}

/**
* Returns the type of the project dependency.
*
* The type indicates the category of the dependency is used to determine where it should be placed
* within the workspace.
*
* @see ProjectDependencyType
*
* @return the type of the dependency
*/
public ProjectDependencyType getType() {
return type;
}

@Override
public String getGroup() {
return groupID;
}

@Override
public String getName() {
return artifact;
}

@Override
public String getReason() {
return reason;
}

/**
* Returns the module string representation of the dependency in the format
* {@code group:artifact}.
*
* @return the module string representation
*/
public String getModule() {
return String.join(":", getGroup(), getName());
}

public URI getRepo() {
return gitRepo;
}

@Override
public String getVersion() {
return version;
}

}
Loading

0 comments on commit 8323110

Please sign in to comment.