[DEV] refactoring, cleaning, better java AND start dependency-sync
This commit is contained in:
parent
3553740686
commit
aefb938621
BIN
generator_bundle_jgit/target/jgit_bundle-5.12.0.jar
Normal file
BIN
generator_bundle_jgit/target/jgit_bundle-5.12.0.jar
Normal file
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Sun Sep 19 15:44:02 CEST 2021
|
||||
groupId=org.atriasoft
|
||||
artifactId=jgit_bundle
|
||||
version=5.12.0
|
@ -7,18 +7,24 @@ import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.DeltaBranch;
|
||||
import org.atriasoft.island.model.manifest.DeliverMode;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.ListBranchCommand.ListMode;
|
||||
import org.eclipse.jgit.api.MergeCommand.FastForwardMode;
|
||||
import org.eclipse.jgit.api.MergeResult;
|
||||
import org.eclipse.jgit.api.Status;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.api.errors.NoHeadException;
|
||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.errors.NoWorkTreeException;
|
||||
import org.eclipse.jgit.errors.RevisionSyntaxException;
|
||||
import org.eclipse.jgit.lib.BranchConfig;
|
||||
@ -26,8 +32,11 @@ import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
@SuppressWarnings("exports")
|
||||
public class Commands {
|
||||
private static final String default_behind_message = "[DEV] update dev tag version";
|
||||
private static final String default_update_message = "[VERSION] update dev tag version";
|
||||
private Commands() {}
|
||||
public static List<String> getListBranchLocal(final Git git) throws GitAPIException {
|
||||
List<String> remotes = Commands.getListBranchRemote(git);
|
||||
@ -215,7 +224,7 @@ public class Commands {
|
||||
* @return true if it is a git repository, false otherwise.
|
||||
*/
|
||||
public static boolean isGitRepository(final String path) {
|
||||
Path git_repo_path = Env.get_island_root_path().resolve(path);
|
||||
Path git_repo_path = Env.getIslandRootPath().resolve(path);
|
||||
if (!Files.exists(git_repo_path)) {
|
||||
Log.warning("Path Does not Exist ... " + git_repo_path + " ==> skip");
|
||||
return false;
|
||||
@ -227,6 +236,16 @@ public class Commands {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean historyContains(final List<ObjectId> values, final ObjectId checkElem) {
|
||||
for (ObjectId elemSha2 : values) {
|
||||
if (elemSha2.equals(checkElem)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get deltas between 2 branches.
|
||||
* @param git JGit interface of the current repository.
|
||||
@ -242,27 +261,13 @@ public class Commands {
|
||||
// remove all identical sha1 ==> not needed for this
|
||||
int inForward = 0;
|
||||
for (ObjectId elemSha1 : retCurrentBranchSha1) {
|
||||
boolean find = false;
|
||||
for (ObjectId elemSha2 : retTrackBranchSha1) {
|
||||
if (elemSha2.equals(elemSha1)) {
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!find) {
|
||||
if (!Commands.historyContains(retTrackBranchSha1, elemSha1)) {
|
||||
inForward++;
|
||||
}
|
||||
}
|
||||
int inBehind = 0;
|
||||
for (ObjectId elemSha1 : retTrackBranchSha1) {
|
||||
boolean find = false;
|
||||
for (ObjectId elemSha2 : retCurrentBranchSha1) {
|
||||
if (elemSha2.equals(elemSha1)) {
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!find) {
|
||||
if (!Commands.historyContains(retCurrentBranchSha1, elemSha1)) {
|
||||
inBehind++;
|
||||
}
|
||||
}
|
||||
@ -289,7 +294,14 @@ public class Commands {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean stringInList(final String[] elements, final String value) {
|
||||
for (int iii=0; iii<elements.length; iii++) {
|
||||
if (elements[iii].equals(value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public record CreateVersion(String[] version, boolean addInManagement) {}
|
||||
public static CreateVersion get_current_version_repo(final Path git_repo_path) {
|
||||
Path version_path_file = git_repo_path.resolve("version.txt");
|
||||
@ -305,10 +317,10 @@ public class Commands {
|
||||
Log.print(" (1) Add in managing version");
|
||||
Log.print(" (2) Do NOTHING & continue");
|
||||
input1 = Commands.input();
|
||||
if (input1.equals("1") || input1.equals("2") ) {
|
||||
if (Commands.stringInList(new String[]{"1", "2"}, input1)) {
|
||||
valid = true;
|
||||
} else {
|
||||
Log.print("!!! Must select in range [1,2]");
|
||||
Log.print("!!! Must select in range [1..2]");
|
||||
}
|
||||
}
|
||||
if (input1.equals("1")) {
|
||||
@ -323,7 +335,7 @@ public class Commands {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
version_description = Tools.version_string_to_list(Tools.readFile(version_path_file, Charset.defaultCharset()));
|
||||
version_description = Tools.versionStringToList(Tools.readFile(version_path_file, Charset.defaultCharset()));
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@ -331,5 +343,168 @@ public class Commands {
|
||||
}
|
||||
return new CreateVersion(version_description, add_in_version_management);
|
||||
}
|
||||
public static int[] create_new_version_repo(
|
||||
final Git git,
|
||||
final String[] version_description,
|
||||
final boolean add_in_version_management,
|
||||
final String source_branch,
|
||||
final String destination_branch) {
|
||||
// get tracking branch
|
||||
List<ObjectId> ret_destination_branch_sha1 = null;
|
||||
List<ObjectId> ret_source_branch_sha1 = null;
|
||||
try {
|
||||
ret_destination_branch_sha1 = Commands.getRevisionListToBranch(git, destination_branch);
|
||||
ret_source_branch_sha1 = Commands.getRevisionListToBranch(git, source_branch);
|
||||
} catch (NoHeadException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Log.critical("dfghdsfghdfgh");
|
||||
} catch (GitAPIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Log.critical("sdgfhdgfhsdfhsdf");
|
||||
}
|
||||
// remove all identical sha1 ==> not needed for this
|
||||
boolean have_forward = false;
|
||||
for (ObjectId elem_sha1 : ret_destination_branch_sha1) {
|
||||
if (!Commands.historyContains(ret_source_branch_sha1, elem_sha1)) {
|
||||
RevCommit message = Commands.get_specific_commit_message(git, elem_sha1);
|
||||
Log.warning("deliver: Forward commit: '" + message.getFullMessage() + "'");
|
||||
have_forward = true;
|
||||
}
|
||||
}
|
||||
if (have_forward == true) {
|
||||
Log.error("'" + destination_branch + "' branch must not be forward '" + source_branch + "' branch");
|
||||
return null;
|
||||
}
|
||||
String behind_message = "";
|
||||
int behind_count = 0;
|
||||
for (ObjectId elem_sha1 : ret_source_branch_sha1) {
|
||||
if (!Commands.historyContains(ret_destination_branch_sha1, elem_sha1)) {
|
||||
RevCommit message = Commands.get_specific_commit_message(git, elem_sha1);
|
||||
behind_count += 1;
|
||||
behind_message = message.getFullMessage();
|
||||
}
|
||||
}
|
||||
if (behind_count == 0 && add_in_version_management == false) {
|
||||
Log.info("deliver: ==> Nothing to do (1).");
|
||||
return null;
|
||||
}
|
||||
if (behind_count == 1 && ( behind_message.equals(Commands.default_behind_message) || behind_message.equals(Commands.default_update_message))) {
|
||||
Log.info("deliver: ==> Nothing to do (2).");
|
||||
return null;
|
||||
}
|
||||
for (ObjectId elem_sha1 : ret_source_branch_sha1) {
|
||||
if (!Commands.historyContains(ret_destination_branch_sha1, elem_sha1)) {
|
||||
RevCommit message = Commands.get_specific_commit_message(git, elem_sha1);
|
||||
Log.print("deliver: Behind commit: '" + message.getFullMessage() + "'");
|
||||
}
|
||||
}
|
||||
// Choice of the new version:
|
||||
String input1 = null;
|
||||
while (input1 == null) {
|
||||
Log.print("update version: curent: " + Arrays.toString(version_description));
|
||||
Log.print(" (1) Major version (change API)");
|
||||
Log.print(" (2) Medium version (add feature)");
|
||||
Log.print(" (3) Minor version (Bug fix & doc)");
|
||||
Log.print(" (4) Do not release & continue");
|
||||
input1 = Commands.input();
|
||||
if (!Commands.stringInList(new String[]{"1", "2", "3", "4"}, input1)) {
|
||||
Log.info("!!! Must select in range [1..4]");
|
||||
input1 = null;
|
||||
}
|
||||
}
|
||||
// limit and force at 3 the nuber of variables
|
||||
String[] version_description_tmp = version_description;
|
||||
int[] version_description_int = new int[version_description.length];
|
||||
for (int iii=0; iii<version_description_tmp.length; iii++) {
|
||||
version_description_int[iii] = Integer.parseInt(version_description_tmp[iii]);
|
||||
}
|
||||
|
||||
int[] new_version_descrtiption = new int[version_description.length];
|
||||
if (version_description_int.length >= 1) {
|
||||
new_version_descrtiption[0] = version_description_int[0];
|
||||
} else {
|
||||
new_version_descrtiption[0] = 0;
|
||||
}
|
||||
if (version_description_int.length >= 2) {
|
||||
new_version_descrtiption[1] = version_description_int[1];
|
||||
} else {
|
||||
new_version_descrtiption[1] = 0;
|
||||
}
|
||||
if (version_description_int.length >= 3) {
|
||||
new_version_descrtiption[2] = version_description_int[2];
|
||||
} else {
|
||||
new_version_descrtiption[2] = 0;
|
||||
}
|
||||
Log.info("update version: curent: " + Arrays.toString(new_version_descrtiption));
|
||||
// increment the version
|
||||
if (input1.equals("1")) {
|
||||
new_version_descrtiption[0] += 1;
|
||||
new_version_descrtiption[1] = 0;
|
||||
new_version_descrtiption[2] = 0;
|
||||
} else if (input1.equals("2")) {
|
||||
version_description[1] += 1;
|
||||
new_version_descrtiption[2] = 0;
|
||||
} else if (input1.equals("3")) {
|
||||
version_description[2] += 1;
|
||||
} else if (input1.equals("4")) {
|
||||
Log.info("No release for this repository");
|
||||
return null;
|
||||
} else {
|
||||
Log.warning("An error occured for this repository");
|
||||
return null;
|
||||
}
|
||||
Log.info("update version: curent: " + Arrays.toString(new_version_descrtiption));
|
||||
return new_version_descrtiption;
|
||||
}
|
||||
|
||||
private static RevCommit get_specific_commit_message(final Git git, final ObjectId elem_sha1) {
|
||||
// TODO Auto-generated method stub
|
||||
try (RevWalk walk = new RevWalk(git.getRepository())) {
|
||||
RevCommit commit = walk.parseCommit(elem_sha1);
|
||||
System.out.println("\nCommit-Message: " + commit.getFullMessage());
|
||||
walk.dispose();
|
||||
return commit;
|
||||
} catch (MissingObjectException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IncorrectObjectTypeException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void merge_branch_on_master(final Git git, final String from, final DeliverMode deliverModeMerge, final String to) {
|
||||
ObjectId objectIdFrom = null;
|
||||
try {
|
||||
objectIdFrom = git.getRepository().resolve(from);
|
||||
} catch (RevisionSyntaxException | IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
Log.error("Merge error: can not retrive the source branch");
|
||||
return;
|
||||
}
|
||||
Commands.checkout(git, to);
|
||||
MergeResult res = null;
|
||||
try {
|
||||
res = git.merge()
|
||||
.include(objectIdFrom)
|
||||
.setMessage("Merge branch '" + from + "' into '" + to + "'")
|
||||
.setFastForward(deliverModeMerge==DeliverMode.MERGE?FastForwardMode.NO_FF:FastForwardMode.FF_ONLY)
|
||||
.call();
|
||||
} catch (GitAPIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (res == null || !res.getMergeStatus().isSuccessful()) {
|
||||
Log.error("Merge error:" + res.getConflicts().toString());
|
||||
// inform the user he has to handle the conflicts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.atriasoft.island;
|
||||
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
|
||||
public class Config {
|
||||
private static ConfigManifest config;
|
||||
|
@ -18,131 +18,136 @@ import org.atriasoft.island.internal.Log;
|
||||
|
||||
public class Env {
|
||||
private Env() {}
|
||||
public static final int ret_manifest_is_not_existing = -5;
|
||||
public static final int ret_action_is_not_existing = -10;
|
||||
public static final int ret_action_executing_system_error = -11;
|
||||
public static final int ret_action_wrong_parameters = -12;
|
||||
public static final int ret_action_partial_done = -13;
|
||||
public static final int ret_action_fail = -14;
|
||||
public static final int RET_MANIFEST_IS_NOT_EXISTING = -5;
|
||||
public static final int RET_ACTION_IS_NOT_EXISTING = -10;
|
||||
public static final int RET_ACTION_EXECUTING_SYSTEM_ERROR = -11;
|
||||
public static final int RET_ACTION_WRONG_PARAMETERS = -12;
|
||||
public static final int RET_ACTION_PARTIAL_DONE = -13;
|
||||
public static final int RET_ACTION_FAIL = -14;
|
||||
|
||||
public static int ret_action_need_updtate = 15;
|
||||
public static final int RET_ACTION_NEED_UPDTATE = 15;
|
||||
|
||||
public static String system_base_name = "island";
|
||||
public static String systemBaseName = "island";
|
||||
public static String artifactoryBaseFolder = "artifact";
|
||||
|
||||
public static void set_system_base_name(final String val) {
|
||||
Env.system_base_name = val;
|
||||
public static void setSystemBaseName(final String val) {
|
||||
Env.systemBaseName = val;
|
||||
}
|
||||
public static String get_system_base_name() {
|
||||
return Env.system_base_name;
|
||||
public static String getSystemBaseName() {
|
||||
return Env.systemBaseName;
|
||||
}
|
||||
|
||||
public static String get_system_config_name() {
|
||||
return "." + Env.system_base_name + "Config.json";
|
||||
public static String getSystemConfigName() {
|
||||
return "." + Env.systemBaseName + "Config.json";
|
||||
}
|
||||
|
||||
private static boolean fetch_manifest = true;
|
||||
private static boolean fetchManifest = true;
|
||||
|
||||
public static void set_fetch_manifest(final boolean val) {
|
||||
Env.fetch_manifest = val;
|
||||
public static void setFetchManifest(final boolean val) {
|
||||
Env.fetchManifest = val;
|
||||
}
|
||||
public static boolean get_fetch_manifest() {
|
||||
return Env.fetch_manifest;
|
||||
public static boolean getFetchManifest() {
|
||||
return Env.fetchManifest;
|
||||
}
|
||||
|
||||
private static int wait_between_sever_command = 0;
|
||||
private static int waitBetweenSeverCommand = 0;
|
||||
|
||||
public static void set_wait_between_sever_command(final int val) {
|
||||
Env.wait_between_sever_command = val;
|
||||
public static void setWaitBetweenSeverCommand(final int val) {
|
||||
Env.waitBetweenSeverCommand = val;
|
||||
}
|
||||
|
||||
public static int get_wait_between_sever_command() {
|
||||
return Env.wait_between_sever_command;
|
||||
public static int getWaitBetweenSeverCommand() {
|
||||
return Env.waitBetweenSeverCommand;
|
||||
}
|
||||
public static String filter_command = null;
|
||||
public static String filterCommand = null;
|
||||
|
||||
public static void set_filter_command(final String val) {
|
||||
Env.filter_command = val;
|
||||
public static void setFilterCommand(final String val) {
|
||||
Env.filterCommand = val;
|
||||
}
|
||||
public static String get_filter_command() {
|
||||
return Env.filter_command;
|
||||
public static String getFilterCommand() {
|
||||
return Env.filterCommand;
|
||||
}
|
||||
public static boolean need_process_with_filter(final String data) {
|
||||
if (Env.filter_command == null || Env.filter_command.equals("")) {
|
||||
public static boolean needProcessWithFilter(final String data) {
|
||||
if (Env.filterCommand == null || Env.filterCommand.equals("")) {
|
||||
return true;
|
||||
}
|
||||
if (data.length() < Env.filter_command.length()) {
|
||||
if (data.length() < Env.filterCommand.length()) {
|
||||
return false;
|
||||
}
|
||||
if (data.substring(0,Env.filter_command.length()).equals(Env.filter_command)) {
|
||||
if (data.substring(0,Env.filterCommand.length()).equals(Env.filterCommand)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean display_folder_instead_of_git_name = true;
|
||||
private static boolean displayFolderInsteadOfGitName = true;
|
||||
|
||||
public static void set_display_folder_instead_of_git_name(final boolean val) {
|
||||
Env.display_folder_instead_of_git_name = val;
|
||||
public static void setDisplayFolderInstead_ofGitName(final boolean val) {
|
||||
Env.displayFolderInsteadOfGitName = val;
|
||||
}
|
||||
public static boolean get_display_folder_instead_of_git_name() {
|
||||
return Env.display_folder_instead_of_git_name;
|
||||
public static boolean getDisplayFolderInsteadOfGitName() {
|
||||
return Env.displayFolderInsteadOfGitName;
|
||||
}
|
||||
|
||||
private static Path island_root_path = null;
|
||||
private static Path island_path_user_config = null;
|
||||
private static Path island_path = null;
|
||||
private static Path island_path_config = null;
|
||||
private static Path island_path_manifest = null;
|
||||
private static Path islandRootPath = null;
|
||||
private static Path islandPathUserConfig = null;
|
||||
private static Path islandPath = null;
|
||||
private static Path islandPathConfig = null;
|
||||
private static Path islandPathManifest = null;
|
||||
private static Path islandPathArtifactory = null;
|
||||
|
||||
|
||||
static {
|
||||
//String tmp = island_root_path.toAbsolutePath().toString();
|
||||
Env.island_root_path = Paths.get("");
|
||||
Path tmpPath = Env.island_root_path.toAbsolutePath();
|
||||
Env.islandRootPath = Paths.get("");
|
||||
Path tmpPath = Env.islandRootPath.toAbsolutePath();
|
||||
Log.info("Current absolute path is: " + tmpPath);
|
||||
while (!Files.isDirectory(tmpPath.resolve("." + Env.get_system_base_name()))) {
|
||||
while (!Files.isDirectory(tmpPath.resolve("." + Env.getSystemBaseName()))) {
|
||||
tmpPath = tmpPath.getParent();
|
||||
Log.info("test upper path: " + tmpPath);
|
||||
if (tmpPath == null) {
|
||||
Log.info("the root path of " + Env.get_system_base_name() + " must not be upper parent paths of (" + Env.island_root_path.toAbsolutePath() + ")");
|
||||
tmpPath = Env.island_root_path.toAbsolutePath();
|
||||
Log.info("the root path of " + Env.getSystemBaseName() + " must not be upper parent paths of (" + Env.islandRootPath.toAbsolutePath() + ")");
|
||||
tmpPath = Env.islandRootPath.toAbsolutePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Env.island_root_path = tmpPath;
|
||||
Env.island_path_user_config = Env.island_root_path.resolve(Env.get_system_config_name());
|
||||
Env.island_path = Env.island_root_path.resolve("." + Env.get_system_base_name());
|
||||
Env.island_path_config = Env.island_path.resolve("config.xml");
|
||||
Env.island_path_manifest = Env.island_path.resolve("manifest");
|
||||
Env.islandRootPath = tmpPath;
|
||||
Env.islandPathUserConfig = Env.islandRootPath.resolve(Env.getSystemConfigName());
|
||||
Env.islandPath = Env.islandRootPath.resolve("." + Env.getSystemBaseName());
|
||||
Env.islandPathConfig = Env.islandPath.resolve("config.xml");
|
||||
Env.islandPathManifest = Env.islandPath.resolve("manifest");
|
||||
Env.islandPathArtifactory = Env.islandPath.resolve(Env.artifactoryBaseFolder);
|
||||
}
|
||||
/**
|
||||
* To use later to know where the ".island" parent path is ...
|
||||
* @return the parent path of the ".island"
|
||||
*/
|
||||
public static Path get_island_root_path() {
|
||||
return Env.island_root_path;
|
||||
public static Path getIslandRootPath() {
|
||||
return Env.islandRootPath;
|
||||
}
|
||||
public static Path get_island_path() {
|
||||
return Env.island_path;
|
||||
public static Path getIslandPath() {
|
||||
return Env.islandPath;
|
||||
}
|
||||
public static Path get_island_path_config() {
|
||||
return Env.island_path_config;
|
||||
public static Path getIslandPathConfig() {
|
||||
return Env.islandPathConfig;
|
||||
}
|
||||
|
||||
public static Path getIslandPathManifest() {
|
||||
return Env.island_path_manifest;
|
||||
return Env.islandPathManifest;
|
||||
}
|
||||
public static Path get_island_path_user_config() {
|
||||
return Env.island_path_user_config;
|
||||
public static Path getIslandPathArtifactory() {
|
||||
return Env.islandPathArtifactory;
|
||||
}
|
||||
public static Path getIslandPathUserConfig() {
|
||||
return Env.islandPathUserConfig;
|
||||
}
|
||||
|
||||
public static void main(final String[] args) {
|
||||
Log.error("island_root_path = " + Env.island_root_path.toAbsolutePath());
|
||||
Log.error("island_path_user_config = " + Env.island_path_user_config.toAbsolutePath());
|
||||
Log.error("island_path = " + Env.island_path.toAbsolutePath());
|
||||
Log.error("island_path_config = " + Env.island_path_config.toAbsolutePath());
|
||||
Log.error("island_path_manifest = " + Env.island_path_manifest.toAbsolutePath());
|
||||
|
||||
Log.error("islandRootPath = " + Env.islandRootPath.toAbsolutePath());
|
||||
Log.error("islandPathUserConfig = " + Env.islandPathUserConfig.toAbsolutePath());
|
||||
Log.error("islandPath = " + Env.islandPath.toAbsolutePath());
|
||||
Log.error("islandPathConfig = " + Env.islandPathConfig.toAbsolutePath());
|
||||
Log.error("islandPathManifest = " + Env.islandPathManifest.toAbsolutePath());
|
||||
Log.error("islandPathArtifactory = " + Env.islandPathArtifactory.toAbsolutePath());
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,14 +10,15 @@ import org.atriasoft.death.annotation.ArgName;
|
||||
import org.atriasoft.death.annotation.ArgSubActions;
|
||||
import org.atriasoft.island.actions.BaseCheckout;
|
||||
import org.atriasoft.island.actions.BaseCommit;
|
||||
import org.atriasoft.island.actions.Deliver;
|
||||
import org.atriasoft.island.actions.BaseFetch;
|
||||
import org.atriasoft.island.actions.BaseInit;
|
||||
import org.atriasoft.island.actions.ManifestCheckout;
|
||||
import org.atriasoft.island.actions.ManifestStatus;
|
||||
import org.atriasoft.island.actions.BasePush;
|
||||
import org.atriasoft.island.actions.BaseStatus;
|
||||
import org.atriasoft.island.actions.BaseSync;
|
||||
import org.atriasoft.island.actions.Deliver;
|
||||
import org.atriasoft.island.actions.DependencySync;
|
||||
import org.atriasoft.island.actions.ManifestCheckout;
|
||||
import org.atriasoft.island.actions.ManifestStatus;
|
||||
import org.atriasoft.island.actions.VolatileAdd;
|
||||
import org.atriasoft.island.actions.VolatileList;
|
||||
import org.atriasoft.island.actions.VolatileRemove;
|
||||
@ -80,6 +81,7 @@ public class MainIsland {
|
||||
MainConfig.subActions.add(ManifestCheckout.class);
|
||||
MainConfig.subActions.add(ManifestStatus.class);
|
||||
MainConfig.subActions.add(Deliver.class);
|
||||
MainConfig.subActions.add(DependencySync.class);
|
||||
}
|
||||
|
||||
public boolean check_boolean(final String value) {
|
||||
@ -90,12 +92,12 @@ public class MainIsland {
|
||||
}
|
||||
|
||||
public void applyConfig() {
|
||||
Env.set_wait_between_sever_command(this.wait);
|
||||
Env.setWaitBetweenSeverCommand(this.wait);
|
||||
// Logger.setLevel(this.verbose);
|
||||
Env.set_display_folder_instead_of_git_name(this.folderDisplay);
|
||||
Env.setDisplayFolderInstead_ofGitName(this.folderDisplay);
|
||||
// Logger.setColor(this.color);
|
||||
Env.set_filter_command(this.filter);
|
||||
Env.set_fetch_manifest(this.fetchManifest);
|
||||
Env.setFilterCommand(this.filter);
|
||||
Env.setFetchManifest(this.fetchManifest);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,20 +14,23 @@ import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||
import org.atriasoft.exml.exception.ExmlException;
|
||||
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.Link;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.RemoteConfig;
|
||||
import org.atriasoft.island.model.manifest.Artifactory;
|
||||
import org.atriasoft.island.model.manifest.DeliverMode;
|
||||
import org.atriasoft.island.model.manifest.Dependency;
|
||||
import org.atriasoft.island.model.manifest.Link;
|
||||
import org.atriasoft.island.model.manifest.ManifestFile;
|
||||
import org.atriasoft.island.model.manifest.OptionRepository;
|
||||
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
import org.atriasoft.island.model.manifest.RemoteConfig;
|
||||
|
||||
public class Manifest {
|
||||
public static boolean isInit() {
|
||||
if (!Files.exists(Env.get_island_path())){
|
||||
Log.verbose("Lutin is not init: path does not exist: '" + Env.get_island_path() + "'");
|
||||
if (!Files.exists(Env.getIslandPath())){
|
||||
Log.verbose("Lutin is not init: path does not exist: '" + Env.getIslandPath() + "'");
|
||||
return false;
|
||||
}
|
||||
if (!Files.exists(Env.get_island_path_config())) {
|
||||
Log.verbose("Lutin is not init: config does not exist: '" + Env.get_island_path_config() + "'");
|
||||
if (!Files.exists(Env.getIslandPathConfig())) {
|
||||
Log.verbose("Lutin is not init: config does not exist: '" + Env.getIslandPathConfig() + "'");
|
||||
return false;
|
||||
}
|
||||
if (!Files.exists(Env.getIslandPathManifest())) {
|
||||
@ -39,7 +42,7 @@ public class Manifest {
|
||||
public static void checkIsInit() {
|
||||
// check if .XXX exist (create it if needed)
|
||||
if (!Manifest.isInit()) {
|
||||
Log.error("System not init: missing config: '" + Env.get_island_path() + "'. Call <island init> first");
|
||||
Log.error("System not init: missing config: '" + Env.getIslandPath() + "'. Call <island init> first");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
@ -125,12 +128,52 @@ public class Manifest {
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
public List<Artifactory> getAllArtefactories() {
|
||||
ManifestFile mani = this.manifests.get(this.rootManifest);
|
||||
return getAllArtefactories(mani);
|
||||
}
|
||||
|
||||
public List<Artifactory> getAllArtefactories(final ManifestFile mani) {
|
||||
List<Artifactory> out = new ArrayList<>();
|
||||
// add all local project
|
||||
for (Artifactory elem : mani.getArtefactories()) {
|
||||
Log.verbose("parse a " + elem);
|
||||
Artifactory conf = elem.clone();
|
||||
out.add(conf);
|
||||
}
|
||||
// add all include project
|
||||
for (String elemInclude : mani.getIncludes()) {
|
||||
ManifestFile mani2 = this.manifests.get(elemInclude);
|
||||
List<Artifactory> list_project = getAllArtefactories(mani2);
|
||||
for (Artifactory elem_proj : list_project) {
|
||||
out.add(elem_proj);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public List<Dependency> getAllDependencies() {
|
||||
ManifestFile mani = this.manifests.get(this.rootManifest);
|
||||
return getAllDependencies(mani);
|
||||
}
|
||||
|
||||
public List<Dependency> getAllDependencies(final ManifestFile mani) {
|
||||
List<Dependency> out = new ArrayList<>();
|
||||
// add all local project
|
||||
out.addAll(mani.getDependencies());
|
||||
// add all include project
|
||||
for (String elemInclude : mani.getIncludes()) {
|
||||
ManifestFile mani2 = this.manifests.get(elemInclude);
|
||||
out.addAll(getAllDependencies(mani2));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public List<ProjectConfig> get_all_configs() {
|
||||
ManifestFile mani = this.manifests.get(this.rootManifest);
|
||||
return get_all_configs(mani, null, new ArrayList<>());
|
||||
}
|
||||
|
||||
|
||||
public List<ProjectConfig> get_all_configs(final ManifestFile mani, OptionRepository defaultPlouf, final List<RemoteConfig> upper_remotes) {
|
||||
List<ProjectConfig> out = new ArrayList<>();
|
||||
if (defaultPlouf == null) {
|
||||
@ -144,7 +187,7 @@ public class Manifest {
|
||||
// add all local project
|
||||
for (ProjectConfig elem : mani.getProjects()) {
|
||||
Log.verbose("parse element " + elem);
|
||||
if (!Env.need_process_with_filter(elem.getName())) {
|
||||
if (!Env.needProcessWithFilter(elem.getName())) {
|
||||
Log.info("Filter repository: " + elem.getName());
|
||||
continue;
|
||||
}
|
||||
@ -245,6 +288,8 @@ public class Manifest {
|
||||
*/
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
public String getDeliverDevelop() {
|
||||
OptionRepository defaultPlouf = this.defaultBase;
|
||||
if (this.defaultWhat != null) {
|
||||
@ -259,5 +304,12 @@ public class Manifest {
|
||||
}
|
||||
return defaultPlouf.getBranchRelease();
|
||||
}
|
||||
public DeliverMode getDeliverModeMerge() {
|
||||
OptionRepository defaultPlouf = this.defaultBase;
|
||||
if (this.defaultWhat != null) {
|
||||
defaultPlouf = this.defaultWhat;
|
||||
}
|
||||
return defaultPlouf.getDeliverMode();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.atriasoft.island;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
@ -9,17 +10,24 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.manifest.Dependency;
|
||||
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
|
||||
public class Tools {
|
||||
|
||||
|
||||
public static String get_list_base_display(final int id, final int count, final ProjectConfig elem) {
|
||||
if (!Env.get_display_folder_instead_of_git_name()) {
|
||||
public static String getListBaseDisplay(final int id, final int count, final ProjectConfig elem) {
|
||||
if (!Env.getDisplayFolderInsteadOfGitName()) {
|
||||
return id + "/" + count + " : " + elem.getName();
|
||||
}
|
||||
return id + "/" + count + " : " + elem.getPath();
|
||||
}
|
||||
public static String getListBaseDisplay(final int id, final int count, final Dependency elem) {
|
||||
if (!Env.getDisplayFolderInsteadOfGitName()) {
|
||||
return id + "/" + count + " : " + elem.name();
|
||||
}
|
||||
return id + "/" + count + " : " + elem.name();
|
||||
}
|
||||
|
||||
public static void createDirectory(final Path basePath) {
|
||||
Path absPath = basePath.toAbsolutePath();
|
||||
@ -35,7 +43,7 @@ public class Tools {
|
||||
}
|
||||
|
||||
public static void waitForServerIfNeeded() {
|
||||
int waitTime = Env.get_wait_between_sever_command();
|
||||
int waitTime = Env.getWaitBetweenSeverCommand();
|
||||
if (waitTime>0) {
|
||||
Log.info("Waiting between commands: " + waitTime + "s");
|
||||
try {
|
||||
@ -58,7 +66,7 @@ public class Tools {
|
||||
* @param version
|
||||
* @return list of element : {"1", "5", "2", "dev"}
|
||||
*/
|
||||
public static String[] version_string_to_list(final String version) {
|
||||
public static String[] versionStringToList(final String version) {
|
||||
Log.verbose("parse version string '" + version +"'");
|
||||
List<String> out = new ArrayList<>();
|
||||
if (version == null || version.isEmpty()) {
|
||||
@ -77,5 +85,38 @@ public class Tools {
|
||||
}
|
||||
return out.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static String versionToString(final int[] version, final boolean develop) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int iii=0; iii<version.length; iii++) {
|
||||
if (sb.length() != 0) {
|
||||
sb.append(".");
|
||||
}
|
||||
sb.append(Integer.toString(version[iii]));
|
||||
}
|
||||
if (develop) {
|
||||
sb.append("-dev");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void fileWriteData(final Path path, final String data) {
|
||||
if (!Files.exists(path.getParent())) {
|
||||
File file = path.getParent().toFile();
|
||||
if (!file.mkdirs()) {
|
||||
Log.critical("Can not create the path:" + path.getParent());
|
||||
}
|
||||
}
|
||||
try {
|
||||
Files.writeString(path, data);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPlural(final List<?> artefactories) {
|
||||
return artefactories.size() > 1 ? "ies" : "y";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
|
||||
@ArgCommand("checkout")
|
||||
@ArgDescription("Ckeckout a specific branch in all repository")
|
||||
@ -58,8 +58,8 @@ public class BaseCheckout {
|
||||
boolean have_error = false;
|
||||
for (ProjectConfig elem : all_project) {
|
||||
id_element += 1;
|
||||
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||
if (!StatusActions.checkout_elem(elem, this.remote, branch, base_display)) {
|
||||
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||
if (!StatusActions.checkoutElem(elem, this.remote, branch, base_display)) {
|
||||
have_error = true;
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
|
||||
@ -60,9 +60,9 @@ public class BaseCommit {
|
||||
|
||||
for (ProjectConfig elem : all_project) {
|
||||
id_element++;
|
||||
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||
Log.info("commit : " + base_display);
|
||||
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||
if ( !Commands.isGitRepository(git_repo_path.toString())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.lib.TextProgressMonitor;
|
||||
@ -59,11 +59,11 @@ public class BaseFetch {
|
||||
|
||||
for (ProjectConfig elem : all_project) {
|
||||
id_element++;
|
||||
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||
Log.print("fetch : " + base_display);
|
||||
Tools.waitForServerIfNeeded();
|
||||
Log.debug("elem : " + elem);
|
||||
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||
if (elem.getTag() != null) {
|
||||
Log.todo("Need to select a specific tag version ... " + elem.getTag());
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.transport.SshSessionFactory;
|
||||
@ -44,9 +44,9 @@ public class BaseInit {
|
||||
}
|
||||
Log.info("Init with: '" + addressManifest + "' branch='" + this.branch + "' name of manifest='" + this.manifestFile + "'");
|
||||
if (Manifest.isInit()) {
|
||||
Log.critical("System already init: path already exist: '" + Env.get_island_path() + "'");
|
||||
Log.critical("System already init: path already exist: '" + Env.getIslandPath() + "'");
|
||||
}
|
||||
Tools.createDirectory(Env.get_island_path());
|
||||
Tools.createDirectory(Env.getIslandPath());
|
||||
|
||||
// create the file configuration:
|
||||
ConfigManifest configuration = Config.createUniqueConfig();
|
||||
|
@ -17,8 +17,8 @@ import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.lib.TextProgressMonitor;
|
||||
@ -58,11 +58,11 @@ public class BasePush {
|
||||
|
||||
for (ProjectConfig elem : all_project) {
|
||||
id_element++;
|
||||
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||
Log.print("push : " + base_display + dryRunComment);
|
||||
Tools.waitForServerIfNeeded();
|
||||
Log.debug("elem : " + elem);
|
||||
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||
if (!Commands.isGitRepository(elem.getPath())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
|
||||
@ -65,7 +65,7 @@ public class BaseStatus {
|
||||
boolean is_behind = false;
|
||||
for (ProjectConfig elem : all_project) {
|
||||
id_element++;
|
||||
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||
int ret = StatusActions.displayStatus(elem, this.remote, this.display_tag, id_element, base_display);
|
||||
if (ret != 0) {
|
||||
is_behind = true;
|
||||
|
@ -17,9 +17,9 @@ import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.MirrorConfig;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.MirrorConfig;
|
||||
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.lib.BranchConfig;
|
||||
@ -72,11 +72,11 @@ public class BaseSync {
|
||||
|
||||
for (ProjectConfig elem : all_project) {
|
||||
id_element++;
|
||||
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||
Log.info("sync : " + base_display);
|
||||
Tools.waitForServerIfNeeded();
|
||||
Log.debug("elem : " + elem);
|
||||
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||
if (elem.getTag() != null) {
|
||||
Log.todo("Need to select a specific tag version ... " + elem.getTag());
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.atriasoft.island.actions;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.death.annotation.ArgAlias;
|
||||
@ -18,10 +19,11 @@ import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.ResetCommand.ResetType;
|
||||
|
||||
@ArgCommand("deliver")
|
||||
@ArgDescription("Deliver the current repository (develop & master MUST be up to date and you MUST be on master)")
|
||||
@ -63,7 +65,7 @@ public class Deliver {
|
||||
int id_element = 0;
|
||||
for (ProjectConfig elem : all_project) {
|
||||
id_element++;
|
||||
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||
Log.verbose("delivercheck : " + base_display);
|
||||
if (!StatusActions.deliverCheck(elem, null, id_element, base_display, this.from, this.to)) {
|
||||
deliver_availlable = false;
|
||||
@ -77,12 +79,12 @@ public class Deliver {
|
||||
id_element = 0;
|
||||
for (ProjectConfig elem : all_project) {
|
||||
id_element += 1;
|
||||
String base_display = Tools.get_list_base_display(id_element, all_project.size(), elem);
|
||||
String base_display = Tools.getListBaseDisplay(id_element, all_project.size(), elem);
|
||||
Log.info("deliver: ========================================================================");
|
||||
Log.info("deliver:.equals(" + base_display);
|
||||
Log.info("deliver: ========================================================================");
|
||||
|
||||
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||
// Check the validity of the version,
|
||||
CreateVersion curentVersionElem = Commands.get_current_version_repo(git_repo_path);
|
||||
if (curentVersionElem == null) {
|
||||
@ -90,43 +92,49 @@ public class Deliver {
|
||||
}
|
||||
Log.info("deliver: ==> version: " + curentVersionElem.version());
|
||||
|
||||
|
||||
|
||||
Git git = Git.open(git_repo_path.toFile());
|
||||
|
||||
// go to the dev branch
|
||||
select_branch = Commands.get_current_branch(git_repo_path);
|
||||
|
||||
// Checkout destination branch:
|
||||
Commands.checkout(git_repo_path, destination_branch);
|
||||
|
||||
Commands.checkout(git, this.to);
|
||||
// create new repo tag
|
||||
new_version_description = status.create_new_version_repo(git_repo_path, version_description, add_in_version_management, source_branch, destination_branch);
|
||||
Log.info("new version: " + str(new_version_description));
|
||||
int[] new_version_description = Commands.create_new_version_repo(git, curentVersionElem.version(), curentVersionElem.addInManagement(), this.from, this.to);
|
||||
Log.info("new version: " + Arrays.toString(new_version_description));
|
||||
if (new_version_description == null) {
|
||||
continue;
|
||||
}
|
||||
// merge branch
|
||||
if (mani.deliver_mode.equals("merge") ) {
|
||||
merge_force = true;
|
||||
} else {
|
||||
merge_force = false;
|
||||
}
|
||||
Commands.merge_branch_on_master(git_repo_path, source_branch, merge_force, branch_destination=destination_branch);
|
||||
|
||||
version_path_file = new Path(git_repo_path, "version.txt");
|
||||
Commands.merge_branch_on_master(git, this.from, mani.getDeliverModeMerge(), this.to);
|
||||
|
||||
Path version_path_file = git_repo_path.resolve("version.txt");
|
||||
// update version file:
|
||||
tools.file_write_data(version_path_file, tools.version_to_string(new_version_description));
|
||||
Commands.add_file(git_repo_path, version_path_file);
|
||||
Commands.commit_all(git_repo_path, "[RELEASE] Release v" + tools.version_to_string(new_version_description));
|
||||
Commands.tag(git_repo_path, "v" + tools.version_to_string(new_version_description));
|
||||
Commands.checkout(git_repo_path, source_branch);
|
||||
Commands.reset_hard(git_repo_path, destination_branch);
|
||||
new_version_description.append("dev");
|
||||
tools.file_write_data(version_path_file, tools.version_to_string(new_version_description));
|
||||
Commands.add_file(git_repo_path, version_path_file);
|
||||
Commands.commit_all(git_repo_path, status.default_update_message);
|
||||
Commands.checkout(git_repo_path, destination_branch);
|
||||
String releaseVersion = Tools.versionToString(new_version_description, false);
|
||||
Tools.fileWriteData(version_path_file, releaseVersion);
|
||||
git.add()
|
||||
.addFilepattern("version.txt")
|
||||
.call();
|
||||
git.commit()
|
||||
.setAll(true)
|
||||
.setMessage("[RELEASE] Release v" + releaseVersion)
|
||||
.call();
|
||||
git.tag()
|
||||
.setName("v" + releaseVersion)
|
||||
.call();
|
||||
// now we update the development branch:
|
||||
git.checkout()
|
||||
.setCreateBranch(false)
|
||||
.setName("refs/heads/" + this.from)
|
||||
.call();
|
||||
git.reset()
|
||||
.setMode(ResetType.HARD)
|
||||
.setRef("refs/heads/"+ this.to)
|
||||
.call();
|
||||
Tools.fileWriteData(version_path_file, Tools.versionToString(new_version_description, true));
|
||||
git.add()
|
||||
.addFilepattern("version.txt")
|
||||
.call();
|
||||
git.commit()
|
||||
.setAll(true)
|
||||
.setMessage(StatusActions.defaultUpdateMessage)
|
||||
.call();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
209
src/org/atriasoft/island/actions/DependencySync.java
Normal file
209
src/org/atriasoft/island/actions/DependencySync.java
Normal file
@ -0,0 +1,209 @@
|
||||
package org.atriasoft.island.actions;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.death.annotation.ArgCommand;
|
||||
import org.atriasoft.death.annotation.ArgDescription;
|
||||
import org.atriasoft.death.annotation.ArgExecute;
|
||||
import org.atriasoft.death.annotation.ArgSample;
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.exception.ExmlException;
|
||||
import org.atriasoft.island.Config;
|
||||
import org.atriasoft.island.Env;
|
||||
import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.manifest.Artifactory;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.Dependency;
|
||||
import org.atriasoft.island.model.maven.MavenMetadata;
|
||||
|
||||
@ArgCommand("depend-sync")
|
||||
@ArgDescription("Syncronize all the dependencies referenced")
|
||||
@ArgSample("depend-sync")
|
||||
public class DependencySync {
|
||||
|
||||
private static final String MAVEN_METADATA = "maven-metadata.xml";
|
||||
|
||||
Artifactory findArtifactory(final List<Artifactory> artefactories, final String name) {
|
||||
Artifactory out = null;
|
||||
for (Artifactory elem: artefactories) {
|
||||
if ("default".equals(elem.getName())) {
|
||||
out = elem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// By default we are capable to use maven artefactory (can be replace with using "default" name).
|
||||
if (out == null) {
|
||||
out = new Artifactory("default", "https://repo1.maven.org/maven2", "maven");
|
||||
}
|
||||
boolean find = false;
|
||||
for (Artifactory elem: artefactories) {
|
||||
if (name.equals(elem.getName())) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
Log.error("Can not find the remote '" + name + "'artefactory in the list ==> fallback to 'default'");
|
||||
return out;
|
||||
}
|
||||
|
||||
public String createMavenMetadataRemoteFileName(final List<Artifactory> artefactories, final Dependency dependency) {
|
||||
return createBasePkgRemoteFileName(artefactories, dependency, DependencySync.MAVEN_METADATA);
|
||||
}
|
||||
|
||||
public Path createMetadataLocalFileName(final List<Artifactory> artefactories, final Dependency dependency) {
|
||||
return createBasePkgLocalFileName(artefactories, dependency, DependencySync.MAVEN_METADATA);
|
||||
}
|
||||
|
||||
public String createBasePkgRemoteFileName(final List<Artifactory> artefactories, final Dependency dependency, final String version) {
|
||||
Artifactory artifactory = findArtifactory(artefactories, dependency.remote());
|
||||
String out = artifactory.getFetch();
|
||||
while (out.endsWith("/")) {
|
||||
out = out.substring(0, out.length()-1);
|
||||
}
|
||||
out += "/" + dependency.org().replace(".", "/") + "/" + dependency.name() + "/" + version;
|
||||
return out;
|
||||
}
|
||||
|
||||
public Path createBasePkgLocalFileName(final List<Artifactory> artefactories, final Dependency dependency, final String version) {
|
||||
Artifactory artifactory = findArtifactory(artefactories, dependency.remote());
|
||||
String out = artifactory.getName() + "/" + dependency.org().replace(".", "/") + "/" + dependency.name() + "/" + version;
|
||||
Path outPath = Env.getIslandPathArtifactory().resolve(out);
|
||||
return outPath;
|
||||
}
|
||||
|
||||
|
||||
public String getJavaPackageFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + ".jar";
|
||||
}
|
||||
public String getJavaDocFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + "-javadoc.jar";
|
||||
}
|
||||
public String getJavaSourceFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + "-sources.jar";
|
||||
}
|
||||
|
||||
@ArgExecute
|
||||
public void execute() throws ActionException, Exception {
|
||||
|
||||
// check system is OK
|
||||
Manifest.checkIsInit();
|
||||
ConfigManifest configuration = Config.getUniqueConfig();
|
||||
|
||||
// load the manifest after pulling it (if possible)
|
||||
Path file_source_manifest = Env.getIslandPathManifest().resolve(configuration.getManifestName());
|
||||
if (!Files.exists(file_source_manifest)) {
|
||||
Log.critical("Missing manifest file : '" + file_source_manifest + "'");
|
||||
}
|
||||
Manifest mani = new Manifest(file_source_manifest);
|
||||
|
||||
List<Artifactory> artefactories = mani.getAllArtefactories();
|
||||
List<Dependency> dependencies = mani.getAllDependencies();
|
||||
|
||||
Log.info("Synchronize of: " + dependencies.size() + " dependenc" + Tools.getPlural(dependencies));
|
||||
Log.info("base on: " + artefactories.size() + " artefactor" + Tools.getPlural(artefactories));
|
||||
int id_element = 0;
|
||||
|
||||
for (Dependency elem : dependencies) {
|
||||
id_element++;
|
||||
String base_display = Tools.getListBaseDisplay(id_element, dependencies.size(), elem);
|
||||
Log.info("dep-sync : " + base_display);
|
||||
Tools.waitForServerIfNeeded();
|
||||
Log.debug("elem : " + elem);
|
||||
String metadataFile = createMavenMetadataRemoteFileName(artefactories, elem);
|
||||
Log.print("Metadata position: " + metadataFile);
|
||||
Path localPath = createMetadataLocalFileName(artefactories, elem);
|
||||
String dataAsString = readAllMatadataAndStore(metadataFile, localPath);
|
||||
MavenMetadata metaData = null;
|
||||
try {
|
||||
metaData = Exml.parseOne(dataAsString, MavenMetadata.class, "metadata");
|
||||
} catch (ExmlException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.print("metaData=" + metaData);
|
||||
|
||||
// TODO : check if the curent file is newer....
|
||||
|
||||
// TODO : Check if the version is downloaded
|
||||
|
||||
String lastReleaseTag = metaData.versioning().release();
|
||||
|
||||
String remotePakageFileName = createBasePkgRemoteFileName(artefactories, elem, lastReleaseTag);
|
||||
Path localPackageFileName = createBasePkgLocalFileName(artefactories, elem, lastReleaseTag);
|
||||
// retrieve binary
|
||||
String base = getJavaPackageFileName(elem, lastReleaseTag);
|
||||
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
||||
// retrieve javadoc
|
||||
base = getJavaDocFileName(elem, lastReleaseTag);
|
||||
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
||||
// retrieve sources
|
||||
base = getJavaSourceFileName(elem, lastReleaseTag);
|
||||
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
||||
}
|
||||
Log.print("Dependency sync END");
|
||||
}
|
||||
|
||||
String readAllMatadataAndStore(final String urlPath, final Path path) throws Exception {
|
||||
URL url = new URL(urlPath);
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setConnectTimeout(5000);
|
||||
con.setReadTimeout(5000);
|
||||
con.setInstanceFollowRedirects(false);
|
||||
StringBuilder result = new StringBuilder();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
|
||||
for (String line; (line = reader.readLine()) != null; ) {
|
||||
result.append(line);
|
||||
result.append("\n");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Log.error("Can not retrive data from artefactory ..." + ex.getLocalizedMessage());
|
||||
throw ex;
|
||||
}
|
||||
String dataAsString = result.toString();
|
||||
Log.print("return=" + dataAsString);
|
||||
Tools.fileWriteData(path, dataAsString);
|
||||
return dataAsString;
|
||||
}
|
||||
void readRemoteFileAndStore(final String urlPath, final Path path, final String baseName) throws Exception {
|
||||
if (!Files.exists(path.getParent())) {
|
||||
File file = path.getParent().toFile();
|
||||
if (!file.mkdirs()) {
|
||||
Log.critical("Can not create the path:" + path.getParent());
|
||||
}
|
||||
}
|
||||
URL url = new URL(urlPath);
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setConnectTimeout(5000);
|
||||
con.setReadTimeout(5000);
|
||||
con.setInstanceFollowRedirects(false);
|
||||
FileOutputStream outputStream = new FileOutputStream(path.toFile());
|
||||
final int BUFFER_SIZE = 1024*1024;
|
||||
StringBuilder result = new StringBuilder();
|
||||
InputStream inputStream = con.getInputStream();
|
||||
int bytesRead = -1;
|
||||
int totalRead = 0;
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
totalRead += bytesRead;
|
||||
System.out.print("Download: " + baseName + " =" + totalRead + " B\r");
|
||||
}
|
||||
System.out.print("Download: " + baseName + " =" + totalRead + " B\n");
|
||||
outputStream.close();
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
|
||||
@ArgCommand("manifest-checkout")
|
||||
@ArgDescription("Ckeckout a specific branch of the manifest")
|
||||
@ -37,8 +37,8 @@ public class ManifestCheckout {
|
||||
|
||||
ConfigManifest configuration = Config.getUniqueConfig();
|
||||
ProjectConfig elem = configuration.getManifestConfig();
|
||||
String base_display = Tools.get_list_base_display(0, 0, elem);
|
||||
if (!StatusActions.checkout_elem(elem, this.remote, branch, base_display)) {
|
||||
String base_display = Tools.getListBaseDisplay(0, 0, elem);
|
||||
if (!StatusActions.checkoutElem(elem, this.remote, branch, base_display)) {
|
||||
Log.error("Checkout have fail !!! ");
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ import org.atriasoft.island.Config;
|
||||
import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
|
||||
@ArgCommand("manifest-status")
|
||||
@ArgDescription("Get the status of manifest repositories")
|
||||
@ -34,7 +34,7 @@ public class ManifestStatus {
|
||||
Manifest.checkIsInit();
|
||||
ConfigManifest configuration = Config.getUniqueConfig();
|
||||
ProjectConfig elem = configuration.getManifestConfig();
|
||||
String base_display = Tools.get_list_base_display(0, 0, elem);
|
||||
String base_display = Tools.getListBaseDisplay(0, 0, elem);
|
||||
StatusActions.displayStatus(elem, this.remote, this.displayTag, 0, base_display);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import org.atriasoft.island.Commands;
|
||||
import org.atriasoft.island.Env;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.DeltaBranch;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
|
||||
import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
@ -17,92 +17,92 @@ import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
|
||||
public class StatusActions {
|
||||
|
||||
private static String default_behind_message = "[DEV] update dev tag version";
|
||||
private static String default_update_message = "[VERSION] update dev tag version";
|
||||
private static String base_name_of_a_tagged_branch = "branch_on_tag_";
|
||||
public static String defaultBehindMessage = "[DEV] update dev tag version";
|
||||
public static String defaultUpdateMessage = "[VERSION] update dev tag version";
|
||||
public static String baseNameOfATaggedBranch = "branch_on_tag_";
|
||||
|
||||
public static boolean checkout_elem(final ProjectConfig elem, final String argument_remote_name, String branch_to_checkout, final String base_display) throws Exception {
|
||||
Log.verbose("checkout : " + base_display);
|
||||
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||
public static boolean checkoutElem(final ProjectConfig elem, final String argumentRemoteName, String branchToCheckout, final String baseDisplay) throws Exception {
|
||||
Log.verbose("checkout : " + baseDisplay);
|
||||
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||
if (!Files.exists(git_repo_path)){
|
||||
Log.warning("checkout " + base_display + " ==> repository does not exist ...");
|
||||
Log.warning("checkout " + baseDisplay + " ==> repository does not exist ...");
|
||||
return false;
|
||||
}
|
||||
// check if the repository is modify
|
||||
Git git = Git.open(git_repo_path.toFile());
|
||||
boolean is_modify = git.status().call().hasUncommittedChanges();
|
||||
if (is_modify){
|
||||
Log.warning("checkout " + base_display + " ==> modify data can not checkout new branch");
|
||||
Log.warning("checkout " + baseDisplay + " ==> modify data can not checkout new branch");
|
||||
return false;
|
||||
}
|
||||
List<String> list_branch_local = Commands.getListBranchLocal(git);
|
||||
String select_branch = git.getRepository().getBranch();
|
||||
|
||||
boolean is_tag = false;
|
||||
if (branch_to_checkout.equals("__TAG__")) {
|
||||
branch_to_checkout = StatusActions.base_name_of_a_tagged_branch + elem.getTag();
|
||||
if (branchToCheckout.equals("__TAG__")) {
|
||||
branchToCheckout = StatusActions.baseNameOfATaggedBranch + elem.getTag();
|
||||
is_tag = true;
|
||||
if (elem.isVolatile()) {
|
||||
Log.info("checkout " + base_display + " ==> Can not checkout for 'volatile' repository");
|
||||
Log.info("checkout " + baseDisplay + " ==> Can not checkout for 'volatile' repository");
|
||||
return true;
|
||||
}
|
||||
if (elem.getTag() == null) {
|
||||
Log.info("checkout " + base_display + " ==> Can not checkout for 'null' Tag");
|
||||
Log.info("checkout " + baseDisplay + " ==> Can not checkout for 'null' Tag");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// check if we are on the good branch{
|
||||
if (branch_to_checkout.equals(select_branch)) {
|
||||
Log.info("checkout " + base_display + " ==> No change already on good branch");
|
||||
if (branchToCheckout.equals(select_branch)) {
|
||||
Log.info("checkout " + baseDisplay + " ==> No change already on good branch");
|
||||
return true;
|
||||
}
|
||||
// check if we have already checkout the branch before
|
||||
Log.verbose(" check : " + branch_to_checkout + " in " + list_branch_local);
|
||||
if (list_branch_local.contains("refs/heads/" + branch_to_checkout)) {
|
||||
git.checkout().setCreateBranch(false).setName("refs/heads/" + branch_to_checkout).call();
|
||||
Log.info("checkout " + base_display + " ==> switch branch");
|
||||
Log.verbose(" check : " + branchToCheckout + " in " + list_branch_local);
|
||||
if (list_branch_local.contains("refs/heads/" + branchToCheckout)) {
|
||||
git.checkout().setCreateBranch(false).setName("refs/heads/" + branchToCheckout).call();
|
||||
Log.info("checkout " + baseDisplay + " ==> switch branch");
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> list_tags = Commands.getTags(git);
|
||||
if (list_tags.contains("refs/tags/" + branch_to_checkout)) {
|
||||
if (list_tags.contains("refs/tags/" + branchToCheckout)) {
|
||||
is_tag = true;
|
||||
if (elem.getTag() == null) {
|
||||
elem.setTag(branch_to_checkout);
|
||||
branch_to_checkout = StatusActions.base_name_of_a_tagged_branch + elem.getTag();
|
||||
elem.setTag(branchToCheckout);
|
||||
branchToCheckout = StatusActions.baseNameOfATaggedBranch + elem.getTag();
|
||||
}
|
||||
}
|
||||
// Check if the remote branch exist ...
|
||||
if (is_tag) {
|
||||
Log.info("checkout " + base_display + " ==> NO remote branch");
|
||||
Log.info("checkout " + baseDisplay + " ==> NO remote branch");
|
||||
return true;
|
||||
}
|
||||
List<String> list_branch_remote = Commands.getListBranchRemote(git);
|
||||
String tryRemoteBranch = elem.getSelectRemotes().getName() + "/" + branch_to_checkout;
|
||||
String tryRemoteBranch = elem.getSelectRemotes().getName() + "/" + branchToCheckout;
|
||||
if (list_branch_remote.contains("refs/remotes/" + tryRemoteBranch)) {
|
||||
Log.info(" ==> find ...");
|
||||
try {
|
||||
git.checkout()
|
||||
.setCreateBranch(true)
|
||||
.setName(branch_to_checkout)
|
||||
.setName(branchToCheckout)
|
||||
.setUpstreamMode(SetupUpstreamMode.TRACK)
|
||||
.setStartPoint(tryRemoteBranch)
|
||||
.call();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
Log.error("checkout " + base_display + " ==> Can not checkout to the correct branch");
|
||||
Log.error("checkout " + baseDisplay + " ==> Can not checkout to the correct branch");
|
||||
return false;
|
||||
}
|
||||
Log.info("checkout " + base_display + " ==> create new branch");
|
||||
Log.info("checkout " + baseDisplay + " ==> create new branch");
|
||||
return true;
|
||||
}
|
||||
// Checkout a specific tags{
|
||||
if (!list_tags.contains(elem.getTag())) {
|
||||
Log.info("checkout " + base_display + " ==> NO remote tags");
|
||||
Log.info("checkout " + baseDisplay + " ==> NO remote tags");
|
||||
return true;
|
||||
}
|
||||
Log.info(" ==> find ...");
|
||||
Log.todo("checkout " + base_display + " ==> Can not checkout to the correct tags MUST be inplemented");
|
||||
Log.todo("checkout " + baseDisplay + " ==> Can not checkout to the correct tags MUST be inplemented");
|
||||
return false;
|
||||
/*
|
||||
// checkout the new branch{
|
||||
@ -120,16 +120,16 @@ public class StatusActions {
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
public static int displayStatus(final ProjectConfig elem, final String argument_remote_name, final boolean argument_display_tag, final int id_element, final String base_display) throws IOException, GitAPIException {
|
||||
public static int displayStatus(final ProjectConfig elem, final String argumentRemoteName, final boolean argumentDisplayTag, final int idElement, final String baseDisplay) throws IOException, GitAPIException {
|
||||
String volatileString = "";
|
||||
if (elem.isVolatile()) {
|
||||
volatileString = " (volatile)";
|
||||
}
|
||||
Log.verbose("status : " + base_display);
|
||||
Log.verbose("status : " + baseDisplay);
|
||||
//Log.debug("elem : " + str(elem))
|
||||
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||
if (!Files.exists(git_repo_path)) {
|
||||
Log.print(base_display + volatileString + "\r\t\t\t\t\t\t\t\t\t" + " (not download)");
|
||||
Log.print(baseDisplay + volatileString + "\r\t\t\t\t\t\t\t\t\t" + " (not download)");
|
||||
return 0;
|
||||
}
|
||||
Git git = Git.open(git_repo_path.toFile());
|
||||
@ -139,19 +139,19 @@ public class StatusActions {
|
||||
String select_branch = git.getRepository().getBranch();
|
||||
Log.verbose("List all branch: " + list_branch);
|
||||
String tracking_remote_branch = null;
|
||||
if (!select_branch.startsWith(StatusActions.base_name_of_a_tagged_branch)) {
|
||||
if (!select_branch.startsWith(StatusActions.baseNameOfATaggedBranch)) {
|
||||
// get tracking branch
|
||||
tracking_remote_branch = Commands.getTrackingBranch(git, argument_remote_name, select_branch);
|
||||
tracking_remote_branch = Commands.getTrackingBranch(git, argumentRemoteName, select_branch);
|
||||
if (tracking_remote_branch == null) {
|
||||
if (select_branch == null) {
|
||||
Log.print(base_display + volatileString + "\r\t\t\t\t\t\t\t (NO BRANCH)");
|
||||
Log.print(baseDisplay + volatileString + "\r\t\t\t\t\t\t\t (NO BRANCH)");
|
||||
} else {
|
||||
Log.print(base_display + volatileString + "\r\t\t\t\t\t\t\t " + select_branch);
|
||||
Log.print(baseDisplay + volatileString + "\r\t\t\t\t\t\t\t " + select_branch);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
tracking_remote_branch = select_branch.substring(StatusActions.base_name_of_a_tagged_branch.length());
|
||||
tracking_remote_branch = select_branch.substring(StatusActions.baseNameOfATaggedBranch.length());
|
||||
}
|
||||
String modify_status = " ";
|
||||
if (is_modify == true) {
|
||||
@ -175,7 +175,7 @@ public class StatusActions {
|
||||
|
||||
String tags_comment = "";
|
||||
// check the current tags of the repository
|
||||
if (argument_display_tag) {
|
||||
if (argumentDisplayTag) {
|
||||
List<String> ret_current_tags = Commands.getTagsCurrent(git);
|
||||
Log.verbose("tags found: " + ret_current_tags);
|
||||
for (String elem_tag : ret_current_tags) {
|
||||
@ -190,19 +190,19 @@ public class StatusActions {
|
||||
tags_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t- - - - -";
|
||||
}
|
||||
}
|
||||
Log.print(base_display + volatileString + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + tracking_remote_branch + ")" + behind_forward_comment + tags_comment);
|
||||
Log.print(baseDisplay + volatileString + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + tracking_remote_branch + ")" + behind_forward_comment + tags_comment);
|
||||
Commands.getDiff(git);
|
||||
return deltas.behind();
|
||||
}
|
||||
|
||||
public static boolean deliverCheck(final ProjectConfig elem, final String argument_remote_name, final int id_element, final String base_display, final String source_branch, final String destination_branch) throws GitAPIException, IOException {
|
||||
public static boolean deliverCheck(final ProjectConfig elem, final String argumentRemoteName, final int idElement, final String baseDisplay, final String sourceBranch, final String destinationBranch) throws GitAPIException, IOException {
|
||||
boolean deliver_availlable = true;
|
||||
Log.debug("deliver-ckeck: " + base_display);
|
||||
Log.debug("deliver-ckeck: " + baseDisplay);
|
||||
Log.debug(" ==> check repo exist");
|
||||
// Check the repo exist
|
||||
Path git_repo_path = Env.get_island_root_path().resolve(elem.getPath());
|
||||
Path git_repo_path = Env.getIslandRootPath().resolve(elem.getPath());
|
||||
if (!Files.exists(git_repo_path)) {
|
||||
Log.warning("deliver-ckeck: " + base_display + " ==> MUST be download");
|
||||
Log.warning("deliver-ckeck: " + baseDisplay + " ==> MUST be download");
|
||||
return false;
|
||||
}
|
||||
Log.debug(" ==> check is modify");
|
||||
@ -210,44 +210,44 @@ public class StatusActions {
|
||||
Git git = Git.open(git_repo_path.toFile());
|
||||
boolean is_modify = git.status().call().hasUncommittedChanges();
|
||||
if (is_modify) {
|
||||
Log.warning("deliver-ckeck: " + base_display + " ==> MUST not be modify");
|
||||
Log.warning("deliver-ckeck: " + baseDisplay + " ==> MUST not be modify");
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.debug(" ==> check current branch is '" + source_branch + "'");
|
||||
Log.debug(" ==> check current branch is '" + sourceBranch + "'");
|
||||
// check if we are on source_branch
|
||||
String select_branch = git.getRepository().getBranch();
|
||||
if (!select_branch.equals(source_branch)) {
|
||||
Log.warning("deliver-ckeck: " + base_display + " ==> MUST be on source branch: '" + source_branch + "' and is: '" + select_branch + "'");
|
||||
if (!select_branch.equals(sourceBranch)) {
|
||||
Log.warning("deliver-ckeck: " + baseDisplay + " ==> MUST be on source branch: '" + sourceBranch + "' and is: '" + select_branch + "'");
|
||||
return false;
|
||||
}
|
||||
Log.debug(" ==> check have tracking branch");
|
||||
// check if we have a remote traking branch
|
||||
String tracking_remote_branch = Commands.getTrackingBranch(git, argument_remote_name, select_branch);
|
||||
String tracking_remote_branch = Commands.getTrackingBranch(git, argumentRemoteName, select_branch);
|
||||
if (tracking_remote_branch == null) {
|
||||
Log.warning("deliver-ckeck: " + base_display + " ==> MUST have a remote tracking branch");
|
||||
Log.warning("deliver-ckeck: " + baseDisplay + " ==> MUST have a remote tracking branch");
|
||||
deliver_availlable = false;
|
||||
}
|
||||
|
||||
// go on destination branch
|
||||
Commands.checkout(git, destination_branch);
|
||||
Log.debug(" ==> check current branch is '" + source_branch + "'");
|
||||
Commands.checkout(git, destinationBranch);
|
||||
Log.debug(" ==> check current branch is '" + sourceBranch + "'");
|
||||
// check if we are on "master"
|
||||
select_branch = git.getRepository().getBranch();
|
||||
if (select_branch != destination_branch) {
|
||||
Log.warning("deliver-ckeck: " + base_display + " ==> Can not checkout branch: '" + destination_branch + "' and is: '" + select_branch + "'");
|
||||
if (select_branch != destinationBranch) {
|
||||
Log.warning("deliver-ckeck: " + baseDisplay + " ==> Can not checkout branch: '" + destinationBranch + "' and is: '" + select_branch + "'");
|
||||
deliver_availlable = false;
|
||||
}
|
||||
Log.debug(" ==> check have tracking branch");
|
||||
// check if we have a remote traking branch
|
||||
tracking_remote_branch = Commands.getTrackingBranch(git, argument_remote_name, select_branch);
|
||||
tracking_remote_branch = Commands.getTrackingBranch(git, argumentRemoteName, select_branch);
|
||||
if (tracking_remote_branch == null) {
|
||||
Log.warning("deliver-ckeck: " + base_display + " ==> MUST have a remote tracking branch");
|
||||
Log.warning("deliver-ckeck: " + baseDisplay + " ==> MUST have a remote tracking branch");
|
||||
deliver_availlable = false;
|
||||
}
|
||||
|
||||
// check out back the source branch
|
||||
Commands.checkout(git, source_branch);
|
||||
Commands.checkout(git, sourceBranch);
|
||||
return deliver_availlable;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import org.atriasoft.island.Config;
|
||||
import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
|
||||
@ArgCommand("volatile-add")
|
||||
@ArgDescription("Add a 'volatile' repository with a local path (this element is update as an element in the manifest but is not managed by the manifest)")
|
||||
|
@ -10,8 +10,8 @@ import org.atriasoft.island.Config;
|
||||
import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.Volatile;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
|
||||
@ArgCommand("volatile-list")
|
||||
@ArgDescription("List all volatiles elements")
|
||||
@ -34,7 +34,7 @@ public class VolatileList {
|
||||
Log.print("\t==> No repository");
|
||||
} else {
|
||||
for (Volatile elem : volatiles) {
|
||||
Log.print("\t" + elem.getPath() + "\r\t\t\t\t" + elem.getGitAddress());
|
||||
Log.print("\t" + elem.getPath() + "\r\t\t\t\t" + elem.getAddress());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import org.atriasoft.island.Config;
|
||||
import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
|
||||
@ArgCommand("volatile-rm")
|
||||
@ArgDescription("Remove a 'volatile' repository with a local path")
|
||||
|
@ -5,27 +5,24 @@ import org.atriasoft.exml.annotation.XmlName;
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class Volatile {
|
||||
private String gitAddress;
|
||||
private String address;
|
||||
private String path;
|
||||
|
||||
@XmlName({"address", "path"})
|
||||
public Volatile(final String gitAddress, final String path) {
|
||||
this.gitAddress = gitAddress;
|
||||
this.address = gitAddress;
|
||||
this.path = path;
|
||||
}
|
||||
@XmlName("address")
|
||||
public String getGitAddress() {
|
||||
return this.gitAddress;
|
||||
public String getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
public void setGitAddress(final String gitAddress) {
|
||||
this.gitAddress = gitAddress;
|
||||
public void setAddress(final String gitAddress) {
|
||||
this.address = gitAddress;
|
||||
}
|
||||
@XmlName("path")
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
public void setPath(final String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
58
src/org/atriasoft/island/model/manifest/Artifactory.java
Normal file
58
src/org/atriasoft/island/model/manifest/Artifactory.java
Normal file
@ -0,0 +1,58 @@
|
||||
package org.atriasoft.island.model.manifest;
|
||||
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class Artifactory {
|
||||
private String name; // Local name of the remote.
|
||||
private String fetch; // Address to fetch.
|
||||
private String type; // type of artifactory (default maven to update later ...)
|
||||
|
||||
@XmlName({"name", "fetch", "type"})
|
||||
public Artifactory(final String name, final String fetch, final String type) {
|
||||
this.name = name;
|
||||
this.fetch = fetch;
|
||||
this.type = type;
|
||||
}
|
||||
@XmlName({"name", "fetch"})
|
||||
public Artifactory(final String name, final String fetch) {
|
||||
this.name = name;
|
||||
this.fetch = fetch;
|
||||
this.type = "maven";
|
||||
}
|
||||
public Artifactory() {
|
||||
this.name = "";
|
||||
this.fetch = "";
|
||||
this.type = "maven";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getFetch() {
|
||||
return this.fetch;
|
||||
}
|
||||
public void setFetch(final String fetch) {
|
||||
this.fetch = fetch;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
public void setType(final String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Artifactory clone() {
|
||||
// TODO Auto-generated method stub
|
||||
return new Artifactory(this.name, this.fetch, this.type);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.atriasoft.island.model;
|
||||
package org.atriasoft.island.model.manifest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
@ -13,6 +13,7 @@ import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||
import org.atriasoft.exml.exception.ExmlException;
|
||||
import org.atriasoft.island.Env;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.Volatile;
|
||||
public class ConfigManifest {
|
||||
|
||||
private String repo = "";
|
||||
@ -95,7 +96,7 @@ public class ConfigManifest {
|
||||
}
|
||||
|
||||
public static ConfigManifest load() {
|
||||
return ConfigManifest.load(Env.get_island_path_config());
|
||||
return ConfigManifest.load(Env.getIslandPathConfig());
|
||||
}
|
||||
public static ConfigManifest load(final Path path) {
|
||||
ConfigManifest[] root = null;
|
||||
@ -115,7 +116,7 @@ public class ConfigManifest {
|
||||
}
|
||||
public void store() {
|
||||
try {
|
||||
store(Env.get_island_path_config());
|
||||
store(Env.getIslandPathConfig());
|
||||
} catch (ExmlBuilderException e) {
|
||||
Log.error("Can not store the configuration ... ");
|
||||
e.printStackTrace();
|
30
src/org/atriasoft/island/model/manifest/Dependency.java
Normal file
30
src/org/atriasoft/island/model/manifest/Dependency.java
Normal file
@ -0,0 +1,30 @@
|
||||
package org.atriasoft.island.model.manifest;
|
||||
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
import org.atriasoft.exml.annotation.XmlOptional;
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public record Dependency (
|
||||
String org,
|
||||
String name,
|
||||
@XmlOptional String revision,
|
||||
@XmlOptional String remote) { // TODO this is a big mistake for xml , can not parse multiple type... use @XmlOptionnal(nullDefaultValue=true)
|
||||
|
||||
@XmlName({"org", "name", "rev", "remote"})
|
||||
public Dependency(final String org, final String name, final String revision, final String remote) {
|
||||
this.org = org;
|
||||
this.name = name;
|
||||
this.revision = revision;
|
||||
this.remote = remote==null?"default":remote;
|
||||
}
|
||||
@XmlName({"org", "name", "rev"})
|
||||
public Dependency(final String org, final String name, final String revision) {
|
||||
this(org, name, revision, null);
|
||||
}
|
||||
|
||||
@XmlName({"org", "name"})
|
||||
public Dependency(final String org, final String name) {
|
||||
this(org, name, null, null);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.atriasoft.island.model;
|
||||
package org.atriasoft.island.model.manifest;
|
||||
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
|
@ -7,16 +7,14 @@ import java.util.List;
|
||||
import org.atriasoft.exml.annotation.XmlList;
|
||||
import org.atriasoft.exml.annotation.XmlManaged;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
import org.atriasoft.island.model.Link;
|
||||
import org.atriasoft.island.model.ProjectConfig;
|
||||
import org.atriasoft.island.model.RemoteConfig;
|
||||
|
||||
public class ManifestFile {
|
||||
private Path fileRealPath = null;
|
||||
private List<ProjectConfig> projects = new ArrayList<>();
|
||||
private List<RemoteConfig> remotes = new ArrayList<>();
|
||||
private List<Artifactory> artefactories = new ArrayList<>();
|
||||
private List<String> includes = new ArrayList<>();
|
||||
private List<MavenDependency> mavenDependency = new ArrayList<>();
|
||||
private List<Dependency> dependencies = new ArrayList<>();
|
||||
private OptionRepository options = null;
|
||||
private List<Link> links = new ArrayList<>();
|
||||
|
||||
@ -44,13 +42,13 @@ public class ManifestFile {
|
||||
this.includes = includes;
|
||||
}
|
||||
|
||||
@XmlName(value="maven")
|
||||
@XmlName(value="dependencies")
|
||||
@XmlList(value="dependency")
|
||||
public List<MavenDependency> getMavenDependency() {
|
||||
return this.mavenDependency;
|
||||
public List<Dependency> getDependencies() {
|
||||
return this.dependencies;
|
||||
}
|
||||
public void setMavenDependency(final List<MavenDependency> mavenDependency) {
|
||||
this.mavenDependency = mavenDependency;
|
||||
public void setDependencies(final List<Dependency> dependency) {
|
||||
this.dependencies = dependency;
|
||||
}
|
||||
|
||||
public OptionRepository getOptions() {
|
||||
@ -76,4 +74,12 @@ public class ManifestFile {
|
||||
this.fileRealPath = fileRealPath;
|
||||
}
|
||||
|
||||
@XmlName("artefactory")
|
||||
public List<Artifactory> getArtefactories() {
|
||||
return this.artefactories;
|
||||
}
|
||||
public void setArtefactories(final List<Artifactory> artefacts) {
|
||||
this.artefactories = artefacts;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
package org.atriasoft.island.model.manifest;
|
||||
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class MavenDependency {
|
||||
private String org = null;
|
||||
private String name = null;
|
||||
private String revision = null;
|
||||
|
||||
public String getOrg() {
|
||||
return this.org;
|
||||
}
|
||||
public void setOrg(final String org) {
|
||||
this.org = org;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlName(value="rev")
|
||||
public String getRevision() {
|
||||
return this.revision;
|
||||
}
|
||||
public void setRevision(final String revision) {
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.atriasoft.island.model;
|
||||
package org.atriasoft.island.model.manifest;
|
||||
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
@ -13,17 +13,12 @@ public class MirrorConfig {
|
||||
this.name = name;
|
||||
this.fetch = fetch;
|
||||
}
|
||||
|
||||
@XmlName("name")
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@XmlName("fetch")
|
||||
public String getFetch() {
|
||||
return this.fetch;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.atriasoft.island.model;
|
||||
package org.atriasoft.island.model.manifest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -1,12 +1,14 @@
|
||||
package org.atriasoft.island.model;
|
||||
package org.atriasoft.island.model.manifest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.annotation.XmlAttribute;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
import org.atriasoft.exml.annotation.XmlOptional;
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class RemoteConfig {
|
||||
private String name; // Local name of the remote.
|
||||
private String fetch; // Address to fetch.
|
||||
@ -25,7 +27,6 @@ public class RemoteConfig {
|
||||
this.mirror = new ArrayList<>();
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
@ -33,14 +34,14 @@ public class RemoteConfig {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public String getFetch() {
|
||||
return this.fetch;
|
||||
}
|
||||
public void setFetch(final String fetch) {
|
||||
this.fetch = fetch;
|
||||
}
|
||||
|
||||
|
||||
@XmlAttribute(false)
|
||||
public List<MirrorConfig> getMirror() {
|
||||
return this.mirror;
|
||||
}
|
||||
@ -54,7 +55,6 @@ public class RemoteConfig {
|
||||
}
|
||||
|
||||
@XmlOptional
|
||||
@XmlName("sync")
|
||||
public boolean isSync() {
|
||||
return this.sync;
|
||||
}
|
12
src/org/atriasoft/island/model/maven/MavenMetadata.java
Normal file
12
src/org/atriasoft/island/model/maven/MavenMetadata.java
Normal file
@ -0,0 +1,12 @@
|
||||
package org.atriasoft.island.model.maven;
|
||||
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
|
||||
@XmlDefaultAttibute(false)
|
||||
public record MavenMetadata(
|
||||
@XmlName("groupId") String groupId,
|
||||
@XmlName("artifactId") String artifactId,
|
||||
@XmlName("versioning") Versioning versioning) {
|
||||
|
||||
}
|
14
src/org/atriasoft/island/model/maven/Versioning.java
Normal file
14
src/org/atriasoft/island/model/maven/Versioning.java
Normal file
@ -0,0 +1,14 @@
|
||||
package org.atriasoft.island.model.maven;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.annotation.XmlList;
|
||||
import org.atriasoft.exml.annotation.XmlName;
|
||||
|
||||
public record Versioning(
|
||||
@XmlName("latest") String latest,
|
||||
@XmlName("release") String release,
|
||||
@XmlName("lastUpdated") String lastUpdated,
|
||||
@XmlName("versions") @XmlList(value="version") List<String> versions) {
|
||||
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
//!/usr/bin/python
|
||||
// -*- coding: utf-8 -*-
|
||||
//#
|
||||
//# @author Edouard DUPIN
|
||||
//#
|
||||
//# @copyright 2012, Edouard DUPIN, all right reserved
|
||||
//#
|
||||
//# @license MPL v2.0 (see license file)
|
||||
//#
|
||||
|
||||
from realog import Log
|
||||
from island import tools
|
||||
from island import env
|
||||
from island import multiprocess
|
||||
from island import config
|
||||
from island import manifest
|
||||
from island import commands
|
||||
import status
|
||||
import os
|
||||
|
||||
|
||||
//#
|
||||
//# @brief Get the global description of the current action
|
||||
//# @return (string) the description string (fist line if reserved for the overview, all is for the specific display)
|
||||
//#
|
||||
public void help():
|
||||
return "Deliver the current repository (develop & master MUST be up to date and you MUST be on master)"
|
||||
|
||||
//#
|
||||
//# @brief Add argument to the specific action
|
||||
//# @param[in,out] my_args (death.Arguments) Argument manager
|
||||
//# @param[in] section Name of the currect action
|
||||
//#
|
||||
public void add_specific_arguments(_my_args, _section):
|
||||
_my_args.add("f", "from", haveParam=true, desc="source branche to deliver")
|
||||
_my_args.add("t", "to", haveParam=true, desc="desticantion branche of the deliver")
|
||||
|
||||
//#
|
||||
//# @brief Execute the action required.
|
||||
//#
|
||||
//# @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
|
||||
//# None : No error (return program out 0)
|
||||
//# -10 : ACTION is not existing
|
||||
//# -11 : ACTION execution system error
|
||||
//# -12 : ACTION Wrong parameters
|
||||
//#
|
||||
public void execute(_arguments):
|
||||
argument_from = None
|
||||
argument_to = None
|
||||
for elem in _arguments:
|
||||
if elem.getOptionName().equals("from":
|
||||
Log.info("find source branch name: '" + elem.getArg() + "'")
|
||||
argument_from = elem.getArg()
|
||||
} else if elem.getOptionName().equals("to":
|
||||
Log.info("find destination branch name: '" + elem.getArg() + "'")
|
||||
argument_to = elem.getArg()
|
||||
else:
|
||||
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'")
|
||||
|
||||
// check system is OK
|
||||
Manifest.checkIsInit();
|
||||
|
||||
ConfigManifest configuration = Config.getUniqueConfig();
|
||||
|
||||
file_source_manifest = new Path(Env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == false:
|
||||
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
destination_branch = mani.deliver_master
|
||||
source_branch = mani.deliver_develop
|
||||
if argument_from != None:
|
||||
source_branch = argument_from
|
||||
if argument_to != None:
|
||||
destination_branch = argument_to
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
Log.info("Check if all project are on master: " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
deliver_availlable = true
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
Log.verbose("deliver-ckeck: " + base_display)
|
||||
if status.deliver_check(elem, argument_remote_name, id_element, base_display, source_branch, destination_branch) == false:
|
||||
deliver_availlable = false
|
||||
if deliver_availlable == false:
|
||||
Log.error("deliver-ckeck: Correct the warning to validate the Merge")
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Log.info("deliver-ckeck: ==> All is OK")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
Log.info("deliver: ========================================================================")
|
||||
Log.info("deliver:.equals(" + base_display)
|
||||
Log.info("deliver: ========================================================================")
|
||||
git_repo_path = new Path(Env.get_island_root_path(), elem.path)// Check the validity of the version,
|
||||
version_description, add_in_version_management = status.get_current_version_repo(git_repo_path)
|
||||
if version_description == None:
|
||||
continue
|
||||
Log.info("deliver: ==> version: " + str(version_description))
|
||||
|
||||
// go to the dev branch
|
||||
select_branch = commands.get_current_branch(git_repo_path)
|
||||
|
||||
// Checkout destination branch:
|
||||
commands.checkout(git_repo_path, destination_branch)
|
||||
|
||||
// create new repo tag
|
||||
new_version_description = status.create_new_version_repo(git_repo_path, version_description, add_in_version_management, source_branch, destination_branch)
|
||||
Log.info("new version: " + str(new_version_description))
|
||||
if new_version_description == None:
|
||||
continue
|
||||
// merge branch
|
||||
if mani.deliver_mode.equals("merge":
|
||||
merge_force = true
|
||||
else:
|
||||
merge_force = false
|
||||
commands.merge_branch_on_master(git_repo_pat source_branch, merge_force, branch_destination=destination_branch)
|
||||
|
||||
version_path_file = new Path(git_repo_path, "version.txt")
|
||||
// update version file:
|
||||
tools.file_write_data(version_path_file, tools.version_to_string(new_version_description))
|
||||
commands.add_file(git_repo_path, version_path_file)
|
||||
commands.commit_all(git_repo_path, "[RELEASE] Release v" + tools.version_to_string(new_version_description))
|
||||
commands.tag(git_repo_path, "v" + tools.version_to_string(new_version_description))
|
||||
commands.checkout(git_repo_path, source_branch)
|
||||
commands.reset_hard(git_repo_path, destination_branch)
|
||||
new_version_description.append("dev")
|
||||
tools.file_write_data(version_path_file, tools.version_to_string(new_version_description))
|
||||
commands.add_file(git_repo_path, version_path_file)
|
||||
commands.commit_all(git_repo_path, status.default_update_message)
|
||||
commands.checkout(git_repo_path, destination_branch)
|
||||
|
Loading…
x
Reference in New Issue
Block a user