[DEV] commit all with new insland

This commit is contained in:
Edouard DUPIN 2022-03-20 23:39:36 +01:00
parent 0a0889afa3
commit 62e1c3bd80
6 changed files with 276 additions and 250 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
/__pycache__/
# Compiled python modules.
*.pyc

View File

@ -1 +1,3 @@
/__pycache__/
/classes/

View File

@ -1,5 +1,6 @@
package org.atriasoft.island;
//!/usr/bin/python
// -*- coding: utf-8 -*-
//#
//# @author Edouard DUPIN
@ -17,22 +18,96 @@ import java.nio.file.Paths;
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_ACTION_NEED_UPDTATE = 15;
public static String systemBaseName = "island";
public static String artifactoryBaseFolder = "artifact";
public static void setSystemBaseName(final String val) {
Env.systemBaseName = val;
public static String artifactoryBaseFolder = "artifact";
private static boolean fetchManifest = true;
private static int waitBetweenSeverCommand = 0;
public static String filterCommand = null;
private static boolean displayFolderInsteadOfGitName = true;
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.islandRootPath = Paths.get("");
Path tmpPath = Env.islandRootPath.toAbsolutePath();
Log.debug("Current absolute path is: " + tmpPath);
while (!Files.isDirectory(tmpPath.resolve("." + Env.getSystemBaseName()))) {
tmpPath = tmpPath.getParent();
Log.debug("test upper path: " + tmpPath);
if (tmpPath == null) {
Log.debug("the root path of " + Env.getSystemBaseName() + " must not be upper parent paths of (" + Env.islandRootPath.toAbsolutePath() + ")");
tmpPath = Env.islandRootPath.toAbsolutePath();
break;
}
}
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);
}
public static boolean getDisplayFolderInsteadOfGitName() {
return Env.displayFolderInsteadOfGitName;
}
public static boolean getFetchManifest() {
return Env.fetchManifest;
}
public static String getFilterCommand() {
return Env.filterCommand;
}
public static Path getIslandPath() {
return Env.islandPath;
}
public static Path getIslandPathArtifactory() {
return Env.islandPathArtifactory;
}
public static Path getIslandPathConfig() {
return Env.islandPathConfig;
}
public static Path getIslandPathManifest() {
return Env.islandPathManifest;
}
public static Path getIslandPathUserConfig() {
return Env.islandPathUserConfig;
}
/**
* To use later to know where the ".island" parent path is ...
* @return the parent path of the ".island"
*/
public static Path getIslandRootPath() {
return Env.islandRootPath;
}
public static String getSystemBaseName() {
return Env.systemBaseName;
}
@ -41,32 +116,19 @@ public class Env {
return "." + Env.systemBaseName + "Config.json";
}
private static boolean fetchManifest = true;
public static void setFetchManifest(final boolean val) {
Env.fetchManifest = val;
}
public static boolean getFetchManifest() {
return Env.fetchManifest;
}
private static int waitBetweenSeverCommand = 0;
public static void setWaitBetweenSeverCommand(final int val) {
Env.waitBetweenSeverCommand = val;
}
public static int getWaitBetweenSeverCommand() {
return Env.waitBetweenSeverCommand;
}
public static String filterCommand = null;
public static void setFilterCommand(final String val) {
Env.filterCommand = val;
}
public static String getFilterCommand() {
return Env.filterCommand;
public static void main(final String[] args) {
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());
}
public static boolean needProcessWithFilter(final String data) {
if (Env.filterCommand == null || Env.filterCommand.equals("")) {
return true;
@ -80,75 +142,26 @@ public class Env {
return false;
}
private static boolean displayFolderInsteadOfGitName = true;
public static void setDisplayFolderInstead_ofGitName(final boolean val) {
Env.displayFolderInsteadOfGitName = val;
}
public static boolean getDisplayFolderInsteadOfGitName() {
return Env.displayFolderInsteadOfGitName;
public static void setFetchManifest(final boolean val) {
Env.fetchManifest = val;
}
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.islandRootPath = Paths.get("");
Path tmpPath = Env.islandRootPath.toAbsolutePath();
Log.info("Current absolute path is: " + tmpPath);
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.getSystemBaseName() + " must not be upper parent paths of (" + Env.islandRootPath.toAbsolutePath() + ")");
tmpPath = Env.islandRootPath.toAbsolutePath();
break;
}
}
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 getIslandRootPath() {
return Env.islandRootPath;
}
public static Path getIslandPath() {
return Env.islandPath;
}
public static Path getIslandPathConfig() {
return Env.islandPathConfig;
}
public static Path getIslandPathManifest() {
return Env.islandPathManifest;
}
public static Path getIslandPathArtifactory() {
return Env.islandPathArtifactory;
}
public static Path getIslandPathUserConfig() {
return Env.islandPathUserConfig;
public static void setFilterCommand(final String val) {
Env.filterCommand = val;
}
public static void main(final String[] args) {
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());
public static void setSystemBaseName(final String val) {
Env.systemBaseName = val;
}
public static void setWaitBetweenSeverCommand(final int val) {
Env.waitBetweenSeverCommand = val;
}
private Env() {}
}

