Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Deployer and configuration abstraction #9

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions src/main/java/dev/cerus/deployhelper/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@
import com.google.gson.LongSerializationPolicy;
import dev.cerus.deployhelper.configuration.Config;
import dev.cerus.deployhelper.deploy.Deployer;
import dev.cerus.deployhelper.gson.ArtifactSectionAdapter;
import dev.cerus.deployhelper.gson.CommandsSectionAdapter;
import dev.cerus.deployhelper.gson.ConfigAdapter;
import dev.cerus.deployhelper.gson.DestinationAdapter;
import dev.cerus.deployhelper.gson.SSHSectionAdapter;
import dev.cerus.deployhelper.gson.*;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.net.URISyntaxException;
import java.util.Collections;

public class Launcher {

Expand Down Expand Up @@ -66,17 +61,6 @@ public static void main(final String[] args) {
deployer.deploy();
}

private static void fail(final OptionsParser parser) {
File jar = new File("deploy-helper.jar");
try {
jar = new File(Launcher.class.getProtectionDomain().getCodeSource().getLocation().toURI());
} catch (final URISyntaxException ignored) {
}

System.out.println("Usage: java -jar " + jar.getName() + " OPTIONS");
System.out.println(parser.describeOptions(Collections.emptyMap(), OptionsParser.HelpVerbosity.LONG));
}

public static class Options extends OptionsBase {

@Option(
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/dev/cerus/deployhelper/deploy/Deployer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
import dev.cerus.deployhelper.Launcher;
import dev.cerus.deployhelper.configuration.Config;
import dev.cerus.deployhelper.util.TriFunction;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;

public class Deployer {
Expand Down Expand Up @@ -46,7 +42,7 @@ public void deploy() {
final File artifact = this.findArtifact();

// Check arguments
if (this.options.destination != null && this.options.destination.length() > 0) {
if (!"".equals(this.options.destination)) {
// Loop through the specified destinations and run deploy tasks
for (final String destName : this.options.destination.split(",")) {
final Config.Destination destination = destinationMap.get(destName);
Expand Down Expand Up @@ -187,7 +183,6 @@ private void execSsh(final Config.Destination destination) {
* @param command The command array
* @param destination The destination
* @param artifact The artifact to deploy
*
* @return A command array with replaced variables
*/
private String[] prepareCommand(final String[] command, final Config.Destination destination, final File artifact) {
Expand Down