diff --git a/build.gradle b/build.gradle index a7d9922..c954866 100644 --- a/build.gradle +++ b/build.gradle @@ -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" } + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e70f700..628b0b0 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a877026..1cd7312 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/src/main/java/com/qixalite/spongestart/SpongeStartExtension.java b/src/main/java/com/qixalite/spongestart/SpongeStartExtension.java index e897702..1af0a04 100644 --- a/src/main/java/com/qixalite/spongestart/SpongeStartExtension.java +++ b/src/main/java/com/qixalite/spongestart/SpongeStartExtension.java @@ -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; @@ -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() { diff --git a/src/main/java/com/qixalite/spongestart/tasks/GenerateIntelijTask.java b/src/main/java/com/qixalite/spongestart/tasks/GenerateIntelijTask.java index e1ec495..3525a49 100644 --- a/src/main/java/com/qixalite/spongestart/tasks/GenerateIntelijTask.java +++ b/src/main/java/com/qixalite/spongestart/tasks/GenerateIntelijTask.java @@ -3,9 +3,7 @@ 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; @@ -13,6 +11,7 @@ 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; @@ -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(); } @@ -67,6 +72,57 @@ private void generateConfig(Path file, Map params) throws Excepti transformer.transform(new DOMSource(document), result); } + private void generateConfigAlternative(Path file, Map 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; } diff --git a/src/main/java/com/qixalite/spongestart/tasks/SpongeDownloadTask.java b/src/main/java/com/qixalite/spongestart/tasks/SpongeDownloadTask.java index b177f8f..5ea20e3 100644 --- a/src/main/java/com/qixalite/spongestart/tasks/SpongeDownloadTask.java +++ b/src/main/java/com/qixalite/spongestart/tasks/SpongeDownloadTask.java @@ -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];