[DEV] add link on artefact folder and basic generation of GLD files for java dependency
This commit is contained in:
parent
381980372e
commit
db54f8d50c
45
.classpath
45
.classpath
@ -5,26 +5,6 @@
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-exml">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scenarium-logger">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-death">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-etk">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
@ -45,5 +25,30 @@
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-etk">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-death">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scenarium-logger">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-exml">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-ejson">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="out/eclipse/classes"/>
|
||||
</classpath>
|
||||
|
@ -15,4 +15,5 @@ open module org.atriasoft.island {
|
||||
requires org.atriasoft.etk;
|
||||
//requires org.eclipse.jgit;
|
||||
requires jgit.bundle;
|
||||
requires org.atriasoft.ejson;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ public class Env {
|
||||
|
||||
private static Path islandPathManifest = null;
|
||||
|
||||
private static Path islandPathArtifactoryLink = null;
|
||||
private static Path islandPathArtifactory = null;
|
||||
static {
|
||||
//String tmp = island_root_path.toAbsolutePath().toString();
|
||||
@ -66,6 +67,7 @@ public class Env {
|
||||
Env.islandPathConfig = Env.islandPath.resolve("config.xml");
|
||||
Env.islandPathManifest = Env.islandPath.resolve("manifest");
|
||||
Env.islandPathArtifactory = Env.islandPath.resolve(Env.artifactoryBaseFolder);
|
||||
Env.islandPathArtifactoryLink = Env.islandRootPath.resolve(Env.artifactoryBaseFolder);
|
||||
}
|
||||
|
||||
public static boolean getDisplayFolderInsteadOfGitName() {
|
||||
@ -88,6 +90,10 @@ public class Env {
|
||||
return Env.islandPathArtifactory;
|
||||
}
|
||||
|
||||
public static Path getIslandPathArtifactoryLink() {
|
||||
return Env.islandPathArtifactoryLink;
|
||||
}
|
||||
|
||||
public static Path getIslandPathConfig() {
|
||||
return Env.islandPathConfig;
|
||||
}
|
||||
@ -121,12 +127,13 @@ public class Env {
|
||||
}
|
||||
|
||||
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());
|
||||
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());
|
||||
Log.error("islandPathArtifactoryLink = {}", Env.islandPathArtifactoryLink.toAbsolutePath());
|
||||
}
|
||||
|
||||
public static boolean needProcessWithFilter(final String data) {
|
||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -15,20 +16,6 @@ import org.atriasoft.island.model.manifest.ProjectConfig;
|
||||
|
||||
public class Tools {
|
||||
|
||||
|
||||
public static String getListBaseDisplay(final int id, final int count, final ProjectConfig elem) {
|
||||
if (!Env.getDisplayFolderInsteadOfGitName()) {
|
||||
return id + "/" + count + " : " + elem.getName();
|
||||
}
|
||||
return id + "/" + count + " : " + elem.getPath();
|
||||
}
|
||||
public static String getListBaseDisplay(final int id, final int count, final Dependency elem) {
|
||||
if (!Env.getDisplayFolderInsteadOfGitName()) {
|
||||
return id + "/" + count + " : " + elem.name();
|
||||
}
|
||||
return id + "/" + count + " : " + elem.name();
|
||||
}
|
||||
|
||||
public static void createDirectory(final Path basePath) {
|
||||
Path absPath = basePath.toAbsolutePath();
|
||||
if (!Files.exists(absPath)) {
|
||||
@ -42,19 +29,58 @@ public class Tools {
|
||||
}
|
||||
}
|
||||
|
||||
public static void waitForServerIfNeeded() {
|
||||
int waitTime = Env.getWaitBetweenSeverCommand();
|
||||
if (waitTime>0) {
|
||||
Log.info("Waiting between commands: " + waitTime + "s");
|
||||
public static void createSymbolicLink(Path link, Path target) throws IOException {
|
||||
Log.warning("create Link {} -> {}", link, target);
|
||||
createDirectory(link.getParent());
|
||||
if (Files.exists(link)) {
|
||||
Files.delete(link);
|
||||
}
|
||||
Files.createSymbolicLink(link, target);
|
||||
}
|
||||
|
||||
public static void fileWriteData(final Path path, final String data) {
|
||||
|
||||
Path tmpFile = path.getParent().resolve(path.getFileName() + "__tmp");
|
||||
if (!Files.exists(path.getParent())) {
|
||||
File file = path.getParent().toFile();
|
||||
if (!file.mkdirs()) {
|
||||
Log.critical("Can not create the path:" + path.getParent());
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(waitTime*1000);
|
||||
} catch (InterruptedException e) {
|
||||
Files.writeString(tmpFile, data);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// this is the way to have atomic replacement of file and not partial downloaded file ==> move is 99.999999% atomic.
|
||||
try {
|
||||
Files.move(tmpFile, path, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
|
||||
} catch (IOException e) {
|
||||
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getListBaseDisplay(final int id, final int count, final Dependency elem) {
|
||||
if (!Env.getDisplayFolderInsteadOfGitName()) {
|
||||
return id + "/" + count + " : " + elem.name();
|
||||
}
|
||||
return id + "/" + count + " : " + elem.name();
|
||||
}
|
||||
|
||||
public static String getListBaseDisplay(final int id, final int count, final ProjectConfig elem) {
|
||||
if (!Env.getDisplayFolderInsteadOfGitName()) {
|
||||
return id + "/" + count + " : " + elem.getName();
|
||||
}
|
||||
return id + "/" + count + " : " + elem.getPath();
|
||||
}
|
||||
|
||||
public static String getPlural(final List<?> artefactories) {
|
||||
return artefactories.size() > 1 ? "ies" : "y";
|
||||
}
|
||||
|
||||
public static String readFile(final Path path, final Charset encoding) throws IOException {
|
||||
byte[] encoded = Files.readAllBytes(path);
|
||||
return new String(encoded, encoding);
|
||||
@ -100,33 +126,18 @@ public class Tools {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void fileWriteData(final Path path, final String data) {
|
||||
|
||||
Path tmpFile = path.getParent().resolve(path.getFileName()+"__tmp");
|
||||
if (!Files.exists(path.getParent())) {
|
||||
File file = path.getParent().toFile();
|
||||
if (!file.mkdirs()) {
|
||||
Log.critical("Can not create the path:" + path.getParent());
|
||||
}
|
||||
}
|
||||
public static void waitForServerIfNeeded() {
|
||||
int waitTime = Env.getWaitBetweenSeverCommand();
|
||||
if (waitTime > 0) {
|
||||
Log.info("Waiting between commands: " + waitTime + "s");
|
||||
try {
|
||||
Files.writeString(tmpFile, data);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// this is the way to have atomic replacement of file and not partial downloaded file ==> move is 99.999999% atomic.
|
||||
try {
|
||||
Files.move(tmpFile, path);
|
||||
} catch (IOException e) {
|
||||
|
||||
Thread.sleep(waitTime * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPlural(final List<?> artefactories) {
|
||||
return artefactories.size() > 1 ? "ies" : "y";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,10 @@ import org.atriasoft.death.annotation.ArgDescription;
|
||||
import org.atriasoft.death.annotation.ArgExecute;
|
||||
import org.atriasoft.death.annotation.ArgName;
|
||||
import org.atriasoft.death.annotation.ArgSample;
|
||||
import org.atriasoft.ejson.Ejson;
|
||||
import org.atriasoft.ejson.model.JsonArray;
|
||||
import org.atriasoft.ejson.model.JsonObject;
|
||||
import org.atriasoft.ejson.model.JsonString;
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.exception.ExmlException;
|
||||
import org.atriasoft.island.Config;
|
||||
@ -30,6 +34,7 @@ import org.atriasoft.island.Manifest;
|
||||
import org.atriasoft.island.Tools;
|
||||
import org.atriasoft.island.internal.Log;
|
||||
import org.atriasoft.island.model.ActionException;
|
||||
import org.atriasoft.island.model.GLDDependModel;
|
||||
import org.atriasoft.island.model.manifest.Artifactory;
|
||||
import org.atriasoft.island.model.manifest.ConfigManifest;
|
||||
import org.atriasoft.island.model.manifest.Dependency;
|
||||
@ -42,6 +47,13 @@ import org.atriasoft.island.model.maven.PomMaven;
|
||||
@ArgSample("depend-sync")
|
||||
public class DependencySync {
|
||||
|
||||
private class UpdateDependency {
|
||||
public Dependency dependency;
|
||||
public List<String> download = new ArrayList<>();
|
||||
}
|
||||
|
||||
private static final String MAVEN_METADATA = "maven-metadata.xml";
|
||||
|
||||
@ArgName("doc")
|
||||
@ArgDescription("enable download of the documentation")
|
||||
public boolean documentation = false;
|
||||
@ -50,39 +62,21 @@ public class DependencySync {
|
||||
@ArgDescription("enable download of the sources")
|
||||
public boolean sources = false;
|
||||
|
||||
|
||||
|
||||
|
||||
private static final String MAVEN_METADATA = "maven-metadata.xml";
|
||||
|
||||
Artifactory findArtifactory(final List<Artifactory> artefactories, final String name) {
|
||||
Artifactory out = null;
|
||||
for (Artifactory elem: artefactories) {
|
||||
if ("default".equals(elem.getName())) {
|
||||
out = elem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// By default we are capable to use maven artefactory (can be replace with using "default" name).
|
||||
if (out == null) {
|
||||
out = new Artifactory("default", "https://repo1.maven.org/maven2", "maven");
|
||||
}
|
||||
boolean find = false;
|
||||
for (Artifactory elem: artefactories) {
|
||||
if (name.equals(elem.getName())) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
Log.error("Can not find the remote '" + name + "'artefactory in the list ==> fallback to 'default'");
|
||||
return out;
|
||||
public Path createArtefactLinkFileName(final String fileName) {
|
||||
Path outPath = Env.getIslandPathArtifactoryLink().resolve(fileName);
|
||||
return outPath;
|
||||
}
|
||||
|
||||
public String createMavenMetadataRemoteFileName(final List<Artifactory> artefactories, final Dependency dependency) {
|
||||
return createBasePkgRemoteFileName(artefactories, dependency, DependencySync.MAVEN_METADATA);
|
||||
public Path createArtefactLinkGLDFile(final String fileName) {
|
||||
Path outPath = Env.getIslandPathArtifactoryLink().resolve("GLD_" + fileName + ".json");
|
||||
return outPath;
|
||||
}
|
||||
|
||||
public Path createMetadataLocalFileName(final List<Artifactory> artefactories, final Dependency dependency) {
|
||||
return createBasePkgLocalFileName(artefactories, dependency, DependencySync.MAVEN_METADATA);
|
||||
public Path createBasePkgLocalFileName(final List<Artifactory> artefactories, final Dependency dependency, final String version) {
|
||||
Artifactory artifactory = findArtifactory(artefactories, dependency.remote());
|
||||
String out = artifactory.getName() + "/" + dependency.org().replace(".", "/") + "/" + dependency.name() + "/" + version;
|
||||
Path outPath = Env.getIslandPathArtifactory().resolve(out);
|
||||
return outPath;
|
||||
}
|
||||
|
||||
public String createBasePkgRemoteFileName(final List<Artifactory> artefactories, final Dependency dependency, final String version) {
|
||||
@ -95,42 +89,58 @@ public class DependencySync {
|
||||
return out;
|
||||
}
|
||||
|
||||
public Path createBasePkgLocalFileName(final List<Artifactory> artefactories, final Dependency dependency, final String version) {
|
||||
Artifactory artifactory = findArtifactory(artefactories, dependency.remote());
|
||||
String out = artifactory.getName() + "/" + dependency.org().replace(".", "/") + "/" + dependency.name() + "/" + version;
|
||||
Path outPath = Env.getIslandPathArtifactory().resolve(out);
|
||||
return outPath;
|
||||
private void createGLDFile(PomMaven mavenPom, Path createArtefactLinkGLDFile, Path artefactLink) {
|
||||
GLDDependModel model = new GLDDependModel();
|
||||
model.path.java.add(artefactLink.getFileName().toString());
|
||||
model.groupId = mavenPom.groupId();
|
||||
model.version = mavenPom.version();
|
||||
if (mavenPom.dependencies() != null) {
|
||||
for (PomDependency elem : mavenPom.dependencies()) {
|
||||
model.dependency.add(elem.artifactId());
|
||||
}
|
||||
}
|
||||
// TODO: for later : create a generic serializer ...
|
||||
StringBuilder data = new StringBuilder();
|
||||
JsonObject root = new JsonObject();
|
||||
root.put("type", new JsonString(model.type));
|
||||
root.put("group-id", new JsonString(model.groupId));
|
||||
root.put("version", new JsonString(model.version));
|
||||
JsonObject path = new JsonObject();
|
||||
root.put("path", path);
|
||||
JsonArray java = new JsonArray();
|
||||
for (String elem : model.path.java) {
|
||||
java.add(new JsonString(elem));
|
||||
}
|
||||
path.put("java", java);
|
||||
JsonArray dep = new JsonArray();
|
||||
for (String elem : model.dependency) {
|
||||
dep.add(new JsonString(elem));
|
||||
}
|
||||
root.put("dependency", dep);
|
||||
Ejson.generate(root, data);
|
||||
//Log.error("generated GLD dependency : {}", data.toString());
|
||||
//Log.error(" ==> {}", createArtefactLinkGLDFile.toString());
|
||||
//Log.error(" --> {}", artefactLink.toString());
|
||||
Tools.fileWriteData(createArtefactLinkGLDFile, data.toString());
|
||||
}
|
||||
|
||||
void createLinkOnArtefact(final Path path, final String baseName) throws Exception {
|
||||
// remove previous file in the link area:
|
||||
Tools.createSymbolicLink(createArtefactLinkFileName(baseName), path);
|
||||
}
|
||||
|
||||
// this is the maven module interface
|
||||
public String getPomFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + ".pom";
|
||||
public String createMavenMetadataRemoteFileName(final List<Artifactory> artefactories, final Dependency dependency) {
|
||||
return createBasePkgRemoteFileName(artefactories, dependency, DependencySync.MAVEN_METADATA);
|
||||
}
|
||||
public String getJavaPackageFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + ".jar";
|
||||
}
|
||||
public String getJavaDocFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + "-javadoc.jar";
|
||||
}
|
||||
public String getJavaSourceFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + "-sources.jar";
|
||||
}
|
||||
// This is the gradle module interface
|
||||
public String getModuleFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + ".module";
|
||||
}
|
||||
private class UpdateDependency {
|
||||
public Dependency dependency;
|
||||
public List<String> download = new ArrayList<>();
|
||||
|
||||
public Path createMetadataLocalFileName(final List<Artifactory> artefactories, final Dependency dependency) {
|
||||
return createBasePkgLocalFileName(artefactories, dependency, DependencySync.MAVEN_METADATA);
|
||||
}
|
||||
|
||||
private void downloadPackage(final List<Artifactory> artefactories, final Dependency dependency, final List<UpdateDependency> alreadyDone) throws Exception {
|
||||
Log.debug("download : " + dependency);
|
||||
for (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
|
||||
for (String version : elem.download) {
|
||||
if (version.equals(dependency.revision())) {
|
||||
@ -142,10 +152,10 @@ public class DependencySync {
|
||||
}
|
||||
|
||||
String metadataFile = createMavenMetadataRemoteFileName(artefactories, dependency);
|
||||
Log.print("Metadata position: " + metadataFile);
|
||||
Log.verbose("Metadata position: " + metadataFile);
|
||||
Path localPath = createMetadataLocalFileName(artefactories, dependency);
|
||||
String dataAsString = readAllMatadataAndStore(metadataFile, localPath);
|
||||
Log.print("dataAsString: " + dataAsString);
|
||||
Log.verbose("dataAsString: " + dataAsString);
|
||||
MavenMetadata metaData = null;
|
||||
try {
|
||||
metaData = Exml.parseOne(dataAsString, MavenMetadata.class, "metadata");
|
||||
@ -173,9 +183,16 @@ public class DependencySync {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// retrieve binary
|
||||
base = getJavaPackageFileName(dependency, lastReleaseTag);
|
||||
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
|
||||
// TODO: If Zip artefact this mean we need to uncompress it.
|
||||
createLinkOnArtefact(localPackageFileName.resolve(base), base);
|
||||
// create the GLD file with maven dependency
|
||||
|
||||
createGLDFile(mavenPom, createArtefactLinkGLDFile(mavenPom.artifactId()), createArtefactLinkFileName(base));
|
||||
|
||||
// listFiles(localPackageFileName.resolve(base));
|
||||
// retrieve javadoc
|
||||
if (this.documentation) {
|
||||
@ -194,9 +211,7 @@ public class DependencySync {
|
||||
*/
|
||||
boolean find = false;
|
||||
for (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
|
||||
elem.download.add(dependency.revision());
|
||||
find = true;
|
||||
@ -216,6 +231,7 @@ public class DependencySync {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ArgExecute
|
||||
public void execute() throws ActionException, Exception {
|
||||
List<UpdateDependency> alreadyDone = new ArrayList<>();
|
||||
@ -247,6 +263,67 @@ public class DependencySync {
|
||||
Log.print("Dependency sync END");
|
||||
}
|
||||
|
||||
Artifactory findArtifactory(final List<Artifactory> artefactories, final String name) {
|
||||
Artifactory out = null;
|
||||
for (Artifactory elem : artefactories) {
|
||||
if ("default".equals(elem.getName())) {
|
||||
out = elem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// By default we are capable to use maven artefactory (can be replace with using "default" name).
|
||||
if (out == null) {
|
||||
out = new Artifactory("default", "https://repo1.maven.org/maven2", "maven");
|
||||
}
|
||||
boolean find = false;
|
||||
for (Artifactory elem : artefactories) {
|
||||
if (name.equals(elem.getName())) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
Log.error("Can not find the remote '" + name + "'artefactory in the list ==> fallback to 'default'");
|
||||
return out;
|
||||
}
|
||||
|
||||
public String getJavaDocFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + "-javadoc.jar";
|
||||
}
|
||||
|
||||
public String getJavaPackageFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + ".jar";
|
||||
}
|
||||
|
||||
public String getJavaSourceFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + "-sources.jar";
|
||||
}
|
||||
|
||||
// This is the gradle module interface
|
||||
public String getModuleFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + ".module";
|
||||
}
|
||||
|
||||
// this is the maven module interface
|
||||
public String getPomFileName(final Dependency dependency, final String version) {
|
||||
return dependency.name() + "-" + version + ".pom";
|
||||
}
|
||||
|
||||
void listFiles(final Path path) {
|
||||
Log.info("List of file in " + path);
|
||||
try {
|
||||
ZipFile zipFile = new ZipFile(path.toFile());
|
||||
|
||||
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry entry = entries.nextElement();
|
||||
Log.info(" - " + entry.getName() + " (" + entry.getSize() + ")");
|
||||
//InputStream stream = zipFile.getInputStream(entry);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Log.error("Catch Exception : " + ex.getLocalizedMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
String readAllMatadataAndStore(final String urlPath, final Path path) throws Exception {
|
||||
URL url = new URL(urlPath);
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
@ -265,7 +342,7 @@ public class DependencySync {
|
||||
throw ex;
|
||||
}
|
||||
String dataAsString = result.toString();
|
||||
Log.print("return=" + dataAsString);
|
||||
Log.verbose("return=" + dataAsString);
|
||||
Tools.fileWriteData(path, dataAsString);
|
||||
return dataAsString;
|
||||
}
|
||||
@ -289,7 +366,6 @@ public class DependencySync {
|
||||
con.setReadTimeout(5000);
|
||||
con.setInstanceFollowRedirects(false);
|
||||
final int BUFFER_SIZE = 1024 * 1024;
|
||||
StringBuilder result = new StringBuilder();
|
||||
InputStream inputStream = con.getInputStream();
|
||||
Path tmpFile = path.getParent().resolve(path.getFileName() + "__tmp");
|
||||
FileOutputStream outputStream = new FileOutputStream(tmpFile.toFile());
|
||||
@ -312,22 +388,4 @@ public class DependencySync {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void listFiles(final Path path) {
|
||||
Log.info("List of file in " + path);
|
||||
try {
|
||||
ZipFile zipFile = new ZipFile(path.toFile());
|
||||
|
||||
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||
while(entries.hasMoreElements()){
|
||||
ZipEntry entry = entries.nextElement();
|
||||
Log.info(" - " + entry.getName() + " (" + entry.getSize() + ")");
|
||||
//InputStream stream = zipFile.getInputStream(entry);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Log.error("Catch Exception : " + ex.getLocalizedMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,12 +16,6 @@ public class Log {
|
||||
private static final boolean PRINT_TODO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.TODO);
|
||||
private static final boolean PRINT_PRINT = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.PRINT);
|
||||
|
||||
public static void critical(final String data) {
|
||||
if (Log.PRINT_CRITICAL || Log.FORCE) {
|
||||
Logger.critical(Log.LIB_NAME_DRAW, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void critical(final String data, final Exception e) {
|
||||
e.printStackTrace();
|
||||
if (Log.PRINT_CRITICAL || Log.FORCE) {
|
||||
@ -29,45 +23,51 @@ public class Log {
|
||||
}
|
||||
}
|
||||
|
||||
public static void debug(final String data) {
|
||||
public static void critical(final String data, Object... objects) {
|
||||
if (Log.PRINT_CRITICAL || Log.FORCE) {
|
||||
Logger.critical(Log.LIB_NAME_DRAW, data, objects);
|
||||
}
|
||||
}
|
||||
|
||||
public static void debug(final String data, Object... objects) {
|
||||
if (Log.PRINT_DEBUG || Log.FORCE) {
|
||||
Logger.debug(Log.LIB_NAME_DRAW, data);
|
||||
Logger.debug(Log.LIB_NAME_DRAW, data, objects);
|
||||
}
|
||||
}
|
||||
|
||||
public static void error(final String data) {
|
||||
public static void error(final String data, Object... objects) {
|
||||
if (Log.PRINT_ERROR || Log.FORCE) {
|
||||
Logger.error(Log.LIB_NAME_DRAW, data);
|
||||
Logger.error(Log.LIB_NAME_DRAW, data, objects);
|
||||
}
|
||||
}
|
||||
|
||||
public static void info(final String data) {
|
||||
public static void info(final String data, Object... objects) {
|
||||
if (Log.PRINT_INFO || Log.FORCE) {
|
||||
Logger.info(Log.LIB_NAME_DRAW, data);
|
||||
Logger.info(Log.LIB_NAME_DRAW, data, objects);
|
||||
}
|
||||
}
|
||||
|
||||
public static void print(final String data) {
|
||||
public static void print(final String data, Object... objects) {
|
||||
if (Log.PRINT_PRINT || Log.FORCE) {
|
||||
System.out.println(data);
|
||||
Logger.print(Log.LIB_NAME_DRAW, data, objects);
|
||||
}
|
||||
}
|
||||
|
||||
public static void todo(final String data) {
|
||||
public static void todo(final String data, Object... objects) {
|
||||
if (Log.PRINT_TODO || Log.FORCE) {
|
||||
Logger.todo(Log.LIB_NAME_DRAW, data);
|
||||
Logger.todo(Log.LIB_NAME_DRAW, data, objects);
|
||||
}
|
||||
}
|
||||
|
||||
public static void verbose(final String data) {
|
||||
public static void verbose(final String data, Object... objects) {
|
||||
if (Log.PRINT_VERBOSE || Log.FORCE) {
|
||||
Logger.verbose(Log.LIB_NAME_DRAW, data);
|
||||
Logger.verbose(Log.LIB_NAME_DRAW, data, objects);
|
||||
}
|
||||
}
|
||||
|
||||
public static void warning(final String data) {
|
||||
public static void warning(final String data, Object... objects) {
|
||||
if (Log.PRINT_WARNING || Log.FORCE) {
|
||||
Logger.warning(Log.LIB_NAME_DRAW, data);
|
||||
Logger.warning(Log.LIB_NAME_DRAW, data, objects);
|
||||
}
|
||||
}
|
||||
|
||||
|
17
src/org/atriasoft/island/model/GLDDependModel.java
Normal file
17
src/org/atriasoft/island/model/GLDDependModel.java
Normal file
@ -0,0 +1,17 @@
|
||||
package org.atriasoft.island.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.aknot.annotation.AknotName;
|
||||
|
||||
public class GLDDependModel {
|
||||
public String type = "LIBRARY";
|
||||
@AknotName("group-id")
|
||||
public String groupId;
|
||||
public String version;
|
||||
public GLDDependPathModel path = new GLDDependPathModel();
|
||||
public List<String> dependency = new ArrayList<>();
|
||||
@AknotName("dependency-build")
|
||||
public List<String> dependencyBuild = new ArrayList<>();
|
||||
}
|
8
src/org/atriasoft/island/model/GLDDependPathModel.java
Normal file
8
src/org/atriasoft/island/model/GLDDependPathModel.java
Normal file
@ -0,0 +1,8 @@
|
||||
package org.atriasoft.island.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GLDDependPathModel {
|
||||
public List<String> java = new ArrayList<>();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user