diff --git a/.gitignore b/.gitignore
index 5463594..48d88bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,4 +8,5 @@ all/
logs/
.idea/
*.iml
-out/
\ No newline at end of file
+out/
+/**/dependency-reduced-pom.xml
diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar
new file mode 100644
index 0000000..9cc84ea
Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000..56bb016
--- /dev/null
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1 @@
+distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
\ No newline at end of file
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..e5cc5dc
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,10 @@
+node {
+ stage 'Checkout'
+ git branch: env.BRANCH_NAME, url: 'https://github.com/Nincraft/ModPackDownloader.git'
+
+ stage 'Build'
+ bat 'mvnw.cmd clean install'
+
+ stage 'Archive'
+ archive excludes: '**/target/Mod*-sources.jar,**/target/Mod*-javadoc.jar', includes: '**/target/Mod*.jar, modpackdownloader-core/target/classes/latest.json'
+}
\ No newline at end of file
diff --git a/modpackdownloader-cli/pom.xml b/modpackdownloader-cli/pom.xml
new file mode 100644
index 0000000..a88eeb4
--- /dev/null
+++ b/modpackdownloader-cli/pom.xml
@@ -0,0 +1,85 @@
+
+
+
+ modpackdownloader
+ com.nincraft
+ 0.5
+
+ 4.0.0
+
+ modpackdownloader-cli
+ Modpack Downloader CLI
+
+ SNAPSHOT
+
+
+
+
+ com.nincraft
+ modpackdownloader-core
+
+
+ com.beust
+ jcommander
+
+
+ org.projectlombok
+ lombok
+ provided
+
+
+ junit
+ junit
+ 4.12
+
+
+
+ ModpackDownloader-cli-${short.project.version}+${build.number}
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 1.7
+
+
+ regex-property
+ process-resources
+
+ regex-property
+
+
+ short.project.version
+ ${project.version}
+ ^(\d\.\d(?>\.\d)?)(-SNAPSHOT)?
+ $1
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.4.3
+
+
+ package
+
+ shade
+
+
+
+
+ com.nincraft.modpackdownloader.cli.ModpackDownloaderCLI
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modpackdownloader-cli/src/main/java/com/nincraft/modpackdownloader/cli/ModpackDownloaderCLI.java b/modpackdownloader-cli/src/main/java/com/nincraft/modpackdownloader/cli/ModpackDownloaderCLI.java
new file mode 100644
index 0000000..31e30c6
--- /dev/null
+++ b/modpackdownloader-cli/src/main/java/com/nincraft/modpackdownloader/cli/ModpackDownloaderCLI.java
@@ -0,0 +1,37 @@
+package com.nincraft.modpackdownloader.cli;
+
+import com.nincraft.modpackdownloader.ModpackDownloaderManager;
+import com.nincraft.modpackdownloader.handler.ApplicationUpdateHandler;
+import com.nincraft.modpackdownloader.util.Arguments;
+import com.nincraft.modpackdownloader.util.FileSystemHelper;
+import lombok.extern.log4j.Log4j2;
+
+import java.util.Arrays;
+
+@Log4j2
+public class ModpackDownloaderCLI {
+
+ public static void main(final String[] args) throws InterruptedException {
+ log.info("Starting ModpackDownloaderManager with arguments: {}", Arrays.toString(args));
+ ModpackDownloaderManager modpackDownloaderManager = new ModpackDownloaderManager(args);
+
+ Arguments arguments = modpackDownloaderManager.getArguments();
+
+ if (arguments.isHelpEnabled()) {
+ modpackDownloaderManager.getJCommander().usage();
+ return;
+ }
+
+ modpackDownloaderManager.init();
+
+ if (arguments.isClearCache()) {
+ FileSystemHelper.clearCache();
+ return;
+ }
+ if (arguments.isUpdateApp()) {
+ ApplicationUpdateHandler.update();
+ return;
+ }
+ modpackDownloaderManager.processManifests();
+ }
+}
diff --git a/src/main/resources/log4j2.xml b/modpackdownloader-cli/src/main/resources/log4j2.xml
similarity index 100%
rename from src/main/resources/log4j2.xml
rename to modpackdownloader-cli/src/main/resources/log4j2.xml
diff --git a/src/test/java/com/nincraft/modpackdownloader/ModPackDownloaderTest.java b/modpackdownloader-cli/src/test/java/com/nincraft/modpackdownloader/ModpackDownloaderCLITest.java
similarity index 67%
rename from src/test/java/com/nincraft/modpackdownloader/ModPackDownloaderTest.java
rename to modpackdownloader-cli/src/test/java/com/nincraft/modpackdownloader/ModpackDownloaderCLITest.java
index 0514f7a..5665874 100644
--- a/src/test/java/com/nincraft/modpackdownloader/ModPackDownloaderTest.java
+++ b/modpackdownloader-cli/src/test/java/com/nincraft/modpackdownloader/ModpackDownloaderCLITest.java
@@ -1,11 +1,10 @@
package com.nincraft.modpackdownloader;
import com.google.gson.Gson;
+import com.nincraft.modpackdownloader.cli.ModpackDownloaderCLI;
import com.nincraft.modpackdownloader.container.CurseFile;
import com.nincraft.modpackdownloader.container.Manifest;
import com.nincraft.modpackdownloader.util.VersionHelper;
-import junitparams.JUnitParamsRunner;
-import junitparams.Parameters;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FileUtils;
@@ -16,7 +15,6 @@
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
-import org.junit.runner.RunWith;
import java.io.File;
import java.io.FileFilter;
@@ -28,31 +26,44 @@
import java.util.stream.Collectors;
@Log4j2
-@RunWith(JUnitParamsRunner.class)
-public class ModPackDownloaderTest {
+public class ModpackDownloaderCLITest {
+
+ private final String RESOURCES = "src/test/resources/";
@After
public void cleanUp() throws IOException {
- String[] deleteFiles = {"src/test/resources/update-test.json.bak", "src/test/resources/download-test.json.bak", "src/test/resources/update-test.json"};
+ String[] deleteFiles = {RESOURCES + "update-test.json.bak", RESOURCES + "download-test.json.bak", RESOURCES + "update-test.json"};
for (String s : deleteFiles) {
new File(s).delete();
}
- File backupUpdate = new File("src/test/resources/update-test-backup.json");
- File updateFile = new File("src/test/resources/update-test.json");
+ File backupUpdate = new File(RESOURCES + "update-test-backup.json");
+ File updateFile = new File(RESOURCES + "update-test.json");
FileUtils.copyFile(backupUpdate, updateFile);
}
@Test
- @Parameters({"-manifest src/test/resources/download-test.json -releaseType release", "-manifest src/test/resources/download-test.json -maxDownloadThreads 1"})
- public void testDownload(String arg) throws InterruptedException {
- ModPackDownloader.main(arg.split(" "));
+ public void testDownloadRelease() throws InterruptedException {
+ ModpackDownloaderCLI.main(new String[]{"-manifest", RESOURCES + "download-test.json", "-releaseType", "release", "-forceDownload"});
+ File mod;
+ List mods = new ArrayList<>(Arrays.asList("Thaumcraft-1.8.9-5.2.4.jar", "DimensionalDoors-2.2.5-test9.jar", "pants.jar", "forge-1.8.9-11.15.1.1902-1.8.9-installer.jar"));
+ List checkFiles = addMods(mods);
+
+ for (String fileCheck : checkFiles) {
+ mod = new File(fileCheck);
+ Assert.assertTrue(mod.exists());
+ mod.deleteOnExit();
+ }
+ }
+
+ @Test
+ public void testDownloadMaxThreads() throws InterruptedException {
+ ModpackDownloaderCLI.main(new String[]{"-manifest", RESOURCES + "download-test.json", "-maxDownloadThreads", "1"});
File mod;
List mods = new ArrayList<>(Arrays.asList("Thaumcraft-1.8.9-5.2.4.jar", "DimensionalDoors-2.2.5-test9.jar", "pants.jar", "forge-1.8.9-11.15.1.1902-1.8.9-installer.jar"));
List checkFiles = addMods(mods);
for (String fileCheck : checkFiles) {
mod = new File(fileCheck);
- log.info("Checking {}: {}", mod, mod.exists());
Assert.assertTrue(mod.exists());
mod.deleteOnExit();
}
@@ -60,7 +71,7 @@ public void testDownload(String arg) throws InterruptedException {
@Test
public void testUpdate() throws InterruptedException, IOException, ParseException {
- String manifestName = "src/test/resources/update-test.json";
+ String manifestName = RESOURCES + "update-test.json";
File manifestFile = new File(manifestName);
String[] args = {"-manifest", manifestName, "-updateMods", "-updateForge", "-backupVersion", "1.8.9"};
@@ -68,7 +79,7 @@ public void testUpdate() throws InterruptedException, IOException, ParseExceptio
JSONObject jsonLists = (JSONObject) new JSONParser().parse(new FileReader(manifestFile));
Manifest manifest = gson.fromJson(jsonLists.toString(), Manifest.class);
String oldForgeVersion = manifest.getForgeVersion();
- ModPackDownloader.main(args);
+ ModpackDownloaderCLI.main(args);
jsonLists = (JSONObject) new JSONParser().parse(new FileReader(manifestFile));
manifest = gson.fromJson(jsonLists.toString(), Manifest.class);
for (CurseFile curseFile : manifest.getCurseFiles()) {
@@ -80,16 +91,16 @@ public void testUpdate() throws InterruptedException, IOException, ParseExceptio
@Test
public void testCheckUpdate() throws InterruptedException, IOException, ParseException {
- String manifestName = "src/test/resources/update-test.json";
+ String manifestName = RESOURCES + "update-test.json";
String[] args = {"-manifest", manifestName, "-checkMCUpdate", "1.10.2"};
- ModPackDownloader.main(args);
+ ModpackDownloaderCLI.main(args);
}
@Test
public void testAppUpdate() throws InterruptedException {
String[] args = {"-updateApp"};
- ModPackDownloader.main(args);
- FileFilter fileFilter = new WildcardFileFilter("ModPackDownloader*jar");
+ ModpackDownloaderCLI.main(args);
+ FileFilter fileFilter = new WildcardFileFilter("ModpackDownloader*jar");
File directory = new File(".");
List files = Arrays.asList(directory.listFiles(fileFilter));
Assert.assertTrue(!CollectionUtils.isEmpty(files));
diff --git a/src/test/resources/all-mods.json b/modpackdownloader-cli/src/test/resources/all-mods.json
similarity index 100%
rename from src/test/resources/all-mods.json
rename to modpackdownloader-cli/src/test/resources/all-mods.json
diff --git a/src/test/resources/botania-manifest.json b/modpackdownloader-cli/src/test/resources/botania-manifest.json
similarity index 100%
rename from src/test/resources/botania-manifest.json
rename to modpackdownloader-cli/src/test/resources/botania-manifest.json
diff --git a/src/test/resources/client-mods.json b/modpackdownloader-cli/src/test/resources/client-mods.json
similarity index 100%
rename from src/test/resources/client-mods.json
rename to modpackdownloader-cli/src/test/resources/client-mods.json
diff --git a/src/test/resources/download-test.json b/modpackdownloader-cli/src/test/resources/download-test.json
similarity index 88%
rename from src/test/resources/download-test.json
rename to modpackdownloader-cli/src/test/resources/download-test.json
index 0fde327..974dc53 100644
--- a/src/test/resources/download-test.json
+++ b/modpackdownloader-cli/src/test/resources/download-test.json
@@ -19,9 +19,9 @@
"name": "Thaumcraft"
},
{
- "fileID": 2287496,
- "projectID": 223628,
- "name": "Thaumcraft",
+ "fileID": 2423802,
+ "projectID": 59882,
+ "name": "modular-forcefield-system",
"rename": "pants.jar"
},
{
diff --git a/src/test/resources/forge.json b/modpackdownloader-cli/src/test/resources/forge.json
similarity index 100%
rename from src/test/resources/forge.json
rename to modpackdownloader-cli/src/test/resources/forge.json
diff --git a/src/test/resources/twbb-manifest.json b/modpackdownloader-cli/src/test/resources/twbb-manifest.json
similarity index 100%
rename from src/test/resources/twbb-manifest.json
rename to modpackdownloader-cli/src/test/resources/twbb-manifest.json
diff --git a/src/test/resources/update-test-backup.json b/modpackdownloader-cli/src/test/resources/update-test-backup.json
similarity index 100%
rename from src/test/resources/update-test-backup.json
rename to modpackdownloader-cli/src/test/resources/update-test-backup.json
diff --git a/src/test/resources/update-test.json b/modpackdownloader-cli/src/test/resources/update-test.json
similarity index 100%
rename from src/test/resources/update-test.json
rename to modpackdownloader-cli/src/test/resources/update-test.json
diff --git a/modpackdownloader-core/pom.xml b/modpackdownloader-core/pom.xml
new file mode 100644
index 0000000..077ca10
--- /dev/null
+++ b/modpackdownloader-core/pom.xml
@@ -0,0 +1,141 @@
+
+ 4.0.0
+
+ com.nincraft
+ modpackdownloader
+ 0.5
+
+ modpackdownloader-core
+ Modpack Downloader Core
+
+ SNAPSHOT
+ 2.8.2
+
+
+
+ com.googlecode.json-simple
+ json-simple
+ 1.1.1
+
+
+ org.apache.logging.log4j
+ log4j-api
+ ${log4j.version}
+
+
+ org.apache.commons
+ commons-collections4
+ 4.1
+
+
+ org.apache.commons
+ commons-lang3
+ 3.5
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${log4j.version}
+
+
+ commons-io
+ commons-io
+ 2.5
+
+
+ org.projectlombok
+ lombok
+ provided
+
+
+ com.google.guava
+ guava
+ 21.0
+
+
+ com.google.code.gson
+ gson
+ 2.8.0
+
+
+ net.lingala.zip4j
+ zip4j
+ 1.3.2
+
+
+ com.beust
+ jcommander
+
+
+
+ ModpackDownloader-core-${short.project.version}+${build.number}
+
+
+ src/main/resources
+ true
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 1.7
+
+
+ regex-property
+ process-resources
+
+ regex-property
+
+
+ short.project.version
+ ${project.version}
+ ^(\d\.\d(?>\.\d)?)(-SNAPSHOT)?
+ $1
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 2.6
+
+
+ resources
+ process-resources
+
+ resources
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/ModpackDownloaderManager.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/ModpackDownloaderManager.java
new file mode 100644
index 0000000..9457bfb
--- /dev/null
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/ModpackDownloaderManager.java
@@ -0,0 +1,150 @@
+package com.nincraft.modpackdownloader;
+
+import com.beust.jcommander.JCommander;
+import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
+import com.nincraft.modpackdownloader.processor.DownloadModpackProcessor;
+import com.nincraft.modpackdownloader.processor.DownloadModsProcessor;
+import com.nincraft.modpackdownloader.processor.MergeManifestsProcessor;
+import com.nincraft.modpackdownloader.processor.UpdateModsProcessor;
+import com.nincraft.modpackdownloader.util.Arguments;
+import com.nincraft.modpackdownloader.util.DownloadHelper;
+import com.nincraft.modpackdownloader.util.FileSystemHelper;
+import com.nincraft.modpackdownloader.util.Reference;
+import lombok.Getter;
+import lombok.extern.log4j.Log4j2;
+import lombok.val;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.File;
+
+/**
+ * ModpackDownloaderManager is the main class for starting a download/update.
+ */
+@Log4j2
+public class ModpackDownloaderManager {
+
+ private Reference reference = Reference.getInstance();
+ private DownloadHelper downloadHelper;
+ @Getter
+ private Arguments arguments;
+ @Getter
+ private JCommander jCommander;
+
+ /**
+ * Initializes arguments and jCommander
+ *
+ * @param args String[] of arguments for execution. See {@link Arguments} for all current parameters
+ */
+ public ModpackDownloaderManager(String[] args){
+ arguments = new Arguments();
+ jCommander = initArguments(args);
+ }
+
+ /**
+ * Starts processing the manifest files passed in. This includes downloading a modpack, updating the mods in a
+ * manifest, downloading individual mods, and merging all manifests.
+ * @throws InterruptedException exception is thrown if a processor is interrupted
+ */
+ public void processManifests() throws InterruptedException {
+ log.trace("Processing Manifests...");
+ downloadHelper = new DownloadHelper(arguments);
+ downloadModpack(arguments);
+ updateMods(arguments);
+ downloadMods(arguments);
+ mergeManifests(arguments);
+
+ log.trace("Finished Processing Manifests.");
+ }
+
+ private void downloadModpack(Arguments arguments) throws InterruptedException {
+ if (StringUtils.isNotBlank(arguments.getUpdateCurseModPack())) {
+ new DownloadModpackProcessor(arguments, downloadHelper).process();
+ arguments.setDownloadMods(true);
+ }
+ }
+
+ private void updateMods(Arguments arguments) throws InterruptedException {
+ if (shouldProcessUpdate(arguments)) {
+ new UpdateModsProcessor(arguments, downloadHelper).process();
+ }
+ }
+
+ private boolean shouldProcessUpdate(Arguments arguments) {
+ return arguments.isUpdateMods() || !StringUtils.isBlank(arguments.getCheckMCUpdate());
+ }
+
+ private void downloadMods(Arguments arguments) throws InterruptedException {
+ if (arguments.isDownloadMods()) {
+ new DownloadModsProcessor(arguments, downloadHelper).process();
+ }
+ }
+
+ private void mergeManifests(Arguments arguments) throws InterruptedException {
+ if (arguments.isMergeManifests()) {
+ new MergeManifestsProcessor(arguments, downloadHelper).process();
+ }
+ }
+
+ private void defaultArguments(Arguments arguments) {
+ if (CollectionUtils.isEmpty(arguments.getManifests())) {
+ log.debug("No manifest supplied, using default {}", reference.getDefaultManifestFile());
+ arguments.setManifests(Lists.newArrayList(new File(reference.getDefaultManifestFile())));
+ }
+ if (Strings.isNullOrEmpty(arguments.getModFolder())) {
+ log.debug("No output folder supplied, using default \"mods\"");
+ arguments.setModFolder("mods");
+ }
+ if (noProcessArgsSupplied(arguments)) {
+ arguments.setDownloadMods(true);
+ }
+ }
+
+ private boolean noProcessArgsSupplied(Arguments arguments) {
+ return !arguments.isDownloadMods() && !arguments.isUpdateMods() && !arguments.isMergeManifests()
+ && StringUtils.isBlank(arguments.getCheckMCUpdate());
+ }
+
+ private void setupRepo() {
+ log.trace("Setting up local repository...");
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append(System.getProperty("user.home"));
+ log.debug("User Home System Property detected as: {}", stringBuilder.toString());
+
+ val os = System.getProperty("os.name");
+ log.debug("Operating System detected as: {}", os);
+
+ if (os.startsWith("Windows")) {
+ stringBuilder.append(reference.getWindowsFolder());
+ } else if (os.startsWith("Mac")) {
+ stringBuilder.append(reference.getMacFolder());
+ } else {
+ stringBuilder.append(reference.getOtherFolder());
+ }
+ reference.setUserhome(stringBuilder.toString());
+
+ log.debug("User Home Folder set to: {}", reference.getUserhome());
+
+ FileSystemHelper.createFolder(reference.getUserhome());
+
+ log.debug("Setting User Agent...");
+ System.setProperty("http.agent", "Mozilla/4.0");
+
+ log.trace("Finished setting up local repository.");
+ }
+
+ /**
+ * Initializes the default arguments and sets up the local repo if needed
+ */
+ public void init() {
+ defaultArguments(arguments);
+ setupRepo();
+ }
+
+ private JCommander initArguments(final String[] args) {
+ // Initialize application arguments
+ arguments = new Arguments();
+ return new JCommander(arguments, null, args);
+ }
+}
diff --git a/src/main/java/com/nincraft/modpackdownloader/container/CurseFile.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/CurseFile.java
similarity index 90%
rename from src/main/java/com/nincraft/modpackdownloader/container/CurseFile.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/CurseFile.java
index 665f238..0cc8100 100644
--- a/src/main/java/com/nincraft/modpackdownloader/container/CurseFile.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/CurseFile.java
@@ -18,7 +18,7 @@
@Generated("org.jsonschema2pojo")
@Log4j2
@Data
-@EqualsAndHashCode(callSuper = false)
+@EqualsAndHashCode(callSuper = false, exclude = {"fileID"})
public class CurseFile extends Mod {
@SerializedName("fileID")
@@ -35,10 +35,11 @@ public class CurseFile extends Mod {
private Boolean skipUpdate;
private String projectUrl;
private String projectName;
+ private boolean curseForge;
private Reference reference = Reference.getInstance();
public CurseFile() {
- //empty
+ curseForge = true;
}
public CurseFile(CurseFile curseFile) {
@@ -49,6 +50,7 @@ public CurseFile(CurseFile curseFile) {
skipUpdate = curseFile.skipUpdate;
projectUrl = curseFile.projectUrl;
projectName = curseFile.projectName;
+ curseForge = curseFile.curseForge;
}
public CurseFile(String projectId, String projectName) {
@@ -92,11 +94,7 @@ private String buildProjectUrl() {
}
public String getCurseForgeDownloadUrl() {
- return getCurseForgeDownloadUrl(true);
- }
-
- public String getCurseForgeDownloadUrl(boolean isCurseForge) {
- String baseUrl = isCurseForge ? reference.getCurseforgeBaseUrl() : reference.getFtbBaseUrl();
+ String baseUrl = curseForge ? reference.getCurseforgeBaseUrl() : reference.getFtbBaseUrl();
return String.format(baseUrl + "%s/files/%s/download", getProjectName(),
getFileID());
}
diff --git a/src/main/java/com/nincraft/modpackdownloader/container/CurseModpackFile.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/CurseModpackFile.java
similarity index 81%
rename from src/main/java/com/nincraft/modpackdownloader/container/CurseModpackFile.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/CurseModpackFile.java
index 268c3e9..f761b23 100644
--- a/src/main/java/com/nincraft/modpackdownloader/container/CurseModpackFile.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/CurseModpackFile.java
@@ -8,9 +8,9 @@ public class CurseModpackFile extends CurseFile {
private Reference reference = Reference.getInstance();
- public CurseModpackFile(String projectId, String projectName) {
+ public CurseModpackFile(String projectId, String projectName, int fileId) {
super(projectId, projectName);
- setFileID(0);
+ setFileID(fileId);
}
@Override
diff --git a/src/main/java/com/nincraft/modpackdownloader/container/DownloadableFile.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/DownloadableFile.java
similarity index 100%
rename from src/main/java/com/nincraft/modpackdownloader/container/DownloadableFile.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/DownloadableFile.java
diff --git a/src/main/java/com/nincraft/modpackdownloader/container/Manifest.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/Manifest.java
similarity index 87%
rename from src/main/java/com/nincraft/modpackdownloader/container/Manifest.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/Manifest.java
index 537c427..07f1e3e 100644
--- a/src/main/java/com/nincraft/modpackdownloader/container/Manifest.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/Manifest.java
@@ -38,10 +38,14 @@ public String getMinecraftVersion() {
}
public String getForgeVersion() {
- if (minecraft != null && !minecraft.getModLoaders().isEmpty()) {
+ if (isMinecraftEmpty()) {
return minecraft.getModLoaders().get(0).getId();
}
return null;
}
+ private boolean isMinecraftEmpty() {
+ return minecraft != null && !minecraft.getModLoaders().isEmpty();
+ }
+
}
diff --git a/src/main/java/com/nincraft/modpackdownloader/container/Minecraft.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/Minecraft.java
similarity index 100%
rename from src/main/java/com/nincraft/modpackdownloader/container/Minecraft.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/Minecraft.java
diff --git a/src/main/java/com/nincraft/modpackdownloader/container/Mod.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/Mod.java
similarity index 100%
rename from src/main/java/com/nincraft/modpackdownloader/container/Mod.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/Mod.java
diff --git a/src/main/java/com/nincraft/modpackdownloader/container/ModLoader.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/ModLoader.java
similarity index 100%
rename from src/main/java/com/nincraft/modpackdownloader/container/ModLoader.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/ModLoader.java
diff --git a/src/main/java/com/nincraft/modpackdownloader/container/ThirdParty.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/ThirdParty.java
similarity index 100%
rename from src/main/java/com/nincraft/modpackdownloader/container/ThirdParty.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/container/ThirdParty.java
diff --git a/src/main/java/com/nincraft/modpackdownloader/handler/ApplicationUpdateHandler.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/ApplicationUpdateHandler.java
similarity index 93%
rename from src/main/java/com/nincraft/modpackdownloader/handler/ApplicationUpdateHandler.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/ApplicationUpdateHandler.java
index 4a63375..ba0f5d8 100644
--- a/src/main/java/com/nincraft/modpackdownloader/handler/ApplicationUpdateHandler.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/ApplicationUpdateHandler.java
@@ -35,11 +35,11 @@ public void update() {
log.info("No new updates found");
return;
} else {
- log.info("Update found, downloading " + appName);
+ log.info("Update found, downloading {}", appName);
}
try {
FileUtils.copyURLToFile(new URL(downloadUrl), updatedApp);
- log.info("Downloaded " + appName);
+ log.info("Downloaded {}", appName);
} catch (IOException e) {
log.error("Failed to download update", e);
}
diff --git a/src/main/java/com/nincraft/modpackdownloader/handler/CurseFileHandler.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/CurseFileHandler.java
similarity index 88%
rename from src/main/java/com/nincraft/modpackdownloader/handler/CurseFileHandler.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/CurseFileHandler.java
index c254bdf..349d606 100644
--- a/src/main/java/com/nincraft/modpackdownloader/handler/CurseFileHandler.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/CurseFileHandler.java
@@ -27,8 +27,8 @@
@Log4j2
public class CurseFileHandler implements ModHandler {
- private static Reference reference = Reference.getInstance();
- private static UpdateCheckSummarizer updateCheckSummarizer = UpdateCheckSummarizer.getInstance();
+ private Reference reference = Reference.getInstance();
+ private UpdateCheckSummarizer updateCheckSummarizer = UpdateCheckSummarizer.getInstance();
private Arguments arguments;
private DownloadHelper downloadHelper;
@@ -45,12 +45,8 @@ private void downloadCurseMod(CurseFile curseFile) {
}
}
- private CurseFile getCurseForgeDownloadLocation(final CurseFile curseFile) throws IOException {
- return getCurseForgeDownloadLocation(curseFile, true);
- }
-
- public CurseFile getCurseForgeDownloadLocation(final CurseFile curseFile, boolean isCurseForge) throws IOException {
- val url = curseFile.getCurseForgeDownloadUrl(isCurseForge);
+ public CurseFile getCurseForgeDownloadLocation(final CurseFile curseFile) throws IOException {
+ val url = curseFile.getCurseForgeDownloadUrl();
val projectName = curseFile.getName();
String encodedDownloadLocation = URLHelper.encodeSpaces(projectName);
@@ -100,7 +96,7 @@ private String getEncodedDownloadLocation(String projectName, String actualURL,
public void updateCurseFile(final CurseFile curseFile) {
if (BooleanUtils.isTrue(curseFile.getSkipUpdate())) {
- log.info("Skipped updating {}", curseFile.getName());
+ log.debug("Skipped updating {}", curseFile.getName());
return;
}
JSONObject fileListJson;
@@ -122,7 +118,7 @@ public void updateCurseFile(final CurseFile curseFile) {
val newMod = getLatestVersion(curseFile.getReleaseType() != null ? curseFile.getReleaseType() : arguments.getReleaseType(), curseFile, fileListJson, null);
if (curseFile.getFileID().compareTo(newMod.getFileID()) < 0) {
- log.info("Update found for {}. Most recent version is {}.", curseFile.getName(), newMod.getVersion());
+ log.debug("Update found for {}. Most recent version is {}.", curseFile.getName(), newMod.getVersion());
updateCurseFile(curseFile, newMod);
updateCheckSummarizer.getModList().add(curseFile);
}
@@ -157,7 +153,7 @@ private CurseFile getLatestVersion(String releaseType,
if (!"alpha".equals(releaseType) && fileIds.isEmpty()) {
if (CollectionUtils.isEmpty(arguments.getBackupVersions())) {
- log.info("No files found for Minecraft {}, disabling download of {}", mcVersion, curseFile.getName());
+ log.debug("No files found for Minecraft {}, disabling download of {}", mcVersion, curseFile.getName());
curseFile.setSkipDownload(true);
} else if (!backup) {
newMod = checkBackupVersions(releaseType, curseFile, fileListJson, mcVersion, newMod);
@@ -167,7 +163,7 @@ private CurseFile getLatestVersion(String releaseType,
}
}
if (BooleanUtils.isTrue(curseFile.getSkipDownload()) && !fileIds.isEmpty()) {
- log.info("Found files for Minecraft {}, enabling download of {}", mcVersion, curseFile.getName());
+ log.debug("Found files for Minecraft {}, enabling download of {}", mcVersion, curseFile.getName());
newMod.setSkipDownload(null);
}
@@ -197,11 +193,11 @@ private String defaultReleaseType(String releaseType) {
private CurseFile checkBackupVersions(String releaseType, CurseFile curseFile, JSONObject fileListJson, String mcVersion, CurseFile newMod) {
CurseFile returnMod = newMod;
for (String backupVersion : arguments.getBackupVersions()) {
- log.info("No files found for Minecraft {}, checking backup version {}", mcVersion, backupVersion);
+ log.debug("No files found for Minecraft {}, checking backup version {}", mcVersion, backupVersion);
returnMod = getLatestVersion(releaseType, curseFile, fileListJson, backupVersion);
if (BooleanUtils.isFalse(newMod.getSkipDownload())) {
curseFile.setSkipDownload(null);
- log.info("Found update for {} in Minecraft {}", curseFile.getName(), backupVersion);
+ log.debug("Found update for {} in Minecraft {}", curseFile.getName(), backupVersion);
break;
}
}
@@ -230,16 +226,12 @@ private JSONObject getCurseProjectJson(final CurseFile curseFile) throws ParseEx
val projectName = curseFile.getProjectName();
val modOrModPack = curseFile.getCurseforgeWidgetJson();
String urlStr = String.format(reference.getCurseforgeWidgetJsonUrl(), modOrModPack, projectName);
- if (log.isDebugEnabled()) {
- log.debug(urlStr);
- }
+ log.debug(urlStr);
try {
return URLHelper.getJsonFromUrl(urlStr);
} catch (final FileNotFoundException e) {
urlStr = String.format(reference.getCurseforgeWidgetJsonUrl(), modOrModPack, projectId + "-" + projectName);
- if (log.isDebugEnabled()) {
- log.debug(urlStr, e);
- }
+ log.debug(urlStr, e);
return URLHelper.getJsonFromUrl(urlStr);
}
}
diff --git a/src/main/java/com/nincraft/modpackdownloader/handler/ForgeHandler.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/ForgeHandler.java
similarity index 92%
rename from src/main/java/com/nincraft/modpackdownloader/handler/ForgeHandler.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/ForgeHandler.java
index 26831f5..f9347e2 100644
--- a/src/main/java/com/nincraft/modpackdownloader/handler/ForgeHandler.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/ForgeHandler.java
@@ -16,7 +16,7 @@
@Log4j2
public class ForgeHandler {
- private static Reference reference = Reference.getInstance();
+ private Reference reference = Reference.getInstance();
private Arguments arguments;
private DownloadHelper downloadHelper;
@@ -33,11 +33,11 @@ public void downloadForge(String minecraftVersion, List modLoaders) {
for (ModLoader modLoader : modLoaders) {
if (BooleanUtils.isTrue(modLoader.getDownloadInstaller())) {
- log.info("Downloading Forge installer version {}", modLoader.getId());
+ log.debug("Downloading Forge installer version {}", modLoader.getId());
downloadForgeFile(minecraftVersion, modLoader, true);
}
if (BooleanUtils.isTrue(modLoader.getDownloadUniversal())) {
- log.info("Downloading Forge universal version {}", modLoader.getId());
+ log.debug("Downloading Forge universal version {}", modLoader.getId());
downloadForgeFile(minecraftVersion, modLoader, false);
}
}
@@ -85,7 +85,7 @@ public List updateForge(String minecraftVersion, List modL
String manifestForgeVersion = modLoader.getId().substring(modLoader.getId().indexOf('-') + 1);
if (VersionHelper.compareVersions(manifestForgeVersion, updatedForgeVersion) < 0) {
- log.info("Newer version of Forge found, updating to {}", updatedForgeVersion);
+ log.debug("Newer version of Forge found, updating to {}", updatedForgeVersion);
modLoader.setId("forge-" + updatedForgeVersion);
}
diff --git a/src/main/java/com/nincraft/modpackdownloader/handler/ModHandler.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/ModHandler.java
similarity index 100%
rename from src/main/java/com/nincraft/modpackdownloader/handler/ModHandler.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/ModHandler.java
diff --git a/src/main/java/com/nincraft/modpackdownloader/handler/ThirdPartyModHandler.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/ThirdPartyModHandler.java
similarity index 90%
rename from src/main/java/com/nincraft/modpackdownloader/handler/ThirdPartyModHandler.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/ThirdPartyModHandler.java
index 287b0d1..27e34d2 100644
--- a/src/main/java/com/nincraft/modpackdownloader/handler/ThirdPartyModHandler.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/handler/ThirdPartyModHandler.java
@@ -20,7 +20,7 @@ public void downloadMod(final Mod mod) {
@Override
public void updateMod(final Mod mod) {
- log.info("Updating Third Party Mods is not supported.");
+ log.debug("Updating Third Party Mods is not supported.");
}
}
diff --git a/src/main/java/com/nincraft/modpackdownloader/processor/AbstractProcessor.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/AbstractProcessor.java
similarity index 82%
rename from src/main/java/com/nincraft/modpackdownloader/processor/AbstractProcessor.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/AbstractProcessor.java
index 36fc8be..43ea28d 100644
--- a/src/main/java/com/nincraft/modpackdownloader/processor/AbstractProcessor.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/AbstractProcessor.java
@@ -1,6 +1,5 @@
package com.nincraft.modpackdownloader.processor;
-import com.beust.jcommander.internal.Maps;
import com.google.gson.Gson;
import com.nincraft.modpackdownloader.container.CurseFile;
import com.nincraft.modpackdownloader.container.Manifest;
@@ -23,10 +22,7 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
@@ -34,19 +30,19 @@
@Log4j2
public abstract class AbstractProcessor {
- static final Comparator MOD_COMPARATOR = Comparator.comparing(mod -> mod.getName().toLowerCase());
- static final Map, ModHandler> MOD_HANDLERS = Maps.newHashMap();
+ final Comparator modComparator = Comparator.comparing(mod -> mod.getName().toLowerCase());
+ final Map, ModHandler> modHandlerHashMap = new HashMap<>();
@Getter
@Setter
- private static ExecutorService executorService;
- private static Gson gson = new Gson();
- Map manifestMap = Maps.newHashMap();
+ private ExecutorService executorService;
+ private Gson gson = new Gson();
+ Map manifestMap = new HashMap<>();
Arguments arguments;
DownloadHelper downloadHelper;
AbstractProcessor(Arguments arguments, DownloadHelper downloadHelper) {
- MOD_HANDLERS.put(CurseFile.class, new CurseFileHandler(arguments, downloadHelper));
- MOD_HANDLERS.put(ThirdParty.class, new ThirdPartyModHandler(downloadHelper));
+ modHandlerHashMap.put(CurseFile.class, new CurseFileHandler(arguments, downloadHelper));
+ modHandlerHashMap.put(ThirdParty.class, new ThirdPartyModHandler(downloadHelper));
this.arguments = arguments;
this.downloadHelper = downloadHelper;
buildManifestList(arguments.getManifests());
@@ -108,9 +104,14 @@ List buildModList(final File file, final Manifest manifest) {
modList.addAll(manifest.getCurseFiles());
modList.addAll(manifest.getThirdParty());
+ val modSet = new HashSet();
+ modSet.addAll(modList);
+ modList.clear();
+ modList.addAll(modSet);
+
modList.forEach(Mod::init);
- modList.sort(MOD_COMPARATOR);
+ modList.sort(modComparator);
log.trace("Finished Building Mod List.");
return modList;
diff --git a/src/main/java/com/nincraft/modpackdownloader/processor/DownloadModpackProcessor.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/DownloadModpackProcessor.java
similarity index 88%
rename from src/main/java/com/nincraft/modpackdownloader/processor/DownloadModpackProcessor.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/DownloadModpackProcessor.java
index e651075..319feda 100644
--- a/src/main/java/com/nincraft/modpackdownloader/processor/DownloadModpackProcessor.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/DownloadModpackProcessor.java
@@ -21,7 +21,6 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import java.nio.charset.Charset;
import java.util.Map;
import java.util.Map.Entry;
@@ -80,13 +79,10 @@ boolean preprocess(final Entry manifest) {
boolean process(final Entry manifest) throws InterruptedException {
boolean returnStatus;
log.trace("Updating Curse modpack");
- String modPackIdName;
- try {
- modPackIdName = FileUtils.readFileToString(new File("modpackid"), Charset.defaultCharset());
- log.info("Found modpackid file with id {}", modPackIdName);
- } catch (IOException e) {
- log.error("Could not find modpackid file", e);
- return false;
+ String modPackIdName = arguments.getUpdateCurseModPack();
+ int fileId = 0;
+ if (NumberUtils.isParsable(arguments.getCurseFileId())) {
+ fileId = Integer.parseInt(arguments.getCurseFileId());
}
String modPackId = modPackIdName.substring(0, modPackIdName.indexOf('-'));
if (!NumberUtils.isCreatable(modPackId)) {
@@ -94,13 +90,13 @@ boolean process(final Entry manifest) throws InterruptedExceptio
return false;
}
String modPackName = modPackIdName.substring(modPackIdName.indexOf('-') + 1);
- CurseModpackFile modPack = new CurseModpackFile(modPackId, modPackName);
+ CurseModpackFile modPack = new CurseModpackFile(modPackId, modPackName, fileId);
modPack.init();
arguments.setMcVersion("*");
curseFileHandler.updateCurseFile(modPack);
arguments.setModFolder(".");
modPack.setDownloadUrl(modPack.getCurseForgeDownloadUrl());
- getDownloadUrl(modPack, true);
+ getDownloadUrl(modPack);
if (!modPack.getFileName().contains(".zip")) {
modPack.setFileName(modPack.getName() + ".zip");
}
@@ -108,13 +104,14 @@ boolean process(final Entry manifest) throws InterruptedExceptio
if (DownloadStatus.FAILURE.equals(downloadStatus)) {
log.warn("Failed to download {}. Attempting redownload with FTB URL", modPack.getName());
- modPack.setDownloadUrl(modPack.getCurseForgeDownloadUrl(false));
- getDownloadUrl(modPack, false);
+ modPack.setCurseForge(false);
+ modPack.setDownloadUrl(modPack.getCurseForgeDownloadUrl());
+ getDownloadUrl(modPack);
downloadStatus = downloadHelper.downloadFile(modPack, false);
}
if (DownloadStatus.SKIPPED.equals(downloadStatus)) {
- log.info("No new updates found for {}", modPack.getName());
+ log.debug("No new updates found for {}", modPack.getName());
}
returnStatus = checkSuccessfulDownloadStatus(downloadStatus);
@@ -127,7 +124,7 @@ boolean process(final Entry manifest) throws InterruptedExceptio
try {
ZipFile modPackZip = new ZipFile(modPack.getFileName());
modPackZip.extractAll(".");
- log.info("Successfully unzipped modpack");
+ log.debug("Successfully unzipped modpack");
} catch (ZipException e) {
log.error("Could not unzip modpack", e);
try {
@@ -153,9 +150,9 @@ boolean postProcess(final Entry manifest) {
return true;
}
- private void getDownloadUrl(CurseFile modPack, boolean isCurseForge) {
+ private void getDownloadUrl(CurseFile modPack) {
try {
- curseFileHandler.getCurseForgeDownloadLocation(modPack, isCurseForge);
+ curseFileHandler.getCurseForgeDownloadLocation(modPack);
} catch (IOException e) {
log.error("Failed to get download location for {}", modPack.getName(), e);
}
diff --git a/src/main/java/com/nincraft/modpackdownloader/processor/DownloadModsProcessor.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/DownloadModsProcessor.java
similarity index 74%
rename from src/main/java/com/nincraft/modpackdownloader/processor/DownloadModsProcessor.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/DownloadModsProcessor.java
index 9ebc536..3923572 100644
--- a/src/main/java/com/nincraft/modpackdownloader/processor/DownloadModsProcessor.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/DownloadModsProcessor.java
@@ -21,47 +21,45 @@
@Log4j2
public class DownloadModsProcessor extends AbstractProcessor {
- private static final List MOD_LIST = Lists.newArrayList();
- private static Reference reference = Reference.getInstance();
+ private final List modList = Lists.newArrayList();
+ private Reference reference = Reference.getInstance();
public DownloadModsProcessor(Arguments arguments, DownloadHelper downloadHelper) {
super(arguments, downloadHelper);
}
private void downloadMods(final Manifest manifest) {
- setExecutorService(Executors.newFixedThreadPool(arguments.getMaxDownloadThreads() > 0 ? arguments.getMaxDownloadThreads() : MOD_LIST.size() + 1));
+ setExecutorService(Executors.newFixedThreadPool(arguments.getMaxDownloadThreads() > 0 ? arguments.getMaxDownloadThreads() : modList.size() + 1));
ForgeHandler forgeHandler = new ForgeHandler(arguments, downloadHelper);
Runnable forgeThread = new Thread(() -> forgeHandler.downloadForge(manifest.getMinecraftVersion(), manifest.getMinecraft().getModLoaders()));
getExecutorService().execute(forgeThread);
- log.trace("Downloading {} mods...", MOD_LIST.size());
+ log.trace("Downloading {} mods...", modList.size());
int downloadCount = 1;
- for (val mod : MOD_LIST) {
- log.info(reference.getDownloadingModXOfY(), mod.getName(), downloadCount++,
+ for (val mod : modList) {
+ log.debug(reference.getDownloadingModXOfY(), mod.getName(), downloadCount++,
Reference.downloadTotal);
Runnable modDownload = new Thread(() -> {
- MOD_HANDLERS.get(mod.getClass()).downloadMod(mod);
+ modHandlerHashMap.get(mod.getClass()).downloadMod(mod);
Reference.downloadCount++;
log.trace("Finished downloading {}", mod.getName());
});
getExecutorService().execute(modDownload);
}
getExecutorService().shutdown();
- log.trace("Finished downloading {} mods.", MOD_LIST.size());
+ log.trace("Finished downloading {} mods.", modList.size());
}
@Override
protected void init(final Map manifestMap) {
for (val manifestEntry : manifestMap.entrySet()) {
- MOD_LIST.addAll(buildModList(manifestEntry.getKey(), manifestEntry.getValue()));
+ modList.addAll(buildModList(manifestEntry.getKey(), manifestEntry.getValue()));
}
- Reference.downloadTotal = MOD_LIST.size();
- if (log.isDebugEnabled()) {
- log.debug("A total of {} mods will be downloaded.", Reference.downloadTotal);
- }
+ Reference.downloadTotal = modList.size();
+ log.debug("A total of {} mods will be downloaded.", Reference.downloadTotal);
}
@Override
@@ -73,7 +71,7 @@ protected boolean process(final Entry manifestEntry) {
@Override
protected boolean postProcess(final Entry manifestEntry) {
moveOverrides(manifestEntry.getValue());
- DownloadHelper.getDownloadSummarizer().summarize();
+ downloadHelper.getDownloadSummarizer().summarize();
return true;
}
@@ -84,7 +82,7 @@ private void moveOverrides(Manifest manifest) {
if (overridesDirectory.exists()) {
FileUtils.copyDirectory(overridesDirectory, new File("."));
FileUtils.deleteDirectory(overridesDirectory);
- log.info("Successfully moved overrides: {}", manifest.getOverrides());
+ log.debug("Successfully moved overrides: {}", manifest.getOverrides());
}
} catch (IOException e) {
log.error("Unable to move {} folder", manifest.getOverrides(), e);
diff --git a/src/main/java/com/nincraft/modpackdownloader/processor/MergeManifestsProcessor.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/MergeManifestsProcessor.java
similarity index 100%
rename from src/main/java/com/nincraft/modpackdownloader/processor/MergeManifestsProcessor.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/MergeManifestsProcessor.java
diff --git a/src/main/java/com/nincraft/modpackdownloader/processor/UpdateModsProcessor.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/UpdateModsProcessor.java
similarity index 83%
rename from src/main/java/com/nincraft/modpackdownloader/processor/UpdateModsProcessor.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/UpdateModsProcessor.java
index e5fa2ea..bca0c7b 100644
--- a/src/main/java/com/nincraft/modpackdownloader/processor/UpdateModsProcessor.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/processor/UpdateModsProcessor.java
@@ -9,6 +9,7 @@
import com.nincraft.modpackdownloader.util.Arguments;
import com.nincraft.modpackdownloader.util.DownloadHelper;
import com.nincraft.modpackdownloader.util.Reference;
+import com.nincraft.modpackdownloader.util.URLHelper;
import lombok.Getter;
import lombok.extern.log4j.Log4j2;
import lombok.val;
@@ -23,14 +24,12 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.Executors;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
@Log4j2
public class UpdateModsProcessor extends AbstractProcessor {
- private static Reference reference = Reference.getInstance();
- private static UpdateCheckSummarizer updateCheckSummarizer = UpdateCheckSummarizer.getInstance();
+ private Reference reference = Reference.getInstance();
+ private UpdateCheckSummarizer updateCheckSummarizer = UpdateCheckSummarizer.getInstance();
@Getter
private boolean checkUpdate;
@@ -49,7 +48,7 @@ private void backupCurseManifest(final File manifestFile) {
private void updateMods(final Manifest manifest, final List modList) {
if (!manifest.getBatchAddCurse().isEmpty()) {
- log.info("Found batch add for Curse");
+ log.debug("Found batch add for Curse");
addBatch(manifest, modList);
}
@@ -70,9 +69,9 @@ private void updateMods(final Manifest manifest, final List modList) {
for (val mod : modList) {
log.info(reference.getUpdatingModXOfY(), mod.getName(), updateCount++, Reference.updateTotal);
Runnable modUpdate = new Thread(() -> {
- MOD_HANDLERS.get(mod.getClass()).updateMod(mod);
+ modHandlerHashMap.get(mod.getClass()).updateMod(mod);
Reference.updateCount++;
- log.info("Finished updating {}", mod.getName());
+ log.trace("Finished updating {}", mod.getName());
});
getExecutorService().execute(modUpdate);
}
@@ -85,26 +84,13 @@ private void addBatch(final Manifest manifestFile, final List modList) {
String projectIdPattern = "(\\d)+";
String projectNamePattern = "(((?:[a-z][a-z]+))(-)?)+";
for (String projectUrl : manifestFile.getBatchAddCurse()) {
- String projectIdName = projectUrl.substring(projectUrl.lastIndexOf('/') + 1);
- Pattern pId = Pattern.compile(projectIdPattern);
- Matcher m = pId.matcher(projectIdName);
- String projectId = null;
- if (m.find()) {
- projectId = m.group();
- }
-
- String projectName = null;
-
- pId = Pattern.compile(projectNamePattern);
- m = pId.matcher(projectIdName);
- if (m.find()) {
- projectName = m.group();
- }
+ String projectId = URLHelper.parseCurseUrl(projectIdPattern, projectUrl);
+ String projectName = URLHelper.parseCurseUrl(projectNamePattern, projectUrl);
if (projectId != null && projectName != null) {
curseFile = new CurseFile(projectId, projectName);
curseFile.init();
- log.info("Adding {} from batch add", curseFile.getName());
+ log.debug("Adding {} from batch add", curseFile.getName());
modList.add(curseFile);
manifestFile.getCurseFiles().add(curseFile);
} else {
@@ -114,10 +100,10 @@ private void addBatch(final Manifest manifestFile, final List modList) {
}
private void updateManifest(final File file, final Manifest manifest) {
- log.info("Updating Manifest File...");
+ log.trace("Updating Manifest File...");
// Sort Mod Lists
- manifest.getCurseFiles().sort(MOD_COMPARATOR);
- manifest.getThirdParty().sort(MOD_COMPARATOR);
+ manifest.getCurseFiles().sort(modComparator);
+ manifest.getThirdParty().sort(modComparator);
// Clean up Empty Lists
cleanupLists(manifest);
diff --git a/src/main/java/com/nincraft/modpackdownloader/status/DownloadStatus.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/status/DownloadStatus.java
similarity index 100%
rename from src/main/java/com/nincraft/modpackdownloader/status/DownloadStatus.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/status/DownloadStatus.java
diff --git a/src/main/java/com/nincraft/modpackdownloader/summary/DownloadSummarizer.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/summary/DownloadSummarizer.java
similarity index 90%
rename from src/main/java/com/nincraft/modpackdownloader/summary/DownloadSummarizer.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/summary/DownloadSummarizer.java
index ae17dcb..e0cda0c 100644
--- a/src/main/java/com/nincraft/modpackdownloader/summary/DownloadSummarizer.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/summary/DownloadSummarizer.java
@@ -9,9 +9,9 @@
@Log4j2
public class DownloadSummarizer implements Observer {
- private static int successTotal = 0;
- private static int failureTotal = 0;
- private static int skipTotal = 0;
+ private int successTotal = 0;
+ private int failureTotal = 0;
+ private int skipTotal = 0;
@Override
public void update(Observable o, Object arg) {
diff --git a/src/main/java/com/nincraft/modpackdownloader/summary/UpdateCheckSummarizer.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/summary/UpdateCheckSummarizer.java
similarity index 100%
rename from src/main/java/com/nincraft/modpackdownloader/summary/UpdateCheckSummarizer.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/summary/UpdateCheckSummarizer.java
diff --git a/src/main/java/com/nincraft/modpackdownloader/util/Arguments.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/Arguments.java
similarity index 86%
rename from src/main/java/com/nincraft/modpackdownloader/util/Arguments.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/Arguments.java
index e6d8e5b..3cb7545 100644
--- a/src/main/java/com/nincraft/modpackdownloader/util/Arguments.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/Arguments.java
@@ -2,74 +2,56 @@
import com.beust.jcommander.Parameter;
import com.beust.jcommander.converters.FileConverter;
-import com.nincraft.modpackdownloader.validation.ExistingFile;
import com.nincraft.modpackdownloader.validation.ReleaseType;
-import lombok.Getter;
-import lombok.Setter;
+import lombok.Data;
+import lombok.NoArgsConstructor;
import java.io.File;
import java.util.List;
+@Data
+@NoArgsConstructor
public class Arguments {
- @Getter
- @Setter
@Parameter(names = {"-modFolder", "-folder", "-mods"}, description = "Folder where mods will be downloaded")
private String modFolder;
- @Getter
- @Setter
@Parameter(names = {"-mcVersion"}, description = "Minecraft version")
private String mcVersion;
- @Getter
@Parameter(names = {"-backupVersion", "-backupVersions"}, description = "Backup Minecraft version, during updates" +
"when no version is found for the main Minecraft version, this version will be checked as well")
private List backupVersions;
- @Getter
@Parameter(names = {"-releaseType"}, description = "Release type for Curse updates. Acceptable parameters" +
"are release, beta, and alpha", validateWith = ReleaseType.class)
private String releaseType;
- @Getter
@Parameter(names = {"-maxDownloadThreads"}, description = "Max number of threads for downloading mods. The default is however many mods are in your manifest")
private int maxDownloadThreads;
- @Getter
@Parameter(names = {"-forceDownload"}, description = "Forces downloading instead of pulling from the cache")
private boolean forceDownload = false;
- @Getter
@Parameter(names = {"-generateUrlTxt"}, description = "Generates URL txt files for SKCraft Launcher." +
"Currently not implemented")
private boolean generateUrlTxt;
- @Getter
@Parameter(names = {"-updateForge"}, description = "Updates manifest to the latest version of Forge for the" +
"specified Minecraft version")
private boolean updateForge;
- @Getter
- @Parameter(names = {"-updateCurseModPack"}, description = "Updates the Curse modpack instance")
- private boolean updateCurseModPack;
- @Getter
+ @Parameter(names = {"-updateCurseModPack"}, description = "Updates the Curse modpack instance, takes in a Curse modpack slug")
+ private String updateCurseModPack;
+ @Parameter(names = {"-curseFileId"}, description = "File id of the Curse modpack you want to download")
+ private String curseFileId;
@Parameter(names = {"-updateApp"}, description = "Downloads latest version of ModPack Downloader")
private boolean updateApp;
- @Getter
@Parameter(names = {"-clearCache"}, description = "Clears ModPack Downloader's cache")
private boolean clearCache;
- @Getter
- @Setter
@Parameter(names = {"-manifest", "-manifests"}, description = "List of manifests to use for downloading/updating",
- listConverter = FileConverter.class, validateWith = ExistingFile.class)
+ listConverter = FileConverter.class)
private List manifests;
- @Getter
- @Setter
@Parameter(names = {"-downloadMods"}, description = "Downloads mods in the given manifests." +
"Enabled by default if update and merge are not")
private boolean downloadMods;
- @Getter
@Parameter(names = {"-updateMods"}, description = "Updates mods in the given manifests")
private boolean updateMods;
- @Getter
@Parameter(names = {"-checkMCUpdate"}, description = "Checks mods for updates given the Minecraft version (passed to this parameter) and manifests")
private String checkMCUpdate;
- @Getter
@Parameter(names = {"-mergeManifests"}, description = "Merges the given manifests into one manifest")
private boolean mergeManifests;
- @Getter
@Parameter(names = {"-help"}, description = "Displays this great message", help = true)
private boolean helpEnabled;
}
diff --git a/src/main/java/com/nincraft/modpackdownloader/util/DownloadHelper.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/DownloadHelper.java
similarity index 81%
rename from src/main/java/com/nincraft/modpackdownloader/util/DownloadHelper.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/DownloadHelper.java
index cb7dc22..b39e009 100644
--- a/src/main/java/com/nincraft/modpackdownloader/util/DownloadHelper.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/DownloadHelper.java
@@ -17,7 +17,7 @@
public class DownloadHelper extends Observable {
@Getter
- private static final DownloadSummarizer downloadSummarizer = new DownloadSummarizer();
+ private DownloadSummarizer downloadSummarizer = new DownloadSummarizer();
private Arguments arguments;
public DownloadHelper(Arguments arguments) {
@@ -27,10 +27,10 @@ public DownloadHelper(Arguments arguments) {
/**
* Downloads a {@link DownloadableFile} moves it to the correct folder. Downloads to the local cache and then
- * copies to the download folder. Returns a {@link DownloadStatus}
+ * copies to the download folder.
*
- * @param downloadableFile
- * @return {@link DownloadStatus}
+ * @param downloadableFile a DownloadableFile with a download URL
+ * @return status of the download, failed, skipped, or success
*/
public DownloadStatus downloadFile(final DownloadableFile downloadableFile) {
return downloadFile(downloadableFile, true);
@@ -38,22 +38,22 @@ public DownloadStatus downloadFile(final DownloadableFile downloadableFile) {
/**
* Downloads a {@link DownloadableFile} moves it to the correct folder. Downloads to the local cache if
- * downloadToLocalRepo is set to true and then copies to the download folder. Returns a {@link DownloadStatus}
+ * downloadToLocalRepo is set to true and then copies to the download folder.
*
- * @param downloadableFile
- * @param downloadToLocalRepo
- * @return {@link DownloadStatus}
+ * @param downloadableFile a DownloadableFile with a download URL
+ * @param downloadToLocalRepo set to true to keep a copy of the DownloadableFile in local cache
+ * @return status of the download, failed, skipped, or success
*/
public DownloadStatus downloadFile(final DownloadableFile downloadableFile, boolean downloadToLocalRepo) {
DownloadStatus status = DownloadStatus.FAILURE;
if (BooleanUtils.isTrue(downloadableFile.getSkipDownload())) {
- log.info("Skipped downloading {}", downloadableFile.getName());
+ log.debug("Skipped downloading {}", downloadableFile.getName());
return notifyStatus(DownloadStatus.SKIPPED);
}
val decodedFileName = URLHelper.decodeSpaces(downloadableFile.getFileName());
if (FileSystemHelper.getDownloadedFile(decodedFileName, downloadableFile.getFolder()).exists() && !arguments.isForceDownload()) {
- log.info("Found {} already downloaded, skipping", decodedFileName);
+ log.debug("Found {} already downloaded, skipping", decodedFileName);
return notifyStatus(DownloadStatus.SKIPPED);
}
diff --git a/src/main/java/com/nincraft/modpackdownloader/util/FileSystemHelper.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/FileSystemHelper.java
similarity index 78%
rename from src/main/java/com/nincraft/modpackdownloader/util/FileSystemHelper.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/FileSystemHelper.java
index db411d6..dbf55d2 100644
--- a/src/main/java/com/nincraft/modpackdownloader/util/FileSystemHelper.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/FileSystemHelper.java
@@ -14,7 +14,7 @@
@UtilityClass
public final class FileSystemHelper {
- private static Reference reference = Reference.getInstance();
+ private Reference reference = Reference.getInstance();
public static void createFolder(final String folder) {
if (folder != null) {
@@ -25,7 +25,7 @@ public static void createFolder(final String folder) {
}
}
- public static void moveFromLocalRepo(final DownloadableFile downloadableFile, final String fileName, boolean downloadToLocalRepo, String modFolder) {
+ static void moveFromLocalRepo(final DownloadableFile downloadableFile, final String fileName, boolean downloadToLocalRepo, String modFolder) {
val newProjectName = getProjectNameOrDefault(downloadableFile.getName());
String folder = downloadableFile.getFolder();
if (Strings.isNullOrEmpty(folder)) {
@@ -46,19 +46,24 @@ public static void moveFromLocalRepo(final DownloadableFile downloadableFile, fi
}
}
- public static boolean isInLocalRepo(final String projectName, final String fileName) {
+ static boolean isInLocalRepo(final String projectName, final String fileName) {
return getLocalFile(fileName, getProjectNameOrDefault(projectName)).exists();
}
public static File getDownloadedFile(final String fileName, String modFolder) {
- return getDownloadedFile(fileName, null, modFolder);
+ if (modFolder != null) {
+ createFolder(modFolder);
+ return new File(modFolder + File.separator + fileName);
+ } else {
+ return new File(fileName);
+ }
}
private static String getProjectNameOrDefault(final String projectName) {
return projectName != null ? projectName : "thirdParty";
}
- public static File getLocalFile(DownloadableFile downloadableFile) {
+ static File getLocalFile(DownloadableFile downloadableFile) {
return getLocalFile(downloadableFile.getFileName(), downloadableFile.getName());
}
@@ -66,18 +71,6 @@ private static File getLocalFile(final String fileName, final String newProjectN
return new File(reference.getUserhome() + newProjectName + File.separator + fileName);
}
- private static File getDownloadedFile(String fileName, String folder, String modFolder) {
- if (folder != null) {
- createFolder(folder);
- return new File(folder + File.separator + fileName);
- } else if (modFolder != null) {
- createFolder(modFolder);
- return new File(modFolder + File.separator + fileName);
- } else {
- return new File(fileName);
- }
- }
-
public static void clearCache() {
File cache = new File(reference.getUserhome());
log.info("Clearing cache at {}", reference.getUserhome());
diff --git a/src/main/java/com/nincraft/modpackdownloader/util/Reference.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/Reference.java
similarity index 88%
rename from src/main/java/com/nincraft/modpackdownloader/util/Reference.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/Reference.java
index fd51539..394d5f3 100644
--- a/src/main/java/com/nincraft/modpackdownloader/util/Reference.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/Reference.java
@@ -2,8 +2,12 @@
import lombok.Data;
import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+import static lombok.AccessLevel.PRIVATE;
@Data
+@NoArgsConstructor(access = PRIVATE)
public class Reference {
@Getter
private static final Reference instance = new Reference();
@@ -28,15 +32,10 @@ public class Reference {
private char urlDelimiter = '/';
private String defaultManifestFile = "manifest.json";
private String userhome;
- private String os;
- private String updateAppUrl = "http://play.nincraft.com:8080/job/Mod%20Pack%20Downloader/lastSuccessfulBuild/artifact/target/classes/latest.json";
+ private String updateAppUrl = "http://play.nincraft.com:8080/job/Mod%20Pack%20Downloader/lastSuccessfulBuild/artifact/modpackdownloader-core/target/classes/latest.json";
private String forgeUrl = "http://files.minecraftforge.net/maven/net/minecraftforge/forge/";
private String forgeInstaller = "-installer.jar";
private String forgeUniversal = "-universal.jar";
private String forgeUpdateUrl = "http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json";
private String javaContentType = "application/java-archive";
-
- private Reference() {
- //no-op
- }
}
diff --git a/src/main/java/com/nincraft/modpackdownloader/util/URLHelper.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/URLHelper.java
similarity index 58%
rename from src/main/java/com/nincraft/modpackdownloader/util/URLHelper.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/URLHelper.java
index 228b85c..704396c 100644
--- a/src/main/java/com/nincraft/modpackdownloader/util/URLHelper.java
+++ b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/URLHelper.java
@@ -10,23 +10,35 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
@UtilityClass
@Log4j2
public final class URLHelper {
- private static final String WHITESPACE = " ";
- private static final String WHITESPACE_ENCODED = "%20";
+ private String whitespace = " ";
+ private String whitespaceEncoded = "%20";
public static String encodeSpaces(final String url) {
- return url.replace(WHITESPACE, WHITESPACE_ENCODED);
+ return url.replace(whitespace, whitespaceEncoded);
}
public static String decodeSpaces(final String url) {
- return url.replace(WHITESPACE_ENCODED, WHITESPACE);
+ return url.replace(whitespaceEncoded, whitespace);
}
public static JSONObject getJsonFromUrl(final String url) throws ParseException, IOException {
JSONParser parser = new JSONParser();
return (JSONObject) parser.parse(new BufferedReader(new InputStreamReader(new URL(url).openStream())));
}
+
+ public static String parseCurseUrl(String projectIdPattern, String projectUrl) {
+ String projectIdName = projectUrl.substring(projectUrl.lastIndexOf('/') + 1);
+ Pattern pId = Pattern.compile(projectIdPattern);
+ Matcher m = pId.matcher(projectIdName);
+ if (m.find()) {
+ return m.group();
+ }
+ return null;
+ }
}
diff --git a/src/main/java/com/nincraft/modpackdownloader/util/VersionHelper.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/VersionHelper.java
similarity index 100%
rename from src/main/java/com/nincraft/modpackdownloader/util/VersionHelper.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/util/VersionHelper.java
diff --git a/src/main/java/com/nincraft/modpackdownloader/validation/ReleaseType.java b/modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/validation/ReleaseType.java
similarity index 100%
rename from src/main/java/com/nincraft/modpackdownloader/validation/ReleaseType.java
rename to modpackdownloader-core/src/main/java/com/nincraft/modpackdownloader/validation/ReleaseType.java
diff --git a/modpackdownloader-core/src/main/resources/latest.json b/modpackdownloader-core/src/main/resources/latest.json
new file mode 100644
index 0000000..783f51a
--- /dev/null
+++ b/modpackdownloader-core/src/main/resources/latest.json
@@ -0,0 +1,3 @@
+{
+ "url": "http://play.nincraft.com:8080/job/Mod%20Pack%20Downloader/lastSuccessfulBuild/artifact/modpackdownloader-core/target/${project.build.finalName}.jar"
+}
\ No newline at end of file
diff --git a/modpackdownloader-core/src/test/resources/log4j2.xml b/modpackdownloader-core/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..d4bbc0a
--- /dev/null
+++ b/modpackdownloader-core/src/test/resources/log4j2.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modpackdownloader-gui/pom.xml b/modpackdownloader-gui/pom.xml
new file mode 100644
index 0000000..b143441
--- /dev/null
+++ b/modpackdownloader-gui/pom.xml
@@ -0,0 +1,75 @@
+
+
+
+ modpackdownloader
+ com.nincraft
+ 0.5
+
+ 4.0.0
+
+ modpackdownloader-gui
+ Modpack Downloader GUI
+
+ SNAPSHOT
+
+
+
+ com.nincraft
+ modpackdownloader-core
+
+
+ org.projectlombok
+ lombok
+
+
+
+ ModpackDownloader-gui-${short.project.version}+${build.number}
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 1.7
+
+
+ regex-property
+ process-resources
+
+ regex-property
+
+
+ short.project.version
+ ${project.version}
+ ^(\d\.\d(?>\.\d)?)(-SNAPSHOT)?
+ $1
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.4.3
+
+
+ package
+
+ shade
+
+
+
+
+ com.nincraft.modpackdownloader.gui.ModpackDownloaderGUI
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modpackdownloader-gui/src/main/java/com/nincraft/modpackdownloader/gui/Controller.java b/modpackdownloader-gui/src/main/java/com/nincraft/modpackdownloader/gui/Controller.java
new file mode 100644
index 0000000..9bbe760
--- /dev/null
+++ b/modpackdownloader-gui/src/main/java/com/nincraft/modpackdownloader/gui/Controller.java
@@ -0,0 +1,62 @@
+package com.nincraft.modpackdownloader.gui;
+
+import com.nincraft.modpackdownloader.ModpackDownloaderManager;
+import javafx.application.HostServices;
+import javafx.fxml.FXML;
+import javafx.scene.control.*;
+import lombok.extern.log4j.Log4j2;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Log4j2
+public class Controller {
+
+ @FXML
+ private ProgressBar progressBar;
+ @FXML
+ private TextArea logTextArea;
+ @FXML
+ private TextField projectIdTextBox;
+ @FXML
+ private TextField fileIdTextBox;
+ @FXML
+ private Button downloadButton;
+ @FXML
+ private Hyperlink reportIssue;
+ @FXML
+ private Hyperlink help;
+ private HostServices hostServices;
+
+ void init() {
+ progressBar.setProgress(0);
+ help.setOnAction(event -> hostServices.showDocument("https://github.com/Nincraft/ModPackDownloader/wiki/GUI-Usage"));
+ reportIssue.setOnAction(event -> hostServices.showDocument("https://github.com/Nincraft/ModPackDownloader/issues/new"));
+ downloadButton.setOnAction(event -> startDownload());
+ logTextArea.setEditable(false);
+ TextAreaAppender.setTextArea(logTextArea);
+ }
+
+ private void startDownload() {
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ executor.submit(() -> {
+ try {
+ String projectUrl = projectIdTextBox.getText();
+ String fileIdText = fileIdTextBox.getText();
+ String projectIdName = projectUrl.substring(projectUrl.lastIndexOf('/') + 1);
+ String[] args = {"-updateCurseModPack", projectIdName, "-curseFileId", fileIdText};
+ ModpackDownloaderManager modpackDownloaderManager = new ModpackDownloaderManager(args);
+ modpackDownloaderManager.init();
+ modpackDownloaderManager.processManifests();
+ } catch (InterruptedException e) {
+ log.error(e);
+ executor.shutdownNow();
+ }
+ });
+ executor.shutdownNow();
+ }
+
+ void setHostServices(HostServices hostServices) {
+ this.hostServices = hostServices;
+ }
+}
diff --git a/modpackdownloader-gui/src/main/java/com/nincraft/modpackdownloader/gui/ModpackDownloaderGUI.java b/modpackdownloader-gui/src/main/java/com/nincraft/modpackdownloader/gui/ModpackDownloaderGUI.java
new file mode 100644
index 0000000..5682fa0
--- /dev/null
+++ b/modpackdownloader-gui/src/main/java/com/nincraft/modpackdownloader/gui/ModpackDownloaderGUI.java
@@ -0,0 +1,27 @@
+package com.nincraft.modpackdownloader.gui;
+
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+
+
+public class ModpackDownloaderGUI extends Application {
+
+ public static void main(String[] args) {
+ launch(args);
+ }
+
+ @Override
+ public void start(Stage primaryStage) throws Exception {
+ FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("mpd.fxml"));
+ Parent root = loader.load();
+ Controller controller = loader.getController();
+ controller.setHostServices(getHostServices());
+ controller.init();
+ primaryStage.setTitle("Modpack Downloader by Nincraft Team");
+ primaryStage.setScene(new Scene(root, 600, 410));
+ primaryStage.show();
+ }
+}
diff --git a/modpackdownloader-gui/src/main/java/com/nincraft/modpackdownloader/gui/TextAreaAppender.java b/modpackdownloader-gui/src/main/java/com/nincraft/modpackdownloader/gui/TextAreaAppender.java
new file mode 100644
index 0000000..970009b
--- /dev/null
+++ b/modpackdownloader-gui/src/main/java/com/nincraft/modpackdownloader/gui/TextAreaAppender.java
@@ -0,0 +1,103 @@
+package com.nincraft.modpackdownloader.gui;
+
+import javafx.application.Platform;
+import javafx.scene.control.TextArea;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginElement;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+import org.apache.logging.log4j.core.layout.PatternLayout;
+
+import java.io.Serializable;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+@Plugin(
+ name = "TextAreaAppender",
+ category = "Core",
+ elementType = "appender",
+ printObject = true)
+public final class TextAreaAppender extends AbstractAppender {
+
+ private static TextArea textArea;
+
+
+ private final ReadWriteLock rwLock = new ReentrantReadWriteLock();
+ private final Lock readLock = rwLock.readLock();
+
+
+ protected TextAreaAppender(String name, Filter filter,
+ Layout extends Serializable> layout,
+ final boolean ignoreExceptions) {
+ super(name, filter, layout, ignoreExceptions);
+ }
+
+ /**
+ * Factory method. Log4j will parse the configuration and call this factory
+ * method to construct the appender with
+ * the configured attributes.
+ *
+ * @param name Name of appender
+ * @param layout Log layout of appender
+ * @param filter Filter for appender
+ * @return The TextAreaAppender
+ */
+ @PluginFactory
+ public static TextAreaAppender createAppender(
+ @PluginAttribute("name") String name,
+ @PluginElement("Layout") Layout extends Serializable> layout,
+ @PluginElement("Filter") final Filter filter) {
+ if (name == null) {
+ LOGGER.error("No name provided for TextAreaAppender");
+ return null;
+ }
+ if (layout == null) {
+ layout = PatternLayout.createDefaultLayout();
+ }
+ return new TextAreaAppender(name, filter, layout, true);
+ }
+
+ /**
+ * Set TextArea to append
+ *
+ * @param textArea TextArea to append
+ */
+ public static void setTextArea(TextArea textArea) {
+ TextAreaAppender.textArea = textArea;
+ }
+
+ @Override
+ public void append(LogEvent event) {
+ readLock.lock();
+
+ final String message = new String(getLayout().toByteArray(event));
+
+ try {
+ Platform.runLater(() -> {
+ try {
+ if (textArea != null) {
+ if (textArea.getText().length() == 0) {
+ textArea.setText(message);
+ } else {
+ textArea.selectEnd();
+ textArea.insertText(textArea.getText().length(),
+ message);
+ }
+ }
+ } catch (final Throwable t) {
+ //
+ }
+ });
+ } catch (final IllegalStateException ex) {
+ ex.printStackTrace();
+
+ } finally {
+ readLock.unlock();
+ }
+ }
+}
diff --git a/modpackdownloader-gui/src/main/resources/log4j2.xml b/modpackdownloader-gui/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..97e7745
--- /dev/null
+++ b/modpackdownloader-gui/src/main/resources/log4j2.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modpackdownloader-gui/src/main/resources/mpd.fxml b/modpackdownloader-gui/src/main/resources/mpd.fxml
new file mode 100644
index 0000000..47db157
--- /dev/null
+++ b/modpackdownloader-gui/src/main/resources/mpd.fxml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modpackdownloader-maven-plugin/pom.xml b/modpackdownloader-maven-plugin/pom.xml
new file mode 100644
index 0000000..3e698e5
--- /dev/null
+++ b/modpackdownloader-maven-plugin/pom.xml
@@ -0,0 +1,67 @@
+
+
+ 4.0.0
+
+
+ com.nincraft
+ modpackdownloader
+ 0.5
+
+ modpackdownloader-maven-plugin
+ Modpack Downloader Maven Plugin
+
+ SNAPSHOT
+
+
+ maven-plugin
+
+
+ org.apache.maven
+ maven-plugin-api
+ 3.0
+
+
+ org.apache.maven.plugin-tools
+ maven-plugin-annotations
+ 3.4
+ provided
+
+
+ com.nincraft
+ modpackdownloader-core
+
+
+
+ ModpackDownloader-maven-plugin-${short.project.version}+${build.number}
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 1.7
+
+
+ regex-property
+ process-resources
+
+ regex-property
+
+
+ short.project.version
+ ${project.version}
+ ^(\d\.\d(?>\.\d)?)(-SNAPSHOT)?
+ $1
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+ 3.4
+
+
+
+
\ No newline at end of file
diff --git a/modpackdownloader-maven-plugin/src/main/java/com/nincraft/modpackdownloader/plugin/DownloadMojo.java b/modpackdownloader-maven-plugin/src/main/java/com/nincraft/modpackdownloader/plugin/DownloadMojo.java
new file mode 100644
index 0000000..dd6e9f1
--- /dev/null
+++ b/modpackdownloader-maven-plugin/src/main/java/com/nincraft/modpackdownloader/plugin/DownloadMojo.java
@@ -0,0 +1,30 @@
+package com.nincraft.modpackdownloader.plugin;
+
+import com.nincraft.modpackdownloader.ModpackDownloaderManager;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+@Mojo(name = "download")
+public class DownloadMojo extends AbstractMojo {
+
+ @Parameter(property = "mpd.manifest", defaultValue = "manifest.json")
+ private String manifest;
+
+ @Parameter(property = "mpd.modfolder", defaultValue = "mods")
+ private String modFolder;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().info("Starting modpack download");
+ String[] args = {"-manifest", manifest, "-modFolder", modFolder};
+ try {
+ ModpackDownloaderManager modpackDownloaderManager = new ModpackDownloaderManager(args);
+ modpackDownloaderManager.init();
+ modpackDownloaderManager.processManifests();
+ } catch (InterruptedException e) {
+ getLog().error("Download interrupted", e);
+ }
+ }
+}
diff --git a/modpackdownloader-maven-plugin/src/main/java/com/nincraft/modpackdownloader/plugin/UpdateMojo.java b/modpackdownloader-maven-plugin/src/main/java/com/nincraft/modpackdownloader/plugin/UpdateMojo.java
new file mode 100644
index 0000000..55800d2
--- /dev/null
+++ b/modpackdownloader-maven-plugin/src/main/java/com/nincraft/modpackdownloader/plugin/UpdateMojo.java
@@ -0,0 +1,30 @@
+package com.nincraft.modpackdownloader.plugin;
+
+import com.nincraft.modpackdownloader.ModpackDownloaderManager;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+@Mojo(name = "update")
+public class UpdateMojo extends AbstractMojo {
+
+ @Parameter(property = "mpd.manifest", defaultValue = "manifest.json")
+ private String manifest;
+
+ @Parameter(property = "mpd.modfolder", defaultValue = "mods")
+ private String modFolder;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().info("Starting modpack update");
+ String[] args = {"-manifest", manifest, "-modFolder", modFolder, "-updateMods"};
+ try {
+ ModpackDownloaderManager modpackDownloaderManager = new ModpackDownloaderManager(args);
+ modpackDownloaderManager.init();
+ modpackDownloaderManager.processManifests();
+ } catch (InterruptedException e) {
+ getLog().error("Update interrupted", e);
+ }
+ }
+}
diff --git a/mvnw b/mvnw
new file mode 100644
index 0000000..5bf251c
--- /dev/null
+++ b/mvnw
@@ -0,0 +1,225 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven2 Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# M2_HOME - location of maven2's installed home dir
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ export JAVA_HOME="`/usr/libexec/java_home`"
+ else
+ export JAVA_HOME="/Library/Java/Home"
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+ ## resolve links - $0 may be a link to maven's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+ done
+
+ saveddir=`pwd`
+
+ M2_HOME=`dirname "$PRG"`/..
+
+ # make it fully qualified
+ M2_HOME=`cd "$M2_HOME" && pwd`
+
+ cd "$saveddir"
+ # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --unix "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Migwn, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME="`(cd "$M2_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+ # TODO classpath?
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="`which javac`"
+ if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+ if $darwin ; then
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ else
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ fi
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="`which java`"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ] ; do
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=`cd "$wdir/.."; pwd`
+ fi
+ # end of workaround
+ done
+ echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ echo "$(tr -s '\n' ' ' < "$1")"
+ fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+echo $MAVEN_PROJECTBASEDIR
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --path --windows "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/mvnw.cmd b/mvnw.cmd
new file mode 100644
index 0000000..019bd74
--- /dev/null
+++ b/mvnw.cmd
@@ -0,0 +1,143 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven2 Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%
diff --git a/pom.xml b/pom.xml
index 6876b3c..8c4d17c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,128 +1,46 @@
-
+
4.0.0
+
com.nincraft
- ModPackDownloader
- 0.4.3
- Mod Pack Downloader
- jar
+ modpackdownloader
+ 0.5
+ pom
+ Modpack Downloader
SNAPSHOT
- 2.8.1
-
-
- com.googlecode.json-simple
- json-simple
- 1.1.1
-
-
- org.apache.logging.log4j
- log4j-api
- ${log4j.version}
-
-
- org.apache.commons
- commons-collections4
- 4.1
-
-
- org.apache.commons
- commons-lang3
- 3.5
-
-
- org.apache.logging.log4j
- log4j-core
- ${log4j.version}
-
-
- commons-io
- commons-io
- 2.5
-
-
- org.projectlombok
- lombok
- 1.16.14
- provided
-
-
- com.google.guava
- guava
- 21.0
-
-
- com.google.code.gson
- gson
- 2.8.0
-
-
- net.lingala.zip4j
- zip4j
- 1.3.2
-
-
- com.beust
- jcommander
- 1.60
-
-
- pl.pragmatists
- JUnitParams
- 1.0.6
- test
-
-
- junit
- junit
- 4.12
-
-
+
+ modpackdownloader-core
+ modpackdownloader-maven-plugin
+ modpackdownloader-cli
+ modpackdownloader-gui
+
+
+
+
+
+ com.nincraft
+ modpackdownloader-core
+ ${project.version}
+
+
+ org.projectlombok
+ lombok
+ 1.16.16
+ provided
+
+
+ com.beust
+ jcommander
+ 1.72
+
+
+
- ${project.artifactId}-${short.project.version}+${build.number}
-
-
- src/main/resources
- true
-
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
- 1.7
-
-
- regex-property
- process-resources
-
- regex-property
-
-
- short.project.version
- ${project.version}
- ^(\d\.\d(?>\.\d)?)(-SNAPSHOT)?
- $1
- true
-
-
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- 2.6
-
-
- resources
- process-resources
-
- resources
-
-
-
-
maven-compiler-plugin
3.5.1
@@ -132,28 +50,38 @@
- org.apache.maven.plugins
- maven-shade-plugin
- 2.4.3
+ org.jacoco
+ jacoco-maven-plugin
+ 0.7.8
- package
+ default-prepare-agent
- shade
+ prepare-agent
+
+
+
+ default-report
+ prepare-package
+
+ report
-
-
-
- com.nincraft.modpackdownloader.ModPackDownloader
-
-
-
+
+
+
+ releases
+ http://play.nincraft.com:8081/nexus/content/repositories/releases/
+
+
+ snapshots
+ http://play.nincraft.com:8081/nexus/content/repositories/snapshots/
+
+
releases
diff --git a/src/main/java/com/nincraft/modpackdownloader/ModPackDownloader.java b/src/main/java/com/nincraft/modpackdownloader/ModPackDownloader.java
deleted file mode 100644
index ca385a0..0000000
--- a/src/main/java/com/nincraft/modpackdownloader/ModPackDownloader.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package com.nincraft.modpackdownloader;
-
-import com.beust.jcommander.JCommander;
-import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
-import com.nincraft.modpackdownloader.handler.ApplicationUpdateHandler;
-import com.nincraft.modpackdownloader.processor.DownloadModpackProcessor;
-import com.nincraft.modpackdownloader.processor.DownloadModsProcessor;
-import com.nincraft.modpackdownloader.processor.MergeManifestsProcessor;
-import com.nincraft.modpackdownloader.processor.UpdateModsProcessor;
-import com.nincraft.modpackdownloader.util.Arguments;
-import com.nincraft.modpackdownloader.util.DownloadHelper;
-import com.nincraft.modpackdownloader.util.FileSystemHelper;
-import com.nincraft.modpackdownloader.util.Reference;
-import lombok.experimental.UtilityClass;
-import lombok.extern.log4j.Log4j2;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-
-import java.io.File;
-import java.util.Arrays;
-
-@UtilityClass
-@Log4j2
-class ModPackDownloader {
-
- private static Reference reference = Reference.getInstance();
- private Arguments arguments;
- private DownloadHelper downloadHelper;
-
- public static void main(final String[] args) throws InterruptedException {
- log.info("Starting ModPackDownloader with arguments: {}", Arrays.toString(args));
- JCommander jCommander = initArguments(args);
-
- if (arguments.isHelpEnabled()) {
- jCommander.usage();
- return;
- }
-
- // Set default application arguments
- defaultArguments();
-
- setupRepo();
-
- if (arguments.isClearCache()) {
- FileSystemHelper.clearCache();
- return;
- }
- if (arguments.isUpdateApp()) {
- ApplicationUpdateHandler.update();
- return;
- }
-
- processManifests();
- }
-
- private static void processManifests() throws InterruptedException {
- log.trace("Processing Manifests...");
- downloadHelper = new DownloadHelper(arguments);
- downloadModpack();
- updateMods();
- downloadMods();
- mergeManifests();
-
- log.trace("Finished Processing Manifests.");
- }
-
- private static void downloadModpack() throws InterruptedException {
- if (arguments.isUpdateCurseModPack()) {
- log.warn("The parameter updateCurseModpack will be changing in the next version. You will need to supply the modpack ID in future versions.");
- new DownloadModpackProcessor(arguments, downloadHelper).process();
- arguments.setDownloadMods(true);
- }
- }
-
- private static void updateMods() throws InterruptedException {
- if (arguments.isUpdateMods() || !StringUtils.isBlank(arguments.getCheckMCUpdate())) {
- new UpdateModsProcessor(arguments, downloadHelper).process();
- }
- }
-
- private static void downloadMods() throws InterruptedException {
- if (arguments.isDownloadMods()) {
- new DownloadModsProcessor(arguments, downloadHelper).process();
- }
- }
-
- private static void mergeManifests() throws InterruptedException {
- if (arguments.isMergeManifests()) {
- new MergeManifestsProcessor(arguments, downloadHelper).process();
- }
- }
-
- private static JCommander initArguments(final String[] args) {
- // Initialize application arguments
- arguments = new Arguments();
- return new JCommander(arguments, args);
- }
-
- private static void defaultArguments() {
- if (CollectionUtils.isEmpty(arguments.getManifests())) {
- log.info("No manifest supplied, using default {}", reference.getDefaultManifestFile());
-
- arguments.setManifests(Lists.newArrayList(new File(reference.getDefaultManifestFile())));
- }
- if (Strings.isNullOrEmpty(arguments.getModFolder())) {
- log.info("No output folder supplied, using default \"mods\"");
- arguments.setModFolder("mods");
- }
- if (!arguments.isDownloadMods() && !arguments.isUpdateMods() && !arguments.isMergeManifests() && StringUtils.isBlank(arguments.getCheckMCUpdate())) {
- arguments.setDownloadMods(true);
- }
- }
-
- private static void setupRepo() {
- log.trace("Setting up local repository...");
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append(System.getProperty("user.home"));
- if (log.isDebugEnabled()) {
- log.debug("User Home System Property detected as: {}", stringBuilder.toString());
- }
-
- reference.setOs(System.getProperty("os.name"));
- if (log.isDebugEnabled()) {
- log.debug("Operating System detected as: {}", reference.getOs());
- }
-
-
- if (reference.getOs().startsWith("Windows")) {
- stringBuilder.append(reference.getWindowsFolder());
- } else if (reference.getOs().startsWith("Mac")) {
- stringBuilder.append(reference.getMacFolder());
- } else {
- stringBuilder.append(reference.getOtherFolder());
- }
- reference.setUserhome(stringBuilder.toString());
-
- if (log.isDebugEnabled()) {
- log.debug("User Home Folder set to: {}", reference.getUserhome());
- }
-
- FileSystemHelper.createFolder(reference.getUserhome());
-
- log.debug("Setting User Agent...");
- System.setProperty("http.agent", "Mozilla/4.0");
-
- log.trace("Finished setting up local repository.");
- }
-}
diff --git a/src/main/java/com/nincraft/modpackdownloader/validation/ExistingFile.java b/src/main/java/com/nincraft/modpackdownloader/validation/ExistingFile.java
deleted file mode 100644
index f676fb8..0000000
--- a/src/main/java/com/nincraft/modpackdownloader/validation/ExistingFile.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.nincraft.modpackdownloader.validation;
-
-import com.beust.jcommander.IParameterValidator;
-import com.beust.jcommander.ParameterException;
-
-import java.io.File;
-
-public class ExistingFile implements IParameterValidator {
- @Override
- public void validate(String name, String value) throws ParameterException {
- if (!new File(value).exists()) {
- throw new ParameterException(String.format("Parameter %s is not a valid file (found %s)", name, value));
- }
- }
-}
diff --git a/src/main/resources/latest.json b/src/main/resources/latest.json
deleted file mode 100644
index 79faa32..0000000
--- a/src/main/resources/latest.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "url": "http://play.nincraft.com:8080/job/Mod%20Pack%20Downloader/lastSuccessfulBuild/artifact/target/${project.build.finalName}.jar"
-}
\ No newline at end of file