-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a mappings server task * Generate arg list in task constructor * Fix mappings server task * Make mappings dir a task input * Apply suggestions from code review Co-authored-by: Will <[email protected]> * Update buildSrc/src/main/java/quilt/internal/tasks/mappings/EnigmaMappingsServerTask.java Co-authored-by: Will <[email protected]> --------- Co-authored-by: Will <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
9956e25
commit d03d93b
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
buildSrc/src/main/java/quilt/internal/tasks/mappings/EnigmaMappingsServerTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package quilt.internal.tasks.mappings; | ||
|
||
import org.gradle.api.Project; | ||
import org.gradle.api.file.DirectoryProperty; | ||
import org.gradle.api.file.RegularFileProperty; | ||
import org.gradle.api.tasks.InputDirectory; | ||
import org.gradle.api.tasks.InputFile; | ||
import org.gradle.api.tasks.JavaExec; | ||
import quilt.internal.Constants; | ||
import quilt.internal.tasks.MappingsTask; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public abstract class EnigmaMappingsServerTask extends JavaExec implements MappingsTask { | ||
@InputFile | ||
private final RegularFileProperty jarToMap; | ||
@InputDirectory | ||
protected abstract DirectoryProperty getMappings(); | ||
|
||
private final List<String> serverArgs; | ||
|
||
public EnigmaMappingsServerTask() { | ||
final Project project = this.getProject(); | ||
this.setGroup(Constants.Groups.MAPPINGS_GROUP); | ||
this.getMainClass().set("org.quiltmc.enigma.network.DedicatedEnigmaServer"); | ||
this.classpath(project.getConfigurations().getByName("enigmaRuntime")); | ||
this.jvmArgs("-Xmx2048m"); | ||
|
||
this.jarToMap = getObjectFactory().fileProperty(); | ||
this.getMappings().convention(project.getLayout().dir(project.provider(() -> project.file("mappings")))); | ||
|
||
this.serverArgs = new ArrayList<>(); | ||
|
||
if (project.hasProperty("port")) { | ||
this.serverArgs.add("-port"); | ||
this.serverArgs.add(project.getProperties().get("port").toString()); | ||
} | ||
if (project.hasProperty("password")) { | ||
this.serverArgs.add("-password"); | ||
this.serverArgs.add(project.getProperties().get("password").toString()); | ||
} | ||
if (project.hasProperty("log")) { | ||
this.serverArgs.add("-log"); | ||
this.serverArgs.add(project.getProperties().get("log").toString()); | ||
} else { | ||
this.serverArgs.add("-log"); | ||
this.serverArgs.add("build/logs/server.log"); | ||
} | ||
if (project.hasProperty("args")) { | ||
this.serverArgs.addAll(List.of(project.getProperties().get("args").toString().split(" "))); | ||
} | ||
} | ||
|
||
@Override | ||
public void exec() { | ||
var args = new ArrayList<>(List.of( | ||
"-jar", this.jarToMap.get().getAsFile().getAbsolutePath(), | ||
"-mappings", this.getMappings().get().getAsFile().getAbsolutePath(), | ||
"-profile", "enigma_profile.json" | ||
)); | ||
args.addAll(this.serverArgs); | ||
|
||
args(args); | ||
super.exec(); | ||
} | ||
|
||
public RegularFileProperty getJarToMap() { | ||
return this.jarToMap; | ||
} | ||
} |
d03d93b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No difference between head and target.