Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 066dbc8

Browse files
committed
Merge branch 'release/0.5'
2 parents 1692d5e + 3330f02 commit 066dbc8

63 files changed

Lines changed: 1498 additions & 493 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ all/
88
logs/
99
.idea/
1010
*.iml
11-
out/
11+
out/
12+
/**/dependency-reduced-pom.xml

.mvn/wrapper/maven-wrapper.jar

46.5 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip

Jenkinsfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node {
2+
stage 'Checkout'
3+
git branch: env.BRANCH_NAME, url: 'https://github.com/Nincraft/ModPackDownloader.git'
4+
5+
stage 'Build'
6+
bat 'mvnw.cmd clean install'
7+
8+
stage 'Archive'
9+
archive excludes: '**/target/Mod*-sources.jar,**/target/Mod*-javadoc.jar', includes: '**/target/Mod*.jar, modpackdownloader-core/target/classes/latest.json'
10+
}

modpackdownloader-cli/pom.xml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>modpackdownloader</artifactId>
7+
<groupId>com.nincraft</groupId>
8+
<version>0.5</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>modpackdownloader-cli</artifactId>
13+
<name>Modpack Downloader CLI</name>
14+
<properties>
15+
<build.number>SNAPSHOT</build.number>
16+
</properties>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>com.nincraft</groupId>
21+
<artifactId>modpackdownloader-core</artifactId>
22+
</dependency>
23+
<dependency>
24+
<groupId>com.beust</groupId>
25+
<artifactId>jcommander</artifactId>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.projectlombok</groupId>
29+
<artifactId>lombok</artifactId>
30+
<scope>provided</scope>
31+
</dependency>
32+
<dependency>
33+
<groupId>junit</groupId>
34+
<artifactId>junit</artifactId>
35+
<version>4.12</version>
36+
</dependency>
37+
</dependencies>
38+
<build>
39+
<finalName>ModpackDownloader-cli-${short.project.version}+${build.number}</finalName>
40+
<plugins>
41+
<plugin>
42+
<groupId>org.codehaus.mojo</groupId>
43+
<artifactId>build-helper-maven-plugin</artifactId>
44+
<version>1.7</version>
45+
<executions>
46+
<execution>
47+
<id>regex-property</id>
48+
<phase>process-resources</phase>
49+
<goals>
50+
<goal>regex-property</goal>
51+
</goals>
52+
<configuration>
53+
<name>short.project.version</name>
54+
<value>${project.version}</value>
55+
<regex>^(\d\.\d(?>\.\d)?)(-SNAPSHOT)?</regex>
56+
<replacement>$1</replacement>
57+
<failIfNoMatch>true</failIfNoMatch>
58+
</configuration>
59+
</execution>
60+
</executions>
61+
</plugin>
62+
<plugin>
63+
<groupId>org.apache.maven.plugins</groupId>
64+
<artifactId>maven-shade-plugin</artifactId>
65+
<version>2.4.3</version>
66+
<executions>
67+
<execution>
68+
<phase>package</phase>
69+
<goals>
70+
<goal>shade</goal>
71+
</goals>
72+
<configuration>
73+
<transformers>
74+
<transformer
75+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
76+
<mainClass>com.nincraft.modpackdownloader.cli.ModpackDownloaderCLI</mainClass>
77+
</transformer>
78+
</transformers>
79+
</configuration>
80+
</execution>
81+
</executions>
82+
</plugin>
83+
</plugins>
84+
</build>
85+
</project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.nincraft.modpackdownloader.cli;
2+
3+
import com.nincraft.modpackdownloader.ModpackDownloaderManager;
4+
import com.nincraft.modpackdownloader.handler.ApplicationUpdateHandler;
5+
import com.nincraft.modpackdownloader.util.Arguments;
6+
import com.nincraft.modpackdownloader.util.FileSystemHelper;
7+
import lombok.extern.log4j.Log4j2;
8+
9+
import java.util.Arrays;
10+
11+
@Log4j2
12+
public class ModpackDownloaderCLI {
13+
14+
public static void main(final String[] args) throws InterruptedException {
15+
log.info("Starting ModpackDownloaderManager with arguments: {}", Arrays.toString(args));
16+
ModpackDownloaderManager modpackDownloaderManager = new ModpackDownloaderManager(args);
17+
18+
Arguments arguments = modpackDownloaderManager.getArguments();
19+
20+
if (arguments.isHelpEnabled()) {
21+
modpackDownloaderManager.getJCommander().usage();
22+
return;
23+
}
24+
25+
modpackDownloaderManager.init();
26+
27+
if (arguments.isClearCache()) {
28+
FileSystemHelper.clearCache();
29+
return;
30+
}
31+
if (arguments.isUpdateApp()) {
32+
ApplicationUpdateHandler.update();
33+
return;
34+
}
35+
modpackDownloaderManager.processManifests();
36+
}
37+
}

src/main/resources/log4j2.xml renamed to modpackdownloader-cli/src/main/resources/log4j2.xml

File renamed without changes.

src/test/java/com/nincraft/modpackdownloader/ModPackDownloaderTest.java renamed to modpackdownloader-cli/src/test/java/com/nincraft/modpackdownloader/ModpackDownloaderCLITest.java

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.nincraft.modpackdownloader;
22

