-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from massivedisaster/release/0.0.3
Release/0.0.3
- Loading branch information
Showing
11 changed files
with
252 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
35 changes: 28 additions & 7 deletions
35
...ployautomator/BintrayDeployAutomator.java → ...ter/bintraydeployautomator/Automator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,66 @@ | ||
package com.massivedisaster.bintraydeployautomator; | ||
|
||
import com.massivedisaster.bintraydeployautomator.model.Configuration; | ||
import com.massivedisaster.bintraydeployautomator.utils.CommandLineUtils; | ||
import com.massivedisaster.bintraydeployautomator.utils.FileUtils; | ||
import com.massivedisaster.bintraydeployautomator.utils.GradleUtils; | ||
import javafx.util.Pair; | ||
import org.gradle.tooling.GradleConnector; | ||
import org.gradle.tooling.ProjectConnection; | ||
|
||
import java.io.File; | ||
|
||
public class BintrayDeployAutomator extends FileUtils { | ||
/** | ||
* Bintray deploy automator. | ||
*/ | ||
public class Automator extends FileUtils { | ||
|
||
/** | ||
* Main method. | ||
* | ||
* @param args command line arguments. | ||
*/ | ||
public static void main(String args[]) { | ||
|
||
ProjectConnection gradleConnection = null; | ||
try { | ||
Pair<String, String> auth = CommandLineUtils.commandLineArgs(args); | ||
|
||
// Get configuration from .json. | ||
Configuration configuration = Configuration.parseConfiguration("configuration.json"); | ||
|
||
configuration.setBintrayUsername(auth.getKey()); | ||
configuration.setBintrayKey(auth.getValue()); | ||
|
||
gradleConnection = GradleConnector.newConnector() | ||
.forProjectDirectory(new File(configuration.getBasePath())) | ||
.connect(); | ||
|
||
// Clean and build all projects. | ||
// Clean build and deploy all projects. | ||
rebuildAndBintrayDeploy(gradleConnection, configuration); | ||
|
||
// Replace version if needed. | ||
if (configuration.UpdateReadmeVersion()) { | ||
FileUtils.replaceSemVerInFile(configuration.getVersion(), configuration.getReadmePath()); | ||
// Replace version in readme if needed. | ||
if (configuration.canUpdateReadmeWithVersion()) { | ||
FileUtils.replaceAllSemVerInFile(configuration.getVersion(), configuration.getReadmePath()); | ||
} | ||
|
||
} catch (Exception e) { | ||
System.out.println("BintrayDeployAutomator Error: " + e.toString()); | ||
System.out.println("Automator Error: " + e.toString()); | ||
} finally { | ||
if (gradleConnection != null) { | ||
gradleConnection.close(); | ||
} | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Run build and upload to bintray. | ||
* | ||
* @param gradleConnection the gradle connection. | ||
* @param configuration the configuration model. | ||
*/ | ||
private static void rebuildAndBintrayDeploy(ProjectConnection gradleConnection, Configuration configuration) { | ||
GradleUtils.runGradle(gradleConnection, configuration.getRebuildAndBintrayDeployTasks(), configuration.getRebuildAndBintrayDeployArguments()); | ||
GradleUtils.runGradle(gradleConnection, configuration.getTasks(), configuration.getArguments()); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/massivedisaster/bintraydeployautomator/annotations/NotNull.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.massivedisaster.bintraydeployautomator.annotations; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Documented | ||
@Retention(RetentionPolicy.CLASS) | ||
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE}) | ||
public @interface NotNull { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/com/massivedisaster/bintraydeployautomator/utils/ArrayUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.massivedisaster.bintraydeployautomator.utils; | ||
|
||
/** | ||
* Array Utils | ||
*/ | ||
public class ArrayUtils { | ||
|
||
/** | ||
* Adds all the elements of the given arrays into a new array. | ||
* The new array contains all of the element of array1 followed by all of the elements array2. When an array | ||
* is returned, it is always a new array. | ||
* | ||
* @param array1 the first array whose elements are added to the new array. | ||
* @param array2 the second array whose elements are added to the new array. | ||
* @return The new String[] array. | ||
*/ | ||
public static String[] addAll(String[] array1, String[] array2) { | ||
if (array1 == null) { | ||
return clone(array2); | ||
} else if (array2 == null) { | ||
return clone(array1); | ||
} | ||
String[] joinedArray = new String[array1.length + array2.length]; | ||
System.arraycopy(array1, 0, joinedArray, 0, array1.length); | ||
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length); | ||
return joinedArray; | ||
} | ||
|
||
/** | ||
* Clones an array returning a typecast result and handling null. | ||
* This method returns null for a null input array. | ||
* | ||
* @param array the array to clone, may be null | ||
* @return the cloned array, null if null input | ||
*/ | ||
private static String[] clone(String[] array) { | ||
if (array == null) { | ||
return null; | ||
} | ||
return array.clone(); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/massivedisaster/bintraydeployautomator/utils/CommandLineUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.massivedisaster.bintraydeployautomator.utils; | ||
|
||
import javafx.util.Pair; | ||
import org.apache.commons.cli.*; | ||
|
||
public class CommandLineUtils { | ||
|
||
public static Pair<String, String> commandLineArgs(String[] args) { | ||
Options options = new Options(); | ||
|
||
Option input = new Option("u", "user", true, "Bintray Username"); | ||
input.setRequired(true); | ||
options.addOption(input); | ||
|
||
Option output = new Option("k", "key", true, "Bintray Key"); | ||
output.setRequired(true); | ||
options.addOption(output); | ||
|
||
CommandLineParser parser = new DefaultParser(); | ||
HelpFormatter formatter = new HelpFormatter(); | ||
CommandLine cmd; | ||
|
||
try { | ||
cmd = parser.parse(options, args); | ||
} catch (ParseException e) { | ||
System.out.println(e.getMessage()); | ||
formatter.printHelp("Java -jar BintrayDeployAutomator-0.0.2.jar", options); | ||
|
||
System.exit(1); | ||
return null; | ||
} | ||
|
||
String user = cmd.getOptionValue("user"); | ||
String key = cmd.getOptionValue("key"); | ||
|
||
return new Pair<>(user, key); | ||
} | ||
|
||
} |
Oops, something went wrong.