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

Commit

Permalink
Merge branch 'release/0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nincodedo committed Jul 23, 2017
2 parents 1692d5e + 3330f02 commit 066dbc8
Show file tree
Hide file tree
Showing 63 changed files with 1,498 additions and 493 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ all/
logs/
.idea/
*.iml
out/
out/
/**/dependency-reduced-pom.xml
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
1 change: 1 addition & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
10 changes: 10 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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'
}
85 changes: 85 additions & 0 deletions modpackdownloader-cli/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>modpackdownloader</artifactId>
<groupId>com.nincraft</groupId>
<version>0.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>modpackdownloader-cli</artifactId>
<name>Modpack Downloader CLI</name>
<properties>
<build.number>SNAPSHOT</build.number>
</properties>

<dependencies>
<dependency>
<groupId>com.nincraft</groupId>
<artifactId>modpackdownloader-core</artifactId>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<finalName>ModpackDownloader-cli-${short.project.version}+${build.number}</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>regex-property</id>
<phase>process-resources</phase>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>short.project.version</name>
<value>${project.version}</value>
<regex>^(\d\.\d(?>\.\d)?)(-SNAPSHOT)?</regex>
<replacement>$1</replacement>
<failIfNoMatch>true</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.nincraft.modpackdownloader.cli.ModpackDownloaderCLI</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -28,47 +26,60 @@
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<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"));
List<String> 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<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"));
List<String> checkFiles = addMods(mods);

for (String fileCheck : checkFiles) {
mod = new File(fileCheck);
log.info("Checking {}: {}", mod, mod.exists());
Assert.assertTrue(mod.exists());
mod.deleteOnExit();
}
}

@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"};

Gson gson = new Gson();
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()) {
Expand All @@ -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<File> files = Arrays.asList(directory.listFiles(fileFilter));
Assert.assertTrue(!CollectionUtils.isEmpty(files));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"name": "Thaumcraft"
},
{
"fileID": 2287496,
"projectID": 223628,
"name": "Thaumcraft",
"fileID": 2423802,
"projectID": 59882,
"name": "modular-forcefield-system",
"rename": "pants.jar"
},
{
Expand Down
Loading

0 comments on commit 066dbc8

Please sign in to comment.