Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated gradle to 3.4.1 and fixed some bugs #3

Merged
merged 2 commits into from
Mar 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pluginBundle {
}

task wrapper(type: Wrapper) {
gradleVersion = '3.3'
gradleVersion = '3.4.1'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jan 16 20:10:46 EST 2017
#Fri Mar 10 18:53:58 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip
12 changes: 6 additions & 6 deletions src/main/java/com/qixalite/spongestart/SpongeStartExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class SpongeStartExtension {
protected String vanillaServerFolder = "run" + File.separator + "vanilla";
protected String forgeArtifactType = "";
protected String vanillaArtifactType = "";
protected String SpongeForgeVersion = null;
protected String SpongeVanillaVersion = null;
protected String spongeForgeVersion = null;
protected String spongeVanillaVersion = null;



Expand Down Expand Up @@ -49,19 +49,19 @@ public void setVanillaArtifactType(String vanillaArtifactType) {
}

public String getSpongeVanillaVersion() {
return SpongeVanillaVersion;
return spongeVanillaVersion;
}

public String getSpongeForgeVersion() {
return SpongeForgeVersion;
return spongeForgeVersion;
}

public void setSpongeVanillaVersion(String spongeVanillaVersion) {
SpongeVanillaVersion = spongeVanillaVersion;
this.spongeVanillaVersion = spongeVanillaVersion;
}

public void setSpongeForgeVersion(String spongeForgeVersion) {
SpongeForgeVersion = spongeForgeVersion;
this.spongeForgeVersion = spongeForgeVersion;
}

public String getMinecraft() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
import com.google.common.io.Resources;
import com.qixalite.spongestart.SpongeStart;
import org.gradle.api.tasks.TaskAction;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;
import org.w3c.dom.*;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand All @@ -34,7 +33,13 @@ public void doStuff(){
configs.put("MAIN_CLASS_NAME", "StartServer");
configs.put("WORKING_DIRECTORY", "$PROJECT_DIR$/" + workingdir);
configs.put("PROGRAM_PARAMETERS", runoption);
generateConfig(Paths.get(".idea/runConfigurations/" + taskname + ".xml"), configs );
generateConfigAlternative(Paths.get(".idea/workspace.xml"), configs);
/*
if (Files.exists(Paths.get(".idea/runConfigurations/"))) {
generateConfig(Paths.get(".idea/runConfigurations/" + taskname + ".xml"), configs);
} else {

}*/
} catch (Exception e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -67,6 +72,57 @@ private void generateConfig(Path file, Map<String,String> params) throws Excepti
transformer.transform(new DOMSource(document), result);
}

private void generateConfigAlternative(Path file, Map<String,String> params) throws Exception {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().
parse(file.toString());
Node run = null;
NodeList component = document.getElementsByTagName("component");
for (int i = 0; i < component.getLength(); i++) {
if (component.item(i).getAttributes().getNamedItem("name").getNodeValue().equals("RunManager")) {
run = component.item(i);
break;
}
}

Element configuration = document.createElement("configuration");
configuration.setAttribute("default", "false");
configuration.setAttribute("name", taskname );
configuration.setAttribute("type", "Application");
configuration.setAttribute("factoryName", "Application");

Element extension = document.createElement("extension");
extension.setAttribute("name", "coverage");
extension.setAttribute("enabled", "false");
extension.setAttribute("merge", "false");
extension.setAttribute("sample_coverage", "true");
extension.setAttribute("runner", "idea");

Element mainName = document.createElement("option");
mainName.setAttribute("name", "MAIN_CLASS_NAME");
mainName.setAttribute("value", "StartServer");

Element workingDir = document.createElement("option");
workingDir.setAttribute("name", "WORKING_DIRECTORY");
workingDir.setAttribute("value", "file://$PROJECT_DIR$/"+workingdir);

Element moduleName = document.createElement("module");
moduleName.setAttribute("name", modulename);


configuration.appendChild(extension);
configuration.appendChild(mainName);
configuration.appendChild(workingDir);
configuration.appendChild(moduleName);

run.appendChild(configuration);

Transformer transformer = TransformerFactory.newInstance().newTransformer();

StreamResult result = new StreamResult(new File(file.toString()));
transformer.transform(new DOMSource(document), result);

}

public void setModulename(String modulename) {
this.modulename = modulename;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ public void setVersion(String version){
if (platform == Platform.FORGE && versionData.length == 5 ){
minecraft = versionData[0];
forgebuild = versionData[1];
try {
setUrl(new URL(SPONGE_REPO + platform.getName() + "/" + version + "/" + platform.getName() + "-" + version + ".jar"));
} catch (MalformedURLException e) {
e.printStackTrace();
}
return;
} else if (platform == Platform.VANILLA && versionData.length == 4){
minecraft = versionData[0];
Expand Down