[DEV] update new exml

This commit is contained in:
Edouard DUPIN 2022-05-11 00:57:39 +02:00
parent db54f8d50c
commit cf7da8138d
2 changed files with 45 additions and 34 deletions

View File

@ -9,6 +9,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.exml.Exml;
import org.atriasoft.exml.exception.ExmlBuilderException;
import org.atriasoft.exml.exception.ExmlException;
@ -62,7 +63,7 @@ public class Manifest {
// load the manifest
try {
load();
} catch (ExmlBuilderException e) {
} catch (final ExmlBuilderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@ -82,12 +83,12 @@ public class Manifest {
}
public List<ProjectConfig> get_all_configs() {
ManifestFile mani = this.manifests.get(this.rootManifest);
final 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<>();
final List<ProjectConfig> out = new ArrayList<>();
if (defaultPlouf == null) {
if (this.defaultWhat != null) {
defaultPlouf = this.defaultWhat.clone();
@ -97,23 +98,23 @@ public class Manifest {
}
// Log.error(" this.default=" + str(this.default))
// add all local project
for (ProjectConfig elem : mani.getProjects()) {
for (final ProjectConfig elem : mani.getProjects()) {
Log.verbose("parse element " + elem);
if (!Env.needProcessWithFilter(elem.getName())) {
Log.info("Filter repository: " + elem.getName());
continue;
}
ProjectConfig conf = new ProjectConfig(elem.getName(), createPathWithElem(elem), elem.getTag());
final ProjectConfig conf = new ProjectConfig(elem.getName(), createPathWithElem(elem), elem.getTag());
// add default remote for the project (search in herited element)
for (RemoteConfig remote : mani.getRemotes()) {
for (final RemoteConfig remote : mani.getRemotes()) {
Log.verbose(" Local Remote: " + remote);
if (remote.getName().equals(defaultPlouf.getDefaultRemote())) {
conf.getRemotes().add(remote);
}
}
if (conf.getRemotes().size() == 0) {
for (RemoteConfig remote : upper_remotes) {
for (final RemoteConfig remote : upper_remotes) {
Log.verbose(" upper Remote: " + remote);
if (remote.getName() != null && remote.getName().equals(defaultPlouf.getDefaultRemote())) {
conf.getRemotes().add(remote);
@ -126,7 +127,7 @@ public class Manifest {
}
// select default remote:
Log.debug(" remotes count: " + conf.getRemotes().size());
for (RemoteConfig remote : conf.getRemotes()) {
for (final RemoteConfig remote : conf.getRemotes()) {
Log.debug(" remote=" + remote);
Log.debug(" Ckeck remote : " + remote.getName() + ".equals(" + defaultPlouf.getDefaultRemote());
Log.verbose(" remote=" + remote);
@ -147,15 +148,15 @@ public class Manifest {
out.add(conf);
}
// create a temporary variable to transmit the remote to includes
List<RemoteConfig> upper_remotes_forward = new ArrayList<>(upper_remotes);
for (RemoteConfig remote : mani.getRemotes()) {
final List<RemoteConfig> upper_remotes_forward = new ArrayList<>(upper_remotes);
for (final RemoteConfig remote : mani.getRemotes()) {
upper_remotes_forward.add(remote);
}
// add all include project
for (String elemInclude : mani.getIncludes()) {
ManifestFile mani2 = this.manifests.get(elemInclude);
List<ProjectConfig> list_project = get_all_configs(mani2, defaultPlouf, upper_remotes_forward);
for (ProjectConfig elem_proj : list_project) {
for (final String elemInclude : mani.getIncludes()) {
final ManifestFile mani2 = this.manifests.get(elemInclude);
final List<ProjectConfig> list_project = get_all_configs(mani2, defaultPlouf, upper_remotes_forward);
for (final ProjectConfig elem_proj : list_project) {
out.add(elem_proj);
}
}
@ -203,23 +204,23 @@ public class Manifest {
}
public List<Artifactory> getAllArtefactories() {
ManifestFile mani = this.manifests.get(this.rootManifest);
final ManifestFile mani = this.manifests.get(this.rootManifest);
return getAllArtefactories(mani);
}
public List<Artifactory> getAllArtefactories(final ManifestFile mani) {
List<Artifactory> out = new ArrayList<>();
final List<Artifactory> out = new ArrayList<>();
// add all local project
for (Artifactory elem : mani.getArtefactories()) {
for (final Artifactory elem : mani.getArtefactories()) {
Log.verbose("parse a " + elem);
Artifactory conf = elem.clone();
final 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) {
for (final String elemInclude : mani.getIncludes()) {
final ManifestFile mani2 = this.manifests.get(elemInclude);
final List<Artifactory> list_project = getAllArtefactories(mani2);
for (final Artifactory elem_proj : list_project) {
out.add(elem_proj);
}
}
@ -227,15 +228,15 @@ public class Manifest {
}
public List<Dependency> getAllDependencies() {
ManifestFile mani = this.manifests.get(this.rootManifest);
final ManifestFile mani = this.manifests.get(this.rootManifest);
return getAllDependencies(mani);
}
public List<Dependency> getAllDependencies(final ManifestFile mani) {
List<Dependency> out = new ArrayList<>(mani.getDependencies());
final List<Dependency> out = new ArrayList<>(mani.getDependencies());
// add all include project
for (String elemInclude : mani.getIncludes()) {
ManifestFile mani2 = this.manifests.get(elemInclude);
for (final String elemInclude : mani.getIncludes()) {
final ManifestFile mani2 = this.manifests.get(elemInclude);
out.addAll(getAllDependencies(mani2));
}
return out;
@ -266,9 +267,9 @@ public class Manifest {
}
public List<Link> getLinks() {
List<Link> out = new ArrayList<>();
for (Entry<String, ManifestFile> elem : this.manifests.entrySet()) {
for (Link link : elem.getValue().getLinks()) {
final List<Link> out = new ArrayList<>();
for (final Entry<String, ManifestFile> elem : this.manifests.entrySet()) {
for (final Link link : elem.getValue().getLinks()) {
out.add(link);
}
}
@ -284,19 +285,25 @@ public class Manifest {
ManifestFile parsedElements = null;
try {
parsedElements = Exml.parseOne(this.manifestXml, ManifestFile.class, "manifest");
} catch (ExmlException e1) {
} catch (final ExmlException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (final AknotException 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);
for (final String includeElem : parsedElements.getIncludes()) {
final 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) {
} catch (final ExmlException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (final AknotException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

View File

@ -8,6 +8,7 @@ import java.util.ListIterator;
import org.atriasoft.aknot.annotation.AknotList;
import org.atriasoft.aknot.annotation.AknotName;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.exml.Exml;
import org.atriasoft.exml.exception.ExmlBuilderException;
import org.atriasoft.exml.exception.ExmlException;
@ -28,9 +29,12 @@ public class ConfigManifest {
} catch (final ExmlException e) {
Log.error("Can not parse the file.1. " + path);
e.printStackTrace();
} catch (final AknotException e) {
Log.error("Can not parse the file.2. " + path);
e.printStackTrace();
}
if (root.length != 1) {
Log.error("Can not parse the file.2. " + path);
Log.error("Can not parse the file.3. " + path);
}
return root[0];
}