View File

@ -24,6 +24,14 @@ import org.atriasoft.island.model.manifest.ProjectConfig;
import org.atriasoft.island.model.manifest.RemoteConfig;
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.getIslandPath() + "'. Call <island init> first");
System.exit(-1);
}
}
public static boolean isInit() {
if (!Files.exists(Env.getIslandPath())) {
Log.verbose("Lutin is not init: path does not exist: '" + Env.getIslandPath() + "'");
@ -39,13 +47,6 @@ public class Manifest {
}
return true;
}
public static void checkIsInit() {
// check if .XXX exist (create it if needed)
if (!Manifest.isInit()) {
Log.error("System not init: missing config: '" + Env.getIslandPath() + "'. Call <island init> first");
System.exit(-1);
}
}
private final Path manifestXml;
@ -69,55 +70,6 @@ public class Manifest {
// TODO checkDoublePath();
}
public List<Link> getLinks() {
List<Link> out = new ArrayList<>();
for (Entry<String, ManifestFile> elem : this.manifests.entrySet()) {
for (Link link : elem.getValue().getLinks()) {
out.add(link);
}
}
return out;
}
String removeEndSlash(String value) {
while (value.length() > 1
&& ( value.charAt(value.length()-1) == '\\'
|| value.charAt(value.length()-1) == '/') ) {
value = value.substring(0, value.length()-1);
}
return value;
}
public void load() throws ExmlParserErrorMulti, ExmlBuilderException, IOException {
Path rootDirectory = this.manifestXml.toAbsolutePath();
this.rootManifest = rootDirectory.getFileName().toString();
rootDirectory = rootDirectory.getParent();
Log.info("PArse main XML config " + rootDirectory);
ManifestFile parsedElements = null;
try {
parsedElements = Exml.parseOne(this.manifestXml, ManifestFile.class, "manifest");
} catch (ExmlException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
parsedElements.setFileRealPath(this.manifestXml);
this.manifests.put(this.rootManifest, parsedElements);
for (String includeElem : parsedElements.getIncludes()) {
Path maniPath = rootDirectory.resolve(includeElem);
Log.info("PArse <<SUB>> XML config " + maniPath);
ManifestFile tmpManifest = null;
try {
tmpManifest = Exml.parseOne(maniPath, ManifestFile.class, "manifest");
} catch (ExmlException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
tmpManifest.setFileRealPath(maniPath);
this.manifests.put(includeElem, tmpManifest);
}
}
public String createPathWithElem(final ProjectConfig element) {
String path = element.getPath();
if (path.isEmpty()) {
@ -129,46 +81,6 @@ 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<>());
@ -209,7 +121,8 @@ public class Manifest {
}
}
if (conf.getRemotes().size() == 0) {
Log.error(" No remote detected: " + conf.getRemotes().size() + " for " + conf.getName() + " with default remote name : " + defaultPlouf.getDefaultRemote() + " this remote: " + mani.getRemotes());
Log.error(" No remote detected: " + conf.getRemotes().size() + " for " + conf.getName() + " with default remote name : " + defaultPlouf.getDefaultRemote() + " this remote: "
+ mani.getRemotes());
}
// select default remote:
Log.debug(" remotes count: " + conf.getRemotes().size());
@ -289,6 +202,52 @@ public class Manifest {
return out;
}
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<>(mani.getDependencies());
// add all include project
for (String elemInclude : mani.getIncludes()) {
ManifestFile mani2 = this.manifests.get(elemInclude);
out.addAll(getAllDependencies(mani2));
}
return out;
}
public String getBranchRelease() {
OptionRepository defaultPlouf = this.defaultBase;
if (this.defaultWhat != null) {
defaultPlouf = this.defaultWhat;
}
return defaultPlouf.getBranchRelease();
}
public String getDeliverDevelop() {
OptionRepository defaultPlouf = this.defaultBase;
@ -297,13 +256,7 @@ public class Manifest {
}
return defaultPlouf.getBranchDevelop();
}
public String getBranchRelease() {
OptionRepository defaultPlouf = this.defaultBase;
if (this.defaultWhat != null) {
defaultPlouf = this.defaultWhat;
}
return defaultPlouf.getBranchRelease();
}
public DeliverMode getDeliverModeMerge() {
OptionRepository defaultPlouf = this.defaultBase;
if (this.defaultWhat != null) {
@ -312,4 +265,51 @@ public class Manifest {
return defaultPlouf.getDeliverMode();
}
public List<Link> getLinks() {
List<Link> out = new ArrayList<>();
for (Entry<String, ManifestFile> elem : this.manifests.entrySet()) {
for (Link link : elem.getValue().getLinks()) {
out.add(link);
}
}
return out;
}
public void load() throws ExmlParserErrorMulti, ExmlBuilderException, IOException {
Path rootDirectory = this.manifestXml.toAbsolutePath();
this.rootManifest = rootDirectory.getFileName().toString();
rootDirectory = rootDirectory.getParent();
Log.debug("PArse main XML config " + rootDirectory);
ManifestFile parsedElements = null;
try {
parsedElements = Exml.parseOne(this.manifestXml, ManifestFile.class, "manifest");
} catch (ExmlException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
parsedElements.setFileRealPath(this.manifestXml);
this.manifests.put(this.rootManifest, parsedElements);
for (String includeElem : parsedElements.getIncludes()) {
Path maniPath = rootDirectory.resolve(includeElem);
Log.debug("PArse <<SUB>> XML config " + maniPath);
ManifestFile tmpManifest = null;
try {
tmpManifest = Exml.parseOne(maniPath, ManifestFile.class, "manifest");
} catch (ExmlException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
tmpManifest.setFileRealPath(maniPath);
this.manifests.put(includeElem, tmpManifest);
}
}
String removeEndSlash(String value) {
while (value.length() > 1 && (value.charAt(value.length() - 1) == '\\' || value.charAt(value.length() - 1) == '/')) {
value = value.substring(0, value.length() - 1);
}
return value;
}
}

View File

@ -19,7 +19,6 @@ import org.atriasoft.island.internal.Log;
import org.atriasoft.island.model.ActionException;
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;
import org.eclipse.jgit.transport.PushResult;
@ -72,13 +71,14 @@ public class BasePush {
Git git = Git.open(git_repo_path.toFile());
String select_branch = git.getRepository().getBranch();
Iterable<PushResult> plo = git.push()
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
.setRemote(elem.getSelectRemotes().getName())
.setForce(this.force)
.add(select_branch)
.setDryRun(this.dryRun)
Iterable<PushResult> plo = git.push() //
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out))) //
.setRemote(elem.getSelectRemotes().getName()) //
.setForce(this.force) //
.add(select_branch) //
.setDryRun(this.dryRun) //
.call();
Log.verbose("plop " + plo.hashCode());
Log.info("[" + elem.getName() + "] fetch done " + dryRunComment);
}
}
@ -87,4 +87,3 @@ public class BasePush {
}
}

