---No commit message---
This commit is contained in:
parent
cf7da8138d
commit
5e71f7673b
@ -10,7 +10,7 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.atriasoft.aknot.exception.AknotException;
|
import org.atriasoft.aknot.exception.AknotException;
|
||||||
import org.atriasoft.exml.Exml;
|
import org.atriasoft.exml.XmlMapper;
|
||||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||||
import org.atriasoft.exml.exception.ExmlException;
|
import org.atriasoft.exml.exception.ExmlException;
|
||||||
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
|
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
|
||||||
@ -283,12 +283,10 @@ public class Manifest {
|
|||||||
|
|
||||||
Log.debug("PArse main XML config " + rootDirectory);
|
Log.debug("PArse main XML config " + rootDirectory);
|
||||||
ManifestFile parsedElements = null;
|
ManifestFile parsedElements = null;
|
||||||
|
final XmlMapper mapper = new XmlMapper();
|
||||||
try {
|
try {
|
||||||
parsedElements = Exml.parseOne(this.manifestXml, ManifestFile.class, "manifest");
|
parsedElements = mapper.parse(this.manifestXml, ManifestFile.class);
|
||||||
} catch (final ExmlException e1) {
|
} catch (final ExmlException | AknotException e1) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
} catch (final AknotException e1) {
|
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -299,11 +297,8 @@ public class Manifest {
|
|||||||
Log.debug("PArse <<SUB>> XML config " + maniPath);
|
Log.debug("PArse <<SUB>> XML config " + maniPath);
|
||||||
ManifestFile tmpManifest = null;
|
ManifestFile tmpManifest = null;
|
||||||
try {
|
try {
|
||||||
tmpManifest = Exml.parseOne(maniPath, ManifestFile.class, "manifest");
|
tmpManifest = mapper.parse(maniPath, ManifestFile.class);
|
||||||
} catch (final ExmlException e) {
|
} catch (final ExmlException | AknotException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (final AknotException e) {
|
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import org.atriasoft.ejson.Ejson;
|
|||||||
import org.atriasoft.ejson.model.JsonArray;
|
import org.atriasoft.ejson.model.JsonArray;
|
||||||
import org.atriasoft.ejson.model.JsonObject;
|
import org.atriasoft.ejson.model.JsonObject;
|
||||||
import org.atriasoft.ejson.model.JsonString;
|
import org.atriasoft.ejson.model.JsonString;
|
||||||
import org.atriasoft.exml.Exml;
|
import org.atriasoft.exml.XmlMapper;
|
||||||
import org.atriasoft.exml.exception.ExmlException;
|
import org.atriasoft.exml.exception.ExmlException;
|
||||||
import org.atriasoft.island.Config;
|
import org.atriasoft.island.Config;
|
||||||
import org.atriasoft.island.Env;
|
import org.atriasoft.island.Env;
|
||||||
@ -63,24 +63,24 @@ public class DependencySync {
|
|||||||
public boolean sources = false;
|
public boolean sources = false;
|
||||||
|
|
||||||
public Path createArtefactLinkFileName(final String fileName) {
|
public Path createArtefactLinkFileName(final String fileName) {
|
||||||
Path outPath = Env.getIslandPathArtifactoryLink().resolve(fileName);
|
final Path outPath = Env.getIslandPathArtifactoryLink().resolve(fileName);
|
||||||
return outPath;
|
return outPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Path createArtefactLinkGLDFile(final String fileName) {
|
public Path createArtefactLinkGLDFile(final String fileName) {
|
||||||
Path outPath = Env.getIslandPathArtifactoryLink().resolve("GLD_" + fileName + ".json");
|
final Path outPath = Env.getIslandPathArtifactoryLink().resolve("GLD_" + fileName + ".json");
|
||||||
return outPath;
|
return outPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Path createBasePkgLocalFileName(final List<Artifactory> artefactories, final Dependency dependency, final String version) {
|
public Path createBasePkgLocalFileName(final List<Artifactory> artefactories, final Dependency dependency, final String version) {
|
||||||
Artifactory artifactory = findArtifactory(artefactories, dependency.remote());
|
final Artifactory artifactory = findArtifactory(artefactories, dependency.remote());
|
||||||
String out = artifactory.getName() + "/" + dependency.org().replace(".", "/") + "/" + dependency.name() + "/" + version;
|
final String out = artifactory.getName() + "/" + dependency.org().replace(".", "/") + "/" + dependency.name() + "/" + version;
|
||||||
Path outPath = Env.getIslandPathArtifactory().resolve(out);
|
final Path outPath = Env.getIslandPathArtifactory().resolve(out);
|
||||||
return outPath;
|
return outPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String createBasePkgRemoteFileName(final List<Artifactory> artefactories, final Dependency dependency, final String version) {
|
public String createBasePkgRemoteFileName(final List<Artifactory> artefactories, final Dependency dependency, final String version) {
|
||||||
Artifactory artifactory = findArtifactory(artefactories, dependency.remote());
|
final Artifactory artifactory = findArtifactory(artefactories, dependency.remote());
|
||||||
String out = artifactory.getFetch();
|
String out = artifactory.getFetch();
|
||||||
while (out.endsWith("/")) {
|
while (out.endsWith("/")) {
|
||||||
out = out.substring(0, out.length() - 1);
|
out = out.substring(0, out.length() - 1);
|
||||||
@ -89,31 +89,31 @@ public class DependencySync {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGLDFile(PomMaven mavenPom, Path createArtefactLinkGLDFile, Path artefactLink) {
|
private void createGLDFile(final PomMaven mavenPom, final Path createArtefactLinkGLDFile, final Path artefactLink) {
|
||||||
GLDDependModel model = new GLDDependModel();
|
final GLDDependModel model = new GLDDependModel();
|
||||||
model.path.java.add(artefactLink.getFileName().toString());
|
model.path.java.add(artefactLink.getFileName().toString());
|
||||||
model.groupId = mavenPom.groupId();
|
model.groupId = mavenPom.groupId();
|
||||||
model.version = mavenPom.version();
|
model.version = mavenPom.version();
|
||||||
if (mavenPom.dependencies() != null) {
|
if (mavenPom.dependencies() != null) {
|
||||||
for (PomDependency elem : mavenPom.dependencies()) {
|
for (final PomDependency elem : mavenPom.dependencies()) {
|
||||||
model.dependency.add(elem.artifactId());
|
model.dependency.add(elem.artifactId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: for later : create a generic serializer ...
|
// TODO: for later : create a generic serializer ...
|
||||||
StringBuilder data = new StringBuilder();
|
final StringBuilder data = new StringBuilder();
|
||||||
JsonObject root = new JsonObject();
|
final JsonObject root = new JsonObject();
|
||||||
root.put("type", new JsonString(model.type));
|
root.put("type", new JsonString(model.type));
|
||||||
root.put("group-id", new JsonString(model.groupId));
|
root.put("group-id", new JsonString(model.groupId));
|
||||||
root.put("version", new JsonString(model.version));
|
root.put("version", new JsonString(model.version));
|
||||||
JsonObject path = new JsonObject();
|
final JsonObject path = new JsonObject();
|
||||||
root.put("path", path);
|
root.put("path", path);
|
||||||
JsonArray java = new JsonArray();
|
final JsonArray java = new JsonArray();
|
||||||
for (String elem : model.path.java) {
|
for (final String elem : model.path.java) {
|
||||||
java.add(new JsonString(elem));
|
java.add(new JsonString(elem));
|
||||||
}
|
}
|
||||||
path.put("java", java);
|
path.put("java", java);
|
||||||
JsonArray dep = new JsonArray();
|
final JsonArray dep = new JsonArray();
|
||||||
for (String elem : model.dependency) {
|
for (final String elem : model.dependency) {
|
||||||
dep.add(new JsonString(elem));
|
dep.add(new JsonString(elem));
|
||||||
}
|
}
|
||||||
root.put("dependency", dep);
|
root.put("dependency", dep);
|
||||||
@ -139,10 +139,10 @@ public class DependencySync {
|
|||||||
|
|
||||||
private void downloadPackage(final List<Artifactory> artefactories, final Dependency dependency, final List<UpdateDependency> alreadyDone) throws Exception {
|
private void downloadPackage(final List<Artifactory> artefactories, final Dependency dependency, final List<UpdateDependency> alreadyDone) throws Exception {
|
||||||
Log.debug("download : " + dependency);
|
Log.debug("download : " + dependency);
|
||||||
for (UpdateDependency elem : alreadyDone) {
|
for (final UpdateDependency elem : alreadyDone) {
|
||||||
if (elem.dependency.org().equals(dependency.org()) && elem.dependency.name().equals(dependency.name()) && elem.dependency.remote().equals(dependency.remote())) {
|
if (elem.dependency.org().equals(dependency.org()) && elem.dependency.name().equals(dependency.name()) && elem.dependency.remote().equals(dependency.remote())) {
|
||||||
// find element ==> check version
|
// find element ==> check version
|
||||||
for (String version : elem.download) {
|
for (final String version : elem.download) {
|
||||||
if (version.equals(dependency.revision())) {
|
if (version.equals(dependency.revision())) {
|
||||||
// already download ==> skip ...
|
// already download ==> skip ...
|
||||||
return;
|
return;
|
||||||
@ -151,15 +151,16 @@ public class DependencySync {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String metadataFile = createMavenMetadataRemoteFileName(artefactories, dependency);
|
final String metadataFile = createMavenMetadataRemoteFileName(artefactories, dependency);
|
||||||
Log.verbose("Metadata position: " + metadataFile);
|
Log.verbose("Metadata position: " + metadataFile);
|
||||||
Path localPath = createMetadataLocalFileName(artefactories, dependency);
|
final Path localPath = createMetadataLocalFileName(artefactories, dependency);
|
||||||
String dataAsString = readAllMatadataAndStore(metadataFile, localPath);
|
final String dataAsString = readAllMatadataAndStore(metadataFile, localPath);
|
||||||
Log.verbose("dataAsString: " + dataAsString);
|
Log.verbose("dataAsString: " + dataAsString);
|
||||||
MavenMetadata metaData = null;
|
MavenMetadata metaData = null;
|
||||||
|
final XmlMapper mapper = new XmlMapper();
|
||||||
try {
|
try {
|
||||||
metaData = Exml.parseOne(dataAsString, MavenMetadata.class, "metadata");
|
metaData = mapper.parse(dataAsString, MavenMetadata.class);
|
||||||
} catch (ExmlException e) {
|
} catch (final ExmlException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -169,17 +170,17 @@ public class DependencySync {
|
|||||||
|
|
||||||
// TODO : Check if the version is download
|
// TODO : Check if the version is download
|
||||||
|
|
||||||
String lastReleaseTag = metaData.versioning().release();
|
final String lastReleaseTag = metaData.versioning().release();
|
||||||
|
|
||||||
String remotePakageFileName = createBasePkgRemoteFileName(artefactories, dependency, lastReleaseTag);
|
final String remotePakageFileName = createBasePkgRemoteFileName(artefactories, dependency, lastReleaseTag);
|
||||||
Path localPackageFileName = createBasePkgLocalFileName(artefactories, dependency, lastReleaseTag);
|
final Path localPackageFileName = createBasePkgLocalFileName(artefactories, dependency, lastReleaseTag);
|
||||||
// pom sources
|
// pom sources
|
||||||
String base = getPomFileName(dependency, lastReleaseTag);
|
String base = getPomFileName(dependency, lastReleaseTag);
|
||||||
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
||||||
PomMaven mavenPom = null;
|
PomMaven mavenPom = null;
|
||||||
try {
|
try {
|
||||||
mavenPom = Exml.parseOne(localPackageFileName.resolve(base), PomMaven.class, "project");
|
mavenPom = mapper.parse(localPackageFileName.resolve(base), PomMaven.class);
|
||||||
} catch (ExmlException e) {
|
} catch (final ExmlException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -210,7 +211,7 @@ public class DependencySync {
|
|||||||
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
||||||
*/
|
*/
|
||||||
boolean find = false;
|
boolean find = false;
|
||||||
for (UpdateDependency elem : alreadyDone) {
|
for (final UpdateDependency elem : alreadyDone) {
|
||||||
if (elem.dependency.org().equals(dependency.org()) && elem.dependency.name().equals(dependency.name()) && elem.dependency.remote().equals(dependency.remote())) {
|
if (elem.dependency.org().equals(dependency.org()) && elem.dependency.name().equals(dependency.name()) && elem.dependency.remote().equals(dependency.remote())) {
|
||||||
// find element ==> check version
|
// find element ==> check version
|
||||||
elem.download.add(dependency.revision());
|
elem.download.add(dependency.revision());
|
||||||
@ -219,14 +220,14 @@ public class DependencySync {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!find) {
|
if (!find) {
|
||||||
UpdateDependency tmpp = new UpdateDependency();
|
final UpdateDependency tmpp = new UpdateDependency();
|
||||||
tmpp.dependency = dependency;
|
tmpp.dependency = dependency;
|
||||||
tmpp.download.add(dependency.revision());
|
tmpp.download.add(dependency.revision());
|
||||||
alreadyDone.add(tmpp);
|
alreadyDone.add(tmpp);
|
||||||
}
|
}
|
||||||
if (mavenPom != null && mavenPom.dependencies() != null) {
|
if (mavenPom != null && mavenPom.dependencies() != null) {
|
||||||
for (PomDependency value : mavenPom.dependencies()) {
|
for (final PomDependency value : mavenPom.dependencies()) {
|
||||||
Dependency dependencyTmp = new Dependency(value.groupId(), value.artifactId(), value.version(), dependency.remote());
|
final Dependency dependencyTmp = new Dependency(value.groupId(), value.artifactId(), value.version(), dependency.remote());
|
||||||
downloadPackage(artefactories, dependencyTmp, alreadyDone);
|
downloadPackage(artefactories, dependencyTmp, alreadyDone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,28 +235,28 @@ public class DependencySync {
|
|||||||
|
|
||||||
@ArgExecute
|
@ArgExecute
|
||||||
public void execute() throws ActionException, Exception {
|
public void execute() throws ActionException, Exception {
|
||||||
List<UpdateDependency> alreadyDone = new ArrayList<>();
|
final List<UpdateDependency> alreadyDone = new ArrayList<>();
|
||||||
// check system is OK
|
// check system is OK
|
||||||
Manifest.checkIsInit();
|
Manifest.checkIsInit();
|
||||||
ConfigManifest configuration = Config.getUniqueConfig();
|
final ConfigManifest configuration = Config.getUniqueConfig();
|
||||||
|
|
||||||
// load the manifest after pulling it (if possible)
|
// load the manifest after pulling it (if possible)
|
||||||
Path file_source_manifest = Env.getIslandPathManifest().resolve(configuration.getManifestName());
|
final Path file_source_manifest = Env.getIslandPathManifest().resolve(configuration.getManifestName());
|
||||||
if (!Files.exists(file_source_manifest)) {
|
if (!Files.exists(file_source_manifest)) {
|
||||||
Log.critical("Missing manifest file : '" + file_source_manifest + "'");
|
Log.critical("Missing manifest file : '" + file_source_manifest + "'");
|
||||||
}
|
}
|
||||||
Manifest mani = new Manifest(file_source_manifest);
|
final Manifest mani = new Manifest(file_source_manifest);
|
||||||
|
|
||||||
List<Artifactory> artefactories = mani.getAllArtefactories();
|
final List<Artifactory> artefactories = mani.getAllArtefactories();
|
||||||
List<Dependency> dependencies = mani.getAllDependencies();
|
final List<Dependency> dependencies = mani.getAllDependencies();
|
||||||
|
|
||||||
Log.info("Synchronize of: " + dependencies.size() + " dependenc" + Tools.getPlural(dependencies));
|
Log.info("Synchronize of: " + dependencies.size() + " dependenc" + Tools.getPlural(dependencies));
|
||||||
Log.info("base on: " + artefactories.size() + " artefactor" + Tools.getPlural(artefactories));
|
Log.info("base on: " + artefactories.size() + " artefactor" + Tools.getPlural(artefactories));
|
||||||
int id_element = 0;
|
int id_element = 0;
|
||||||
|
|
||||||
for (Dependency elem : dependencies) {
|
for (final Dependency elem : dependencies) {
|
||||||
id_element++;
|
id_element++;
|
||||||
String base_display = Tools.getListBaseDisplay(id_element, dependencies.size(), elem);
|
final String base_display = Tools.getListBaseDisplay(id_element, dependencies.size(), elem);
|
||||||
Log.info("dep-sync : " + base_display);
|
Log.info("dep-sync : " + base_display);
|
||||||
Log.debug("elem : " + elem);
|
Log.debug("elem : " + elem);
|
||||||
downloadPackage(artefactories, elem, alreadyDone);
|
downloadPackage(artefactories, elem, alreadyDone);
|
||||||
@ -265,7 +266,7 @@ public class DependencySync {
|
|||||||
|
|
||||||
Artifactory findArtifactory(final List<Artifactory> artefactories, final String name) {
|
Artifactory findArtifactory(final List<Artifactory> artefactories, final String name) {
|
||||||
Artifactory out = null;
|
Artifactory out = null;
|
||||||
for (Artifactory elem : artefactories) {
|
for (final Artifactory elem : artefactories) {
|
||||||
if ("default".equals(elem.getName())) {
|
if ("default".equals(elem.getName())) {
|
||||||
out = elem;
|
out = elem;
|
||||||
break;
|
break;
|
||||||
@ -275,8 +276,7 @@ public class DependencySync {
|
|||||||
if (out == null) {
|
if (out == null) {
|
||||||
out = new Artifactory("default", "https://repo1.maven.org/maven2", "maven");
|
out = new Artifactory("default", "https://repo1.maven.org/maven2", "maven");
|
||||||
}
|
}
|
||||||
boolean find = false;
|
for (final Artifactory elem : artefactories) {
|
||||||
for (Artifactory elem : artefactories) {
|
|
||||||
if (name.equals(elem.getName())) {
|
if (name.equals(elem.getName())) {
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
@ -310,38 +310,38 @@ public class DependencySync {
|
|||||||
void listFiles(final Path path) {
|
void listFiles(final Path path) {
|
||||||
Log.info("List of file in " + path);
|
Log.info("List of file in " + path);
|
||||||
try {
|
try {
|
||||||
ZipFile zipFile = new ZipFile(path.toFile());
|
final ZipFile zipFile = new ZipFile(path.toFile());
|
||||||
|
|
||||||
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
final Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||||
while (entries.hasMoreElements()) {
|
while (entries.hasMoreElements()) {
|
||||||
ZipEntry entry = entries.nextElement();
|
final ZipEntry entry = entries.nextElement();
|
||||||
Log.info(" - " + entry.getName() + " (" + entry.getSize() + ")");
|
Log.info(" - " + entry.getName() + " (" + entry.getSize() + ")");
|
||||||
//InputStream stream = zipFile.getInputStream(entry);
|
//InputStream stream = zipFile.getInputStream(entry);
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (final IOException ex) {
|
||||||
Log.error("Catch Exception : " + ex.getLocalizedMessage());
|
Log.error("Catch Exception : " + ex.getLocalizedMessage());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String readAllMatadataAndStore(final String urlPath, final Path path) throws Exception {
|
String readAllMatadataAndStore(final String urlPath, final Path path) throws Exception {
|
||||||
URL url = new URL(urlPath);
|
final URL url = new URL(urlPath);
|
||||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
final HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
con.setRequestMethod("GET");
|
con.setRequestMethod("GET");
|
||||||
con.setConnectTimeout(5000);
|
con.setConnectTimeout(5000);
|
||||||
con.setReadTimeout(5000);
|
con.setReadTimeout(5000);
|
||||||
con.setInstanceFollowRedirects(false);
|
con.setInstanceFollowRedirects(false);
|
||||||
StringBuilder result = new StringBuilder();
|
final StringBuilder result = new StringBuilder();
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
|
||||||
for (String line; (line = reader.readLine()) != null;) {
|
for (String line; (line = reader.readLine()) != null;) {
|
||||||
result.append(line);
|
result.append(line);
|
||||||
result.append("\n");
|
result.append("\n");
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (final Exception ex) {
|
||||||
Log.error("Can not retrive data from artefactory ..." + ex.getLocalizedMessage());
|
Log.error("Can not retrive data from artefactory ..." + ex.getLocalizedMessage());
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
String dataAsString = result.toString();
|
final String dataAsString = result.toString();
|
||||||
Log.verbose("return=" + dataAsString);
|
Log.verbose("return=" + dataAsString);
|
||||||
Tools.fileWriteData(path, dataAsString);
|
Tools.fileWriteData(path, dataAsString);
|
||||||
return dataAsString;
|
return dataAsString;
|
||||||
@ -354,24 +354,24 @@ public class DependencySync {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (!Files.exists(path.getParent())) {
|
if (!Files.exists(path.getParent())) {
|
||||||
File file = path.getParent().toFile();
|
final File file = path.getParent().toFile();
|
||||||
if (!file.mkdirs()) {
|
if (!file.mkdirs()) {
|
||||||
Log.critical("Can not create the path:" + path.getParent());
|
Log.critical("Can not create the path:" + path.getParent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
URL url = new URL(urlPath);
|
final URL url = new URL(urlPath);
|
||||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
final HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
con.setRequestMethod("GET");
|
con.setRequestMethod("GET");
|
||||||
con.setConnectTimeout(5000);
|
con.setConnectTimeout(5000);
|
||||||
con.setReadTimeout(5000);
|
con.setReadTimeout(5000);
|
||||||
con.setInstanceFollowRedirects(false);
|
con.setInstanceFollowRedirects(false);
|
||||||
final int BUFFER_SIZE = 1024 * 1024;
|
final int BUFFER_SIZE = 1024 * 1024;
|
||||||
InputStream inputStream = con.getInputStream();
|
final InputStream inputStream = con.getInputStream();
|
||||||
Path tmpFile = path.getParent().resolve(path.getFileName() + "__tmp");
|
final Path tmpFile = path.getParent().resolve(path.getFileName() + "__tmp");
|
||||||
FileOutputStream outputStream = new FileOutputStream(tmpFile.toFile());
|
final FileOutputStream outputStream = new FileOutputStream(tmpFile.toFile());
|
||||||
int bytesRead = -1;
|
int bytesRead = -1;
|
||||||
int totalRead = 0;
|
int totalRead = 0;
|
||||||
byte[] buffer = new byte[BUFFER_SIZE];
|
final byte[] buffer = new byte[BUFFER_SIZE];
|
||||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
outputStream.write(buffer, 0, bytesRead);
|
outputStream.write(buffer, 0, bytesRead);
|
||||||
totalRead += bytesRead;
|
totalRead += bytesRead;
|
||||||
@ -382,7 +382,7 @@ public class DependencySync {
|
|||||||
inputStream.close();
|
inputStream.close();
|
||||||
// this is the way to have atomic replacement of file and not partial downloaded file ==> move is 99.999999% atomic.
|
// this is the way to have atomic replacement of file and not partial downloaded file ==> move is 99.999999% atomic.
|
||||||
Files.move(tmpFile, path);
|
Files.move(tmpFile, path);
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (final FileNotFoundException ex) {
|
||||||
Log.warning("File not found: " + urlPath);
|
Log.warning("File not found: " + urlPath);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
|
@ -9,13 +9,14 @@ import java.util.ListIterator;
|
|||||||
import org.atriasoft.aknot.annotation.AknotList;
|
import org.atriasoft.aknot.annotation.AknotList;
|
||||||
import org.atriasoft.aknot.annotation.AknotName;
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
import org.atriasoft.aknot.exception.AknotException;
|
import org.atriasoft.aknot.exception.AknotException;
|
||||||
import org.atriasoft.exml.Exml;
|
import org.atriasoft.exml.XmlMapper;
|
||||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||||
import org.atriasoft.exml.exception.ExmlException;
|
import org.atriasoft.exml.exception.ExmlException;
|
||||||
import org.atriasoft.island.Env;
|
import org.atriasoft.island.Env;
|
||||||
import org.atriasoft.island.internal.Log;
|
import org.atriasoft.island.internal.Log;
|
||||||
import org.atriasoft.island.model.Volatile;
|
import org.atriasoft.island.model.Volatile;
|
||||||
|
|
||||||
|
@AknotName("config-island")
|
||||||
public class ConfigManifest {
|
public class ConfigManifest {
|
||||||
|
|
||||||
public static ConfigManifest load() {
|
public static ConfigManifest load() {
|
||||||
@ -23,9 +24,10 @@ public class ConfigManifest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigManifest load(final Path path) {
|
public static ConfigManifest load(final Path path) {
|
||||||
ConfigManifest[] root = null;
|
ConfigManifest root = null;
|
||||||
|
final XmlMapper mapper = new XmlMapper();
|
||||||
try {
|
try {
|
||||||
root = Exml.parse(path, ConfigManifest.class, "config-island");
|
root = mapper.parse(path, ConfigManifest.class);
|
||||||
} catch (final ExmlException e) {
|
} catch (final ExmlException e) {
|
||||||
Log.error("Can not parse the file.1. " + path);
|
Log.error("Can not parse the file.1. " + path);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -33,10 +35,7 @@ public class ConfigManifest {
|
|||||||
Log.error("Can not parse the file.2. " + path);
|
Log.error("Can not parse the file.2. " + path);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (root.length != 1) {
|
return root;
|
||||||
Log.error("Can not parse the file.3. " + path);
|
|
||||||
}
|
|
||||||
return root[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String repo = "";
|
private String repo = "";
|
||||||
@ -181,9 +180,10 @@ public class ConfigManifest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void store(final Path path) throws ExmlBuilderException {
|
public void store(final Path path) throws ExmlBuilderException {
|
||||||
|
final XmlMapper mapper = new XmlMapper();
|
||||||
try {
|
try {
|
||||||
Exml.store(path, this, "config-island");
|
mapper.store(this, path);
|
||||||
} catch (final ExmlException | IOException ex) {
|
} catch (final ExmlException | IOException | AknotException ex) {
|
||||||
Log.warning("detect throw: " + ex.getMessage());
|
Log.warning("detect throw: " + ex.getMessage());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import org.atriasoft.aknot.annotation.AknotManaged;
|
|||||||
import org.atriasoft.aknot.annotation.AknotName;
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
|
|
||||||
@AknotIgnoreUnknown
|
@AknotIgnoreUnknown
|
||||||
|
@AknotName("manifest")
|
||||||
public class ManifestFile {
|
public class ManifestFile {
|
||||||
private Path fileRealPath = null;
|
private Path fileRealPath = null;
|
||||||
private List<ProjectConfig> projects = new ArrayList<>();
|
private List<ProjectConfig> projects = new ArrayList<>();
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package org.atriasoft.island.model.maven;
|
package org.atriasoft.island.model.maven;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.annotation.AknotDefaultAttribute;
|
||||||
import org.atriasoft.aknot.annotation.AknotIgnoreUnknown;
|
import org.atriasoft.aknot.annotation.AknotIgnoreUnknown;
|
||||||
import org.atriasoft.aknot.annotation.AknotName;
|
import org.atriasoft.aknot.annotation.AknotName;
|
||||||
import org.atriasoft.aknot.annotation.AknotDefaultAttribute;
|
|
||||||
|
|
||||||
@AknotDefaultAttribute(false)
|
@AknotDefaultAttribute(false)
|
||||||
@AknotIgnoreUnknown
|
@AknotIgnoreUnknown
|
||||||
|
@AknotName("metadata")
|
||||||
public record MavenMetadata(
|
public record MavenMetadata(
|
||||||
@AknotName("groupId") String groupId,
|
@AknotName("groupId") String groupId,
|
||||||
@AknotName("artifactId") String artifactId,
|
@AknotName("artifactId") String artifactId,
|
||||||
|
@ -10,6 +10,7 @@ import org.atriasoft.aknot.annotation.AknotOptional;
|
|||||||
|
|
||||||
@AknotDefaultNullValue
|
@AknotDefaultNullValue
|
||||||
@AknotIgnoreUnknown
|
@AknotIgnoreUnknown
|
||||||
|
@AknotName("project")
|
||||||
public record PomMaven(
|
public record PomMaven(
|
||||||
@AknotName("modelVersion") String modelVersion,
|
@AknotName("modelVersion") String modelVersion,
|
||||||
@AknotName("groupId") String groupId,
|
@AknotName("groupId") String groupId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user