33
import com.google.gson.Gson;
4+
import com.nincraft.modpackdownloader.cli.ModpackDownloaderCLI;
45
import com.nincraft.modpackdownloader.container.CurseFile;
56
import com.nincraft.modpackdownloader.container.Manifest;
67
import com.nincraft.modpackdownloader.util.VersionHelper;
7-
import junitparams.JUnitParamsRunner;
8-
import junitparams.Parameters;
98
import lombok.extern.log4j.Log4j2;
109
import org.apache.commons.collections4.CollectionUtils;
1110
import org.apache.commons.io.FileUtils;
@@ -16,7 +15,6 @@
1615
import org.junit.After;
1716
import org.junit.Assert;
1817
import org.junit.Test;
19-
import org.junit.runner.RunWith;
2018

2119
import java.io.File;
2220
import java.io.FileFilter;
@@ -28,47 +26,60 @@
2826
import java.util.stream.Collectors;
2927

3028
@Log4j2
31-
@RunWith(JUnitParamsRunner.class)
32-
public class ModPackDownloaderTest {
29+
public class ModpackDownloaderCLITest {
30+
31+
private final String RESOURCES = "src/test/resources/";
3332

3433
@After
3534
public void cleanUp() throws IOException {
36-
String[] deleteFiles = {"src/test/resources/update-test.json.bak", "src/test/resources/download-test.json.bak", "src/test/resources/update-test.json"};
35+
String[] deleteFiles = {RESOURCES + "update-test.json.bak", RESOURCES + "download-test.json.bak", RESOURCES + "update-test.json"};
3736
for (String s : deleteFiles) {
3837
new File(s).delete();
3938
}
40-
File backupUpdate = new File("src/test/resources/update-test-backup.json");
41-
File updateFile = new File("src/test/resources/update-test.json");
39+
File backupUpdate = new File(RESOURCES + "update-test-backup.json");
40+
File updateFile = new File(RESOURCES + "update-test.json");
4241
FileUtils.copyFile(backupUpdate, updateFile);
4342
}
4443

4544
@Test
46-
@Parameters({"-manifest src/test/resources/download-test.json -releaseType release", "-manifest src/test/resources/download-test.json -maxDownloadThreads 1"})
47-
public void testDownload(String arg) throws InterruptedException {
48-
ModPackDownloader.main(arg.split(" "));
45+
public void testDownloadRelease() throws InterruptedException {
46+
ModpackDownloaderCLI.main(new String[]{"-manifest", RESOURCES + "download-test.json", "-releaseType", "release", "-forceDownload"});
47+
File mod;
48+
List<String> 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"));
49+
List<String> checkFiles = addMods(mods);
50+
51+
for (String fileCheck : checkFiles) {
52+
mod = new File(fileCheck);
53+
Assert.assertTrue(mod.exists());
54+
mod.deleteOnExit();
55+
}
56+
}
57+
58+
@Test
59+
public void testDownloadMaxThreads() throws InterruptedException {
60+
ModpackDownloaderCLI.main(new String[]{"-manifest", RESOURCES + "download-test.json", "-maxDownloadThreads", "1"});
4961
File mod;
5062
List<String> 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"));
5163
List<String> checkFiles = addMods(mods);
5264

5365
for (String fileCheck : checkFiles) {
5466
mod = new File(fileCheck);
55-
log.info("Checking {}: {}", mod, mod.exists());
5667
Assert.assertTrue(mod.exists());
5768
mod.deleteOnExit();
5869
}
5970
}
6071

6172
@Test
6273
public void testUpdate() throws InterruptedException, IOException, ParseException {
63-
String manifestName = "src/test/resources/update-test.json";
74+
String manifestName = RESOURCES + "update-test.json";
6475
File manifestFile = new File(manifestName);
6576
String[] args = {"-manifest", manifestName, "-updateMods", "-updateForge", "-backupVersion", "1.8.9"};
6677

6778
Gson gson = new Gson();
6879
JSONObject jsonLists = (JSONObject) new JSONParser().parse(new FileReader(manifestFile));
6980
Manifest manifest = gson.fromJson(jsonLists.toString(), Manifest.class);
7081
String oldForgeVersion = manifest.getForgeVersion();
71-
ModPackDownloader.main(args);
82+
ModpackDownloaderCLI.main(args);
7283
jsonLists = (JSONObject) new JSONParser().parse(new FileReader(manifestFile));
7384
manifest = gson.fromJson(jsonLists.toString(), Manifest.class);
7485
for (CurseFile curseFile : manifest.getCurseFiles()) {
@@ -80,16 +91,16 @@ public void testUpdate() throws InterruptedException, IOException, ParseExceptio
8091

8192
@Test
8293
public void testCheckUpdate() throws InterruptedException, IOException, ParseException {
83-
String manifestName = "src/test/resources/update-test.json";
94+
String manifestName = RESOURCES + "update-test.json";
8495
String[] args = {"-manifest", manifestName, "-checkMCUpdate", "1.10.2"};
85-
ModPackDownloader.main(args);
96+
ModpackDownloaderCLI.main(args);
8697
}
8798

8899
@Test
89100
public void testAppUpdate() throws InterruptedException {
90101
String[] args = {"-updateApp"};
91-
ModPackDownloader.main(args);
92-
FileFilter fileFilter = new WildcardFileFilter("ModPackDownloader*jar");
102+
ModpackDownloaderCLI.main(args);
103+
FileFilter fileFilter = new WildcardFileFilter("ModpackDownloader*jar");
93104
File directory = new File(".");
94105
List<File> files = Arrays.asList(directory.listFiles(fileFilter));
95106
Assert.assertTrue(!CollectionUtils.isEmpty(files));

src/test/resources/all-mods.json renamed to modpackdownloader-cli/src/test/resources/all-mods.json

File renamed without changes.

src/test/resources/botania-manifest.json renamed to modpackdownloader-cli/src/test/resources/botania-manifest.json

File renamed without changes.

0 commit comments

Comments
 (0)