View File

@ -4,10 +4,12 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import org.atriasoft.exml.annotation.XmlIgnoreUnknow;
import org.atriasoft.exml.annotation.XmlList;
import org.atriasoft.exml.annotation.XmlManaged;
import org.atriasoft.exml.annotation.XmlName;
@XmlIgnoreUnknow
public class ManifestFile {
private Path fileRealPath = null;
private List<ProjectConfig> projects = new ArrayList<>();
@ -18,28 +20,9 @@ public class ManifestFile {
private OptionRepository options = null;
private List<Link> links = new ArrayList<>();
@XmlName(value="project")
public List<ProjectConfig> getProjects() {
return this.projects;
}
public void setProjects(final List<ProjectConfig> projects) {
this.projects = projects;
}
@XmlName(value="remote")
public List<RemoteConfig> getRemotes() {
return this.remotes;
}
public void setRemotes(final List<RemoteConfig> remotes) {
this.remotes = remotes;
}
@XmlName(value="include")
public List<String> getIncludes() {
return this.includes;
}
public void setIncludes(final List<String> includes) {
this.includes = includes;
@XmlName("artefactory")
public List<Artifactory> getArtefactories() {
return this.artefactories;
}
@XmlName(value = "dependencies")
@ -47,39 +30,66 @@ public class ManifestFile {
public List<Dependency> getDependencies() {
return this.dependencies;
}
public void setDependencies(final List<Dependency> dependency) {
this.dependencies = dependency;
@XmlManaged(false)
public Path getFileRealPath() {
return this.fileRealPath;
}
public OptionRepository getOptions() {
return this.options;
}
public void setOptions(final OptionRepository options) {
this.options = options;
@XmlName(value = "include")
public List<String> getIncludes() {
return this.includes;
}
@XmlName(value = "link")
public List<Link> getLinks() {
return this.links;
}
public void setLinks(final List<Link> links) {
this.links = links;
public OptionRepository getOptions() {
return this.options;
}
@XmlManaged(false)
public Path getFileRealPath() {
return this.fileRealPath;
}
public void setFileRealPath(final Path fileRealPath) {
this.fileRealPath = fileRealPath;
@XmlName(value = "project")
public List<ProjectConfig> getProjects() {
return this.projects;
}
@XmlName("artefactory")
public List<Artifactory> getArtefactories() {
return this.artefactories;
@XmlName(value = "remote")
public List<RemoteConfig> getRemotes() {
return this.remotes;
}
public void setArtefactories(final List<Artifactory> artefacts) {
this.artefactories = artefacts;
}
public void setDependencies(final List<Dependency> dependency) {
this.dependencies = dependency;
}
public void setFileRealPath(final Path fileRealPath) {
this.fileRealPath = fileRealPath;
}
public void setIncludes(final List<String> includes) {
this.includes = includes;
}
public void setLinks(final List<Link> links) {
this.links = links;
}
public void setOptions(final OptionRepository options) {
this.options = options;
}
public void setProjects(final List<ProjectConfig> projects) {
this.projects = projects;
}
public void setRemotes(final List<RemoteConfig> remotes) {
this.remotes = remotes;
}
}