[DEV] continue rework

This commit is contained in:
Edouard DUPIN 2021-06-18 18:32:16 +02:00
parent 1bb1c4638e
commit 5a05e0eb77
6 changed files with 517 additions and 310 deletions

View File

@ -11,14 +11,8 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View File

@ -13,15 +13,15 @@ import org.atriasoft.island.model.ActionInterface;
public class Actions { public class Actions {
private static Map<String, Class<ActionInterface>> actions = new HashMap<String,Class<ActionInterface>>(); private static Map<String, Class<ActionInterface>> actions = new HashMap<String,Class<ActionInterface>>();
public static void addAction(String name, Class<ActionInterface> klass) { public static void addAction(final String name, final Class<ActionInterface> klass) {
actions.put(name, klass); Actions.actions.put(name, klass);
} }
/** /**
* Get the wall list of action availlable * Get the wall list of action availlable
* @return The list of action name * @return The list of action name
*/ */
public static Set<String> getListOfAction() { public static Set<String> getListOfAction() {
return actions.keySet(); return Actions.actions.keySet();
} }
@ -51,8 +51,8 @@ public class Actions {
* @return The first line of description * @return The first line of description
* @throws ActionException * @throws ActionException
*/ */
private String getFullActionHelp(String action_name) throws ActionException { private String getFullActionHelp(final String action_name) throws ActionException {
Class<ActionInterface> actionClass = actions.get(action_name); Class<ActionInterface> actionClass = Actions.actions.get(action_name);
if (actionClass == null) { if (actionClass == null) {
throw new ActionException("Action does not registered"); throw new ActionException("Action does not registered");
} }
@ -68,8 +68,8 @@ public class Actions {
return action.help(); return action.help();
} }
private String getActionHelpExample(String action_name) throws ActionException { private String getActionHelpExample(final String action_name) throws ActionException {
Class<ActionInterface> actionClass = actions.get(action_name); Class<ActionInterface> actionClass = Actions.actions.get(action_name);
if (actionClass == null) { if (actionClass == null) {
throw new ActionException("Action does not registered"); throw new ActionException("Action does not registered");
} }
@ -91,11 +91,11 @@ public class Actions {
* @return The first line of description * @return The first line of description
* @throws ActionException * @throws ActionException
*/ */
public String getActionHelp(String action_name) throws ActionException { public String getActionHelp(final String action_name) throws ActionException {
return getFullActionHelp(action_name).split("\n")[0]; return getFullActionHelp(action_name).split("\n")[0];
} }
public void usage(String action_name, Arguments arguments) throws ActionException { public void usage(final String action_name, final Arguments arguments) throws ActionException {
String help = getFullActionHelp(action_name); String help = getFullActionHelp(action_name);
Log.print("Description:"); Log.print("Description:");
Log.print("\t" + help); Log.print("\t" + help);
@ -110,8 +110,8 @@ public class Actions {
System.exit(0); System.exit(0);
} }
public void execute(String action_name, List<String> arguments) throws ActionException { public void execute(final String action_name, final List<String> arguments) throws ActionException {
Class<ActionInterface> actionClass = actions.get(action_name); Class<ActionInterface> actionClass = Actions.actions.get(action_name);
if (actionClass == null) { if (actionClass == null) {
throw new ActionException("Action does not registered"); throw new ActionException("Action does not registered");
} }

View File

@ -17,7 +17,7 @@ import java.nio.file.Paths;
import org.atriasoft.island.internal.Log; import org.atriasoft.island.internal.Log;
public class Env { public class Env {
private Env() {}
public static final int ret_manifest_is_not_existing = -5; 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_is_not_existing = -10;
public static final int ret_action_executing_system_error = -11; public static final int ret_action_executing_system_error = -11;
@ -29,51 +29,51 @@ public class Env {
public static String system_base_name = "island"; public static String system_base_name = "island";
public static void set_system_base_name(String val) { public static void set_system_base_name(final String val) {
system_base_name = val; Env.system_base_name = val;
} }
public static String get_system_base_name() { public static String get_system_base_name() {
return system_base_name; return Env.system_base_name;
} }
public static String get_system_config_name() { public static String get_system_config_name() {
return "." + system_base_name + "Config.json"; return "." + Env.system_base_name + "Config.json";
} }
private static boolean fetch_manifest = true; private static boolean fetch_manifest = true;
public static void set_fetch_manifest(boolean val) { public static void set_fetch_manifest(final boolean val) {
fetch_manifest = val; Env.fetch_manifest = val;
} }
public static boolean get_fetch_manifest() { public static boolean get_fetch_manifest() {
return fetch_manifest; return Env.fetch_manifest;
} }
private static int wait_between_sever_command = 0; private static int wait_between_sever_command = 0;
public static void set_wait_between_sever_command(int val) { public static void set_wait_between_sever_command(final int val) {
wait_between_sever_command = val; Env.wait_between_sever_command = val;
} }
public static int get_wait_between_sever_command() { public static int get_wait_between_sever_command() {
return wait_between_sever_command; return Env.wait_between_sever_command;
} }
public static String filter_command = ""; public static String filter_command = "";
public static void set_filter_command(String val) { public static void set_filter_command(final String val) {
filter_command = val; Env.filter_command = val;
} }
public static String get_filter_command() { public static String get_filter_command() {
return filter_command; return Env.filter_command;
} }
public static boolean need_process_with_filter(String data) { public static boolean need_process_with_filter(final String data) {
if (filter_command.equals("")) { if (Env.filter_command.equals("")) {
return true; return true;
} }
if (data.length() < filter_command.length()) { if (data.length() < Env.filter_command.length()) {
return false; return false;
} }
if (data.substring(0,filter_command.length()).equals(filter_command)) { if (data.substring(0,Env.filter_command.length()).equals(Env.filter_command)) {
return true; return true;
} }
return false; return false;
@ -81,11 +81,11 @@ public class Env {
private static boolean display_folder_instead_of_git_name = true; private static boolean display_folder_instead_of_git_name = true;
public static void set_display_folder_instead_of_git_name(boolean val) { public static void set_display_folder_instead_of_git_name(final boolean val) {
display_folder_instead_of_git_name = val; Env.display_folder_instead_of_git_name = val;
} }
public static boolean get_display_folder_instead_of_git_name() { public static boolean get_display_folder_instead_of_git_name() {
return display_folder_instead_of_git_name; return Env.display_folder_instead_of_git_name;
} }
private static Path island_root_path = null; private static Path island_root_path = null;
@ -98,47 +98,47 @@ public class Env {
static { static {
//String tmp = island_root_path.toAbsolutePath().toString(); //String tmp = island_root_path.toAbsolutePath().toString();
//Log.info("Current absolute path is: " + tmp); //Log.info("Current absolute path is: " + tmp);
island_root_path = Paths.get(""); Env.island_root_path = Paths.get("");
Path tmpPath = island_root_path; Path tmpPath = Env.island_root_path;
while (!Files.isDirectory(tmpPath.resolve("." + get_system_base_name()))) { while (!Files.isDirectory(tmpPath.resolve("." + Env.get_system_base_name()))) {
tmpPath = tmpPath.getParent(); tmpPath = tmpPath.getParent();
if (tmpPath == null) { if (tmpPath == null) {
Log.critical("the root path of " + get_system_base_name() + " must not be upper parent paths of (" + island_root_path.toAbsolutePath() + ")"); Log.critical("the root path of " + Env.get_system_base_name() + " must not be upper parent paths of (" + Env.island_root_path.toAbsolutePath() + ")");
} }
} }
island_root_path = tmpPath; Env.island_root_path = tmpPath;
island_path_user_config = island_root_path.resolve(get_system_config_name()); Env.island_path_user_config = Env.island_root_path.resolve(Env.get_system_config_name());
island_path = island_root_path.resolve("." + get_system_base_name()); Env.island_path = Env.island_root_path.resolve("." + Env.get_system_base_name());
island_path_config = island_path.resolve("config.xml"); Env.island_path_config = Env.island_path.resolve("config.xml");
island_path_manifest = island_path.resolve("manifest"); Env.island_path_manifest = Env.island_path.resolve("manifest");
} }
/** /**
* To use later to know where the ".island" parent path is ... * To use later to know where the ".island" parent path is ...
* @return the parent path of the ".island" * @return the parent path of the ".island"
*/ */
public static Path get_island_root_path() { public static Path get_island_root_path() {
return island_root_path; return Env.island_root_path;
} }
public static Path get_island_path() { public static Path get_island_path() {
return island_path; return Env.island_path;
} }
public static Path get_island_path_config() { public static Path get_island_path_config() {
return island_path_config; return Env.island_path_config;
} }
public static Path get_island_path_manifest() { public static Path get_island_path_manifest() {
return island_path_manifest; return Env.island_path_manifest;
} }
public static Path get_island_path_user_config() { public static Path get_island_path_user_config() {
return island_path_user_config; return Env.island_path_user_config;
} }
public static void main(String[] args) { public static void main(final String[] args) {
Log.error("island_root_path = " + island_root_path.toAbsolutePath()); Log.error("island_root_path = " + Env.island_root_path.toAbsolutePath());
Log.error("island_path_user_config = " + island_path_user_config.toAbsolutePath()); Log.error("island_path_user_config = " + Env.island_path_user_config.toAbsolutePath());
Log.error("island_path = " + island_path.toAbsolutePath()); Log.error("island_path = " + Env.island_path.toAbsolutePath());
Log.error("island_path_config = " + island_path_config.toAbsolutePath()); Log.error("island_path_config = " + Env.island_path_config.toAbsolutePath());
Log.error("island_path_manifest = " + island_path_manifest.toAbsolutePath()); Log.error("island_path_manifest = " + Env.island_path_manifest.toAbsolutePath());
} }

View File

@ -1,33 +1,198 @@
package org.atriasoft.island; package org.atriasoft.island;
import java.io.File; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.atriasoft.exml.Exml; import org.atriasoft.exml.Exml;
import org.atriasoft.exml.exception.ExmlBuilderException;
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
import org.atriasoft.exml.model.XmlAttribute; import org.atriasoft.exml.model.XmlAttribute;
import org.atriasoft.exml.model.XmlElement; import org.atriasoft.exml.model.XmlElement;
import org.atriasoft.exml.model.XmlNode; import org.atriasoft.exml.model.XmlNode;
import org.atriasoft.exml.model.XmlNodeType; import org.atriasoft.exml.model.XmlNodeType;
import org.atriasoft.exml.parser.ParseXml;
import org.atriasoft.island.internal.Log; import org.atriasoft.island.internal.Log;
import org.atriasoft.island.model.Link;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.RemoteListCommand; import org.eclipse.jgit.api.RemoteListCommand;
class RepositoryCongig { class RepositoryCongig {
String remote = "origin"; private String remote = "origin";
String revision = "master"; private String revision = "master";
boolean sync = false; private boolean sync = false;
public RepositoryCongig(final String remote, final String revision, final boolean sync) {
this.remote = remote;
this.revision = revision;
this.sync = sync;
}
public RepositoryCongig() {
}
public String getRemote() {
return this.remote;
}
public void setRemote(final String remote) {
this.remote = remote;
}
public String getRevision() {
return this.revision;
}
public void setRevision(final String revision) {
this.revision = revision;
}
public boolean isSync() {
return this.sync;
}
public void setSync(final boolean sync) {
this.sync = sync;
}
@Override
protected RepositoryCongig clone() {
// TODO Auto-generated method stub
return new RepositoryCongig(this.remote, this.revision, this.sync);
}
} }
record MirrorConfig(String name, String fetch) { class MirrorConfig {
private String name;
private String fetch;
public MirrorConfig(final String name, final String fetch) {
this.name = name;
this.fetch = fetch;
}
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;
}
} }
record RemoteConfig(String name, String fetch, List<MirrorConfig> mirror) { class RemoteConfig {
private String name;
private String fetch;
List<MirrorConfig> mirror;
public RemoteConfig(final String name, final String fetch, final List<MirrorConfig> mirror) {
this.name = name;
this.fetch = fetch;
this.mirror = mirror;
}
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 List<MirrorConfig> getMirror() {
return this.mirror;
}
public void setMirror(final List<MirrorConfig> mirror) {
this.mirror = mirror;
}
@Override
protected RemoteConfig clone() {
// TODO Auto-generated method stub
return new RemoteConfig(this.name, this.fetch, new ArrayList<>(this.mirror));
}
} }
record IncludeConfig(String name, String path, Object manifest) {
class IncludeConfig {
private String name;
private Path path;
private Manifest manifest;
public IncludeConfig(final String name, final Path path, final Manifest manifest) {
this.name = name;
this.path = path;
this.manifest = manifest;
}
public String getName() {
return this.name;
}
public void setName(final String name) {
this.name = name;
}
public Path getPath() {
return this.path;
}
public void setPath(final Path path) {
this.path = path;
}
public Manifest getManifest() {
return this.manifest;
}
public void setManifest(final Manifest manifest) {
this.manifest = manifest;
}
}
class ProjectConfig {
private String name;
private String path;
private String tag;
private List<RemoteConfig> remotes = new ArrayList<>();
RemoteConfig selectRemotes = null;
public ProjectConfig(final String name, final String path, final String tag) {
this.name = name;
this.path = path;
this.tag = tag;
}
public String getName() {
return this.name;
}
public void setName(final String name) {
this.name = name;
}
public String getPath() {
return this.path;
}
public void setPath(final String path) {
this.path = path;
}
public String getTag() {
return this.tag;
}
public void setTag(final String tag) {
this.tag = tag;
}
public void setBranch(final String tag) {
this.tag = tag;
}
public List<RemoteConfig> getRemotes() {
return this.remotes;
}
public void setRemotes(final List<RemoteConfig> remotes) {
this.remotes = remotes;
}
public RemoteConfig getSelectRemotes() {
return this.selectRemotes;
}
public void setSelectRemotes(final RemoteConfig selectRemotes) {
this.selectRemotes = selectRemotes;
}
} }
public class Manifest { public class Manifest {
@ -48,7 +213,7 @@ public class Manifest {
} }
public static void checkIsInit() { public static void checkIsInit() {
// check if .XXX exist (create it if needed) // check if .XXX exist (create it if needed)
if (!isInit()) { 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.get_island_path() + "'. Call <island init> first");
System.exit(-1); System.exit(-1);
} }
@ -57,34 +222,40 @@ public class Manifest {
private String deliver_master = "master"; private String deliver_master = "master";
private String deliver_develop = "develop"; private String deliver_develop = "develop";
private String deliver_mode = "merge"; private String deliver_mode = "merge";
private Path manifestXml; private final Path manifestXml;
List<Object> projects = new ArrayList<>(); List<ProjectConfig> projects = new ArrayList<>();
RepositoryCongig defaultWhat = null; RepositoryCongig defaultWhat = null;
RepositoryCongig default_base = new RepositoryCongig(); RepositoryCongig default_base = new RepositoryCongig();
List<RemoteConfig> remotes = new ArrayList<>(); List<RemoteConfig> remotes = new ArrayList<>();
List<IncludeConfig> includes = new ArrayList<>(); List<IncludeConfig> includes = new ArrayList<>();
List<Object> links = new ArrayList<>(); List<Link> links = new ArrayList<>();
public Manifest(Path manifest_xml) { public Manifest(final Path manifestXml) throws IOException {
manifestXml = manifest_xml; this.manifestXml = manifestXml;
// load the manifest // load the manifest
load(); try {
load();
} catch (ExmlBuilderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// check error in manifest (double path ...) // check error in manifest (double path ...)
// TODO checkDoublePath(); // TODO checkDoublePath();
} }
public List<Object> getLinks() { public List<Link> getLinks() {
return this.links; return this.links;
} }
String removeEndSlash(String value) { String removeEndSlash(String value) {
while (value.length() > 1 while (value.length() > 1
&& ( value.charAt(value.length()-1) == '\\' && ( value.charAt(value.length()-1) == '\\'
|| value.charAt(value.length()-1) == '/')) { || value.charAt(value.length()-1) == '/') ) {
value = value.substring(0, value.length()-1); value = value.substring(0, value.length()-1);
} }
return value; return value;
} }
public void load() {
public void load() throws ExmlParserErrorMulti, ExmlBuilderException, IOException {
XmlElement rootNode = Exml.parse(this.manifestXml); XmlElement rootNode = Exml.parse(this.manifestXml);
Log.debug("manifest : '" + this.manifestXml + "'"); Log.debug("manifest : '" + this.manifestXml + "'");
if (!rootNode.getValue().equals("manifest")) { if (!rootNode.getValue().equals("manifest")) {
@ -137,14 +308,14 @@ public class Manifest {
} }
fetch = removeEndSlash(fetch); fetch = removeEndSlash(fetch);
} else { } else {
Log.error("Parsing the manifest : Unknow '" + child.getName() + "' attibute : '" + attr.getName() + "', availlable:[name,fetch]") Log.error("Parsing the manifest : Unknow '" + child.getValue() + "' attibute : '" + attr.getName() + "', availlable:[name,fetch]");
} }
} }
Log.debug(" find '" + child.getName() + "' : name='" + name + "' fetch='" + fetch + "'"); Log.debug(" find '" + child.getValue() + "' : name='" + name + "' fetch='" + fetch + "'");
// parse the sub global mirror list // parse the sub global mirror list
List<MirrorConfig> mirror_list = new ArrayList<>(); List<MirrorConfig> mirror_list = new ArrayList<>();
for (XmlNode child_2 : child.toElement().getNodes()) { for (XmlNode child_2 : child.toElement().getNodes()) {
if (child_2.getValue().equals("mirror")): if (child_2.getValue().equals("mirror")) {
// find a new mirror // find a new mirror
String mirror_name = ""; String mirror_name = "";
String mirror_fetch = ""; String mirror_fetch = "";
@ -167,147 +338,156 @@ public class Manifest {
} }
mirror_list.add(new MirrorConfig(mirror_name, mirror_fetch)); mirror_list.add(new MirrorConfig(mirror_name, mirror_fetch));
} else { } else {
Log.critical("Parsing the manifest : Unknow '" + child_2.getName() + "', availlable:[mirror]"); Log.critical("Parsing the manifest : Unknow '" + child_2.getValue() + "', availlable:[mirror]");
} }
}
this.remotes.add(new RemoteConfig(name, fetch, mirror_list)); this.remotes.add(new RemoteConfig(name, fetch, mirror_list));
continue; continue;
} }
if (child.getName().equals("include") { if (child.getValue().equals("include")) {
String name = ""; String name = "";
for (XmlAttribute attr : child.toElement.getAttributes()) { for (XmlAttribute attr : child.toElement().getAttributes()) {
if (attr.getName().equals("name")) { if (attr.getName().equals("name")) {
name = attr.getValue(); name = attr.getValue();
} else { } else {
Log.error("Parsing the manifest : Unknow '" + child.getName() + "' attibute : '" + attr + "', availlable:[name]") Log.error("Parsing the manifest : Unknow '" + child.getValue() + "' attibute : '" + attr + "', availlable:[name]");
} }
} }
Log.debug(" find '" + child.getName() + "' : name='" + name + "'"); Log.debug(" find '" + child.getValue() + "' : name='" + name + "'");
// check if the file exist ... // check if the file exist ...
Path new_name_xml = this.manifest_xml.resolve(name); Path new_name_xml = this.manifestXml.resolve(name);
if (!Files.exists(new_name_xml)) { if (!Files.exists(new_name_xml)) {
Log.critical("The file does not exist: " + new_name_xml) Log.critical("The file does not exist: " + new_name_xml);
} }
this.includes.add(new IncludeConfig(name, new_name_xml, null)); this.includes.add(new IncludeConfig(name, new_name_xml, null));
continue; continue;
} }
if (child.getName().equals("default") { if (child.getValue().equals("default")) {
String remote = "origin"; String remote = "origin";
String revision = "master"; String revision = "master";
boolean sync = false; boolean sync = false;
for (XmlAttribute attr : child.toElement.getAttributes()) { for (XmlAttribute attr : child.toElement().getAttributes()) {
if (attr.getName().equals("remote")) { if (attr.getName().equals("remote")) {
remote = attr.getValue(); remote = attr.getValue();
} else if (attr.getName().equals("revision")) { } else if (attr.getName().equals("revision")) {
revision = attr.getValue(); revision = attr.getValue();
} else if (attr.getName().equals("sync-s")) { // synchronize submodule ... automaticaly } else if (attr.getName().equals("sync-s")) { // synchronize submodule ... automaticaly
sync = attr.getValue(); String syncBase = attr.getValue();
if (sync.lower().equals("true") if (syncBase.equalsIgnoreCase("true")
|| sync.equals("1") || syncBase.equals("1")
|| sync.lower().equals("yes")) { || syncBase.toLowerCase().equals("yes")) {
sync = true; sync = true;
} else if (sync.lower().equals("false") } else if (syncBase.equalsIgnoreCase("false")
|| sync.equals("0") || syncBase.equals("0")
|| sync.lower().equals("no")) { || syncBase.equalsIgnoreCase("no")) {
sync = false sync = false;
} else { } else {
Log.critical("Parsing the manifest : Unknow '" + child.getName() + "' attibute : '" + attr + "', value:'" + sync + "' availlable:[true,1,yes,false,0,no]"); Log.critical("Parsing the manifest : Unknow '" + child.getValue() + "' attibute : '" + attr + "', value:'" + sync + "' availlable:[true,1,yes,false,0,no]");
} }
} else { } else {
Log.error("Parsing the manifest : Unknow '" + child.getName() + "' attibute : '" + attr + "', availlable:[remote,revision,sync-s]"); Log.error("Parsing the manifest : Unknow '" + child.getValue() + "' attibute : '" + attr + "', availlable:[remote,revision,sync-s]");
} }
} }
if (this.defaultWhat != null) { if (this.defaultWhat != null) {
Log.error("Parsing the manifest : Node '" + child.getName() + "' already set") Log.error("Parsing the manifest : Node '" + child.getValue() + "' already set");
} }
this.defaultWhat = new RepositoryCongig(remote, revision, sync)); this.defaultWhat = new RepositoryCongig(remote, revision, sync);
Log.debug(" find '" + child.getName() + "' : remote='" + remote + "' revision='" + revision + "' sync=" + sync); Log.debug(" find '" + child.getValue() + "' : remote='" + remote + "' revision='" + revision + "' sync=" + sync);
continue; continue;
} }
if child.tag == "project": if (child.getValue().equals("project")) {
name = "" String name = "";
path = "" String path = "";
tag_sha1 = None String tag_sha1 = null;
for attr in child.attrib: for (XmlAttribute attr : child.toElement().getAttributes()) {
if attr == "name": if (attr.getName().equals("name")) {
name = child.attrib[attr] name = attr.getValue();
} else if attr == "path": } else if (attr.getName().equals("path")) {
path = child.attrib[attr] path = attr.getValue();
} else if attr == "tag": } else if (attr.getName().equals("tag")) {
tag_sha1 = child.attrib[attr] tag_sha1 = attr.getValue();
else: } else {
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,tag,sync-s]") Log.error("Parsing the manifest: Unknow '" + child.getValue() + "' attibute : '" + attr + "', availlable:[name,tag,sync-s]");
if name == "": }
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'name' ==> specify the git to clone ...") }
this.projects.append({ if (name.isEmpty()) {
"name":name, Log.error("Parsing the manifest: '" + child.getValue() + "' missing attribute: 'name' ==> specify the git to clone ...");
"path":path, }
"tag":tag_sha1, this.projects.add(new ProjectConfig(name, path, tag_sha1));
}) Log.debug(" find '" + child.getValue() + "' : name='" + name + "' path='" + path + "' tag='" + tag_sha1 + "'");
Log.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "' path='" + path + "' tag='" + str(tag_sha1) + "'"); continue;
continue }
if child.tag == "option": if (child.getValue().equals("option")) {
// not managed ==> future use // not managed ==> future use
type_option = "" String type_option = "";
value_option = "" String value_option = "";
for attr in child.attrib: for (XmlAttribute attr : child.toElement().getAttributes()) {
if attr == "type": if (attr.getName().equals("type")) {
type_option = child.attrib[attr] type_option = attr.getValue();
} else if attr == "value": } else if (attr.getName().equals("value")) {
value_option = child.attrib[attr] value_option = attr.getValue();
else: } else {
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[type,value]") Log.error("Parsing the manifest: Unknow '" + child.getValue() + "' attibute : '" + attr + "', availlable:[type,value]");
if type_option == "deliver_master": }
this.deliver_master = value_option }
} else if type_option == "deliver_develop": if (type_option.equals("deliver_master")) {
this.deliver_develop = value_option this.deliver_master = value_option;
} else if type_option == "deliver_mode": } else if (type_option.equals("deliver_develop")) {
this.deliver_mode = value_option this.deliver_develop = value_option;
if this.deliver_mode not in ["merge","fast_forward"]: } else if (type_option.equals("deliver_mode")) {
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: option 'deliver_mode' value availlable: [merge,fast_forward]") this.deliver_mode = value_option;
else: if (this.deliver_mode.equals("merge") || this.deliver_mode.equals("fast_forward")) {
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow 'type' value availlable: [deliver_master,deliver_develop,deliver_mode]") Log.critical("Parsing the manifest: option 'deliver_mode' value availlable: [merge,fast_forward]");
continue }
if child.tag == "link": } else {
Log.critical("Parsing the manifest: Unknow 'type' value availlable: [deliver_master,deliver_develop,deliver_mode]");
}
continue;
}
if (child.getValue().equals("link")) {
// not managed ==> future use // not managed ==> future use
source = "" String source = "";
destination = "" String destination = "";
for attr in child.attrib: for (XmlAttribute attr : child.toElement().getAttributes()) {
if attr == "source": if (attr.getName().equals("source")) {
source = child.attrib[attr] source = attr.getValue();
} else if attr == "destination": } else if (attr.getName().equals("destination")) {
destination = child.attrib[attr] destination = attr.getValue();
else: } else {
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[source,destination]") Log.critical("Parsing the manifest: Unknow '" + child.getValue() + "' attibute : '" + attr + "', availlable:[source,destination]");
if source == "": }
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'source' ==> specify the git to clone ...") }
if destination == "": if (source.isEmpty()) {
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'destination' ==> specify the git to clone ...") Log.error("Parsing the manifest: '" + child.getValue() + "' missing attribute: 'source' ==> specify the git to clone ...");
this.links.append({ }
"source":source, if (destination.isEmpty()) {
"destination":destination, Log.error("Parsing the manifest: '" + child.getValue() + "' missing attribute: 'destination' ==> specify the git to clone ...");
}) }
Log.debug("Add link: '" + str(destination) + "' ==> '" + str(source) + "'") this.links.add(new Link(source, destination));
continue Log.debug("Add link: '" + destination + "' ==> '" + source + "'");
Log.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib)); continue;
Log.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]") }
Log.info(" '" + child.getValue() + "' values=" + child.toElement().getAttributes());
Log.error("Parsing error Unknow NODE : '" + child.getValue() + "' availlable:[remote,include,default,project,option,link]");
}
// now we parse all sub repo: // now we parse all sub repo:
for elem in this.includes: for (IncludeConfig elem : this.includes) {
elem["manifest"] = Manifest(elem["path"]) elem.setManifest(new Manifest(elem.getPath()));
}
}
// inside data child.text
// public void _create_path_with_elem(this, element): public String createPathWithElem(final ProjectConfig element) {
// path = element["path"] String path = element.getPath();
// if path == "": if (path.isEmpty()) {
// path = element["name"] path = element.getName();
// if len(path) >= 4 \ if (path.endsWith(".git")) {
// and path[-4:] == ".git": path = path.substring(0, path.length()-4);
// path = path[:-4] }
// return path }
// return path;
// public void checkDoublePath(this, list_path = [], space=""): }
// public void checkDoublePath(this, list_path = [], space="") {
// Log.debug(space + "check path : '" + this.manifest_xml + "'") // Log.debug(space + "check path : '" + this.manifest_xml + "'")
// for elem in this.projects: // for elem in this.projects:
// path = this._create_path_with_elem(elem) // path = this._create_path_with_elem(elem)
@ -317,107 +497,126 @@ public class Manifest {
// list_path.append(path) // list_path.append(path)
// for elem in this.includes: // for elem in this.includes:
// elem["manifest"]._check_double_path(list_path, space + " ") // elem["manifest"]._check_double_path(list_path, space + " ")
// // }
// public void get_all_configs(this, default=None, upper_remotes=[]):
// out = [] public List<ProjectConfig> get_all_configs() {
// if default == None: return get_all_configs(null, new ArrayList<>());
// if this.default != None: }
// default = copy.deepcopy(this.default)
// else: public List<ProjectConfig> get_all_configs(RepositoryCongig defaultPlouf, final List<RemoteConfig> upper_remotes) {
// default = copy.deepcopy(this.default_base) List<ProjectConfig> out = new ArrayList<>();
// // Log.error(" this.default=" + str(this.default)) if (defaultPlouf == null) {
// // add all local project if (this.defaultWhat != null) {
// for elem in this.projects: defaultPlouf = this.defaultWhat.clone();
// Log.verbose("parse element " + str(elem)) } else {
// if Env.need_process_with_filter(elem["name"]) == false: defaultPlouf = this.default_base.clone();
// Log.info("Filter repository: " + str(elem["name"])) }
// continue }
// conf = repo_config.RepoConfig() // Log.error(" this.default=" + str(this.default))
// conf.name = elem["name"] // add all local project
// conf.tag = elem["tag"] for (ProjectConfig elem : this.projects) {
// conf.path = this._create_path_with_elem(elem) Log.verbose("parse element " + elem);
// if (!Env.need_process_with_filter(elem.getName())) {
// // add default remote for the project (search in herited element) Log.info("Filter repository: " + elem.getName());
// for remote in this.remotes: continue;
// Log.verbose(" Local Remote: " + str(remote)) }
// if remote["name"] == default["remote"]: ProjectConfig conf = new ProjectConfig(elem.getName(), createPathWithElem(elem), elem.getTag());
// conf.remotes.append(remote)
// if len(conf.remotes) == 0: // add default remote for the project (search in herited element)
// for remote in upper_remotes: for (RemoteConfig remote : this.remotes) {
// Log.verbose(" upper Remote: " + str(remote)) Log.verbose(" Local Remote: " + remote);
// if remote["name"] == default["remote"]: if (remote.getName().equals(defaultPlouf.getRemote())) {
// conf.remotes.append(remote) conf.getRemotes().add(remote);
// if len(conf.remotes) == 0: }
// Log.error(" No remote detected: " + str(len(conf.remotes)) + " for " + conf.name + " with default remote name : " + default["remote"] + " this remote: " + str(this.remotes)) }
// if (conf.getRemotes().size() == 0) {
// // select default remote: for (RemoteConfig remote : upper_remotes) {
// conf.select_remote = None Log.verbose(" upper Remote: " + remote);
// Log.debug(" remotes count: " + str(len(conf.remotes))) if (remote.getName().equals(defaultPlouf.getRemote())) {
// for remote in conf.remotes: conf.getRemotes().add(remote);
// Log.debug(" remote=" + str(remote)) }
// Log.debug(" Ckeck remote : " + remote["name"] + " == " + default["remote"]) }
// Log.verbose(" remote=" + str(remote)) }
// Log.verbose(" default=" + str(default)) if (conf.getRemotes().size() == 0) {
// if remote["name"] == default["remote"]: Log.error(" No remote detected: " + conf.getRemotes().size() + " for " + conf.getName() + " with default remote name : " + defaultPlouf.getRemote() + " this remote: " + this.remotes);
// conf.select_remote = copy.deepcopy(remote) }
// Log.debug(" copy select=" + str(conf.select_remote)) // select default remote:
// Log.debug(" remotes count: " + conf.getRemotes().size());
// // copy the submodule synchronisation for (RemoteConfig remote : conf.getRemotes()) {
// conf.select_remote["sync"] = default["sync"] Log.debug(" remote=" + remote);
// break Log.debug(" Ckeck remote : " + remote.getName() + " == " + defaultPlouf.getRemote());
// if conf.select_remote == None: Log.verbose(" remote=" + remote);
// Log.error("missing remote for project: " + str(conf.name)) Log.verbose(" default=" + defaultPlouf);
// if (remote.getName().equals(defaultPlouf.getRemote())) {
// conf.branch = default["revision"] conf.setSelectRemotes(remote.clone());
// out.append(conf) Log.debug(" copy select=" + conf.getSelectRemotes());
// // create a temporary variable to transmit the remote to includes
// upper_remotes_forward = copy.deepcopy(upper_remotes) // copy the submodule synchronisation
// for remote in this.remotes: // TODO: ????? conf.getSelectRemotes().setSync(defaultPlouf.isSync());
// upper_remotes_forward.append(remote) break;
// // add all include project }
// for elem in this.includes: }
// list_project = elem["manifest"].get_all_configs(default, upper_remotes_forward) if (conf.getSelectRemotes() == null) {
// for elem_proj in list_project: Log.error("missing remote for project: " + conf.getName());
// out.append(elem_proj) }
// conf.setBranch(defaultPlouf.getRevision());
// //# ------------------------------------------------------------- out.add(conf);
// //# -- add Volatile ... }
// //# ------------------------------------------------------------- // create a temporary variable to transmit the remote to includes
// Log.verbose("include volatile config") List<RemoteConfig> upper_remotes_forward = new ArrayList<>(upper_remotes);
// // TODO: maybe find a better way to do this... for (RemoteConfig remote : this.remotes) {
// conf_global = config.get_unique_config() upper_remotes_forward.add(remote);
// for elem in conf_global.get_volatile(): }
// conf = repo_config.RepoConfig() // add all include project
// base_volatile, repo_volatile = repo_config.split_repo(elem["git_address"]) for (IncludeConfig elem : this.includes) {
// conf.name = repo_volatile List<ProjectConfig> list_project = elem.getManifest().get_all_configs(defaultPlouf, upper_remotes_forward);
// conf.path = elem["path"] for (ProjectConfig elem_proj : list_project) {
// conf.branch = "master" out.add(elem_proj);
// conf.volatile = true }
// conf.remotes = [ }
// {
// 'name': 'origin', // DEPRECIATE volatile for a while?.????
// 'fetch': base_volatile, //# -------------------------------------------------------------
// 'mirror': [] //# -- add Volatile ...
// } //# -------------------------------------------------------------
// ] Log.verbose("include volatile config");
// conf.select_remote = { // TODO: maybe find a better way to do this...
// 'name': 'origin', /*
// 'fetch': base_volatile, conf_global = config.get_unique_config()
// 'sync': false, for elem in conf_global.get_volatile():
// 'mirror': [] conf = repo_config.RepoConfig()
// } base_volatile, repo_volatile = repo_config.split_repo(elem["git_address"])
// out.append(conf) conf.name = repo_volatile
// //# ------------------------------------------------------------- conf.path = elem["path"]
// if false: conf.branch = "master"
// Log.info("list of all repo:") conf.volatile = true
// for elem in out: conf.remotes = [
// Log.info(" '" + elem.name + "'") {
// Log.info(" path: " + elem.path) 'name': 'origin',
// Log.info(" remotes: " + str(elem.remotes)) 'fetch': base_volatile,
// Log.info(" select_remote: " + str(elem.select_remote)) 'mirror': []
// Log.info(" branch: " + elem.branch) }
// return out ]
// conf.select_remote = {
'name': 'origin',
'fetch': base_volatile,
'sync': false,
'mirror': []
}
out.append(conf)
//# -------------------------------------------------------------
if false:
Log.info("list of all repo:")
for elem in out:
Log.info(" '" + elem.name + "'")
Log.info(" path: " + elem.path)
Log.info(" remotes: " + str(elem.remotes))
Log.info(" select_remote: " + str(elem.select_remote))
Log.info(" branch: " + elem.branch)
*/
return out;
}
// //
//public void tag_manifest(manifest_xml_filename, all_tags): //public void tag_manifest(manifest_xml_filename, all_tags):
// tree = etree.parse(manifest_xml_filename) // tree = etree.parse(manifest_xml_filename)
@ -533,4 +732,6 @@ public class Manifest {
// // now we parse all sub repo: // // now we parse all sub repo:
// for elem in includes: // for elem in includes:
// tag_clear(elem["path"]) // tag_clear(elem["path"])
// //
}

View File

@ -21,35 +21,35 @@ public class ConfigManifest {
} }
public String getRepo() { public String getRepo() {
return repo; return this.repo;
} }
public void setRepo(String repo) { public void setRepo(final String repo) {
this.repo = repo; this.repo = repo;
} }
public String getBranch() { public String getBranch() {
return branch; return this.branch;
} }
public void setBranch(String branch) { public void setBranch(final String branch) {
this.branch = branch; this.branch = branch;
} }
public String getManifestName() { public String getManifestName() {
return manifestName; return this.manifestName;
} }
public void setManifestName(String manifestName) { public void setManifestName(final String manifestName) {
this.manifestName = manifestName; this.manifestName = manifestName;
} }
public List<Volatile> getVolatiles() { public List<Volatile> getVolatiles() {
return volatiles; return this.volatiles;
} }
public void setVolatiles(List<Volatile> volatiles) { public void setVolatiles(final List<Volatile> volatiles) {
this.volatiles = volatiles; this.volatiles = volatiles;
} }
public void addVolatile(String gitAddress, String path) { public void addVolatile(final String gitAddress, final String path) {
rmVolatile(path); rmVolatile(path);
this.volatiles.add(new Volatile(gitAddress, path)); this.volatiles.add(new Volatile(gitAddress, path));
} }
private void rmVolatile(String path) { private void rmVolatile(final String path) {
ListIterator<Volatile> it = volatiles.listIterator(); ListIterator<Volatile> it = this.volatiles.listIterator();
while (it.hasNext()) { while (it.hasNext()) {
Volatile elem = it.next(); Volatile elem = it.next();
if (elem.path.equals(path)) { if (elem.path.equals(path)) {
@ -58,29 +58,29 @@ public class ConfigManifest {
} }
} }
public List<Link> getCurentLink() { public List<Link> getCurentLink() {
return curentLink; return this.curentLink;
} }
public void setCurentLink(List<Link> curentLink) { public void setCurentLink(final List<Link> curentLink) {
this.curentLink = curentLink; this.curentLink = curentLink;
} }
public void addLink(String source, String destination) { public void addLink(final String source, final String destination) {
rmLink(destination); rmLink(destination);
this.curentLink.add(new Link(source, destination)); this.curentLink.add(new Link(source, destination));
} }
private void rmLink(String destination) { private void rmLink(final String destination) {
ListIterator<Link> it = curentLink.listIterator(); ListIterator<Link> it = this.curentLink.listIterator();
while (it.hasNext()) { while (it.hasNext()) {
Link elem = it.next(); Link elem = it.next();
if (elem.destination.equals(destination)) { if (elem.getDestination().equals(destination)) {
it.remove(); it.remove();
} }
} }
} }
public static ConfigManifest load() { public static ConfigManifest load() {
return load(Env.get_island_path_config()); return ConfigManifest.load(Env.get_island_path_config());
} }
public static ConfigManifest load(Path path) { public static ConfigManifest load(final Path path) {
ConfigManifest[] root = null; ConfigManifest[] root = null;
try { try {
root = Exml.parse(path, ConfigManifest.class, "config-island"); root = Exml.parse(path, ConfigManifest.class, "config-island");
@ -96,7 +96,7 @@ public class ConfigManifest {
public void store() { public void store() {
store(Env.get_island_path_config()); store(Env.get_island_path_config());
} }
public void store(Path path) { public void store(final Path path) {
Log.todo("unimplemented model..."); Log.todo("unimplemented model...");
} }

View File

@ -1,9 +1,9 @@
package org.atriasoft.island.model; package org.atriasoft.island.model;
class Link { public class Link {
public String source; private String source;
public String destination; private String destination;
public Link(String source, String destination) { public Link(final String source, final String destination) {
this.source = source; this.source = source;
this.destination = destination; this.destination = destination;
} }
@ -11,5 +11,17 @@ class Link {
this.source = ""; this.source = "";
this.destination = ""; this.destination = "";
} }
public String getSource() {
return this.source;
}
public void setSource(final String source) {
this.source = source;
}
public String getDestination() {
return this.destination;
}
public void setDestination(final String destination) {
this.destination = destination;
}
} }