+++ /dev/null
-package org.argeo.slc;
-
-/**
- * Adds a dimension to {@link NameVersion} by adding an arbitrary category (e.g.
- * Maven groupId, yum repository ID, etc.)
- */
-public interface CategorizedNameVersion extends NameVersion {
- /** The category of the component. */
- String getCategory();
-
- static CategorizedNameVersion parseCategoryNameVersion(String str) {
- if (str == null || "".equals(str.trim()))
- throw new IllegalArgumentException("At least one character required.");
- String[] arr = str.trim().split(":");
- if (arr.length > 3)
- throw new IllegalArgumentException(str + " does not respect the [category]:[name]:[version] pattern");
- DefaultCategorizedNameVersion res = new DefaultCategorizedNameVersion();
- res.setCategory(arr[0]);
- if (arr.length > 1)
- res.setName(arr[1]);
- if (arr.length > 2)
- res.setVersion(arr[2]);
- return res;
- }
-}
--- /dev/null
+package org.argeo.slc;
+
+/**
+ * Adds a dimension to {@link NameVersion} by adding an arbitrary category (e.g.
+ * Maven groupId, yum repository ID, etc.)
+ */
+public interface CategoryNameVersion extends NameVersion {
+ /** The category of the component. */
+ String getCategory();
+
+ static CategoryNameVersion parseCategoryNameVersion(String str) {
+ if (str == null || "".equals(str.trim()))
+ throw new IllegalArgumentException("At least one character required.");
+ String[] arr = str.trim().split(":");
+ if (arr.length > 3)
+ throw new IllegalArgumentException(str + " does not respect the [category]:[name]:[version] pattern");
+ DefaultCategoryNameVersion res = new DefaultCategoryNameVersion();
+ res.setCategory(arr[0]);
+ if (arr.length > 1)
+ res.setName(arr[1]);
+ if (arr.length > 2)
+ res.setVersion(arr[2]);
+ return res;
+ }
+}
+++ /dev/null
-package org.argeo.slc;
-
-/** Canonical implementation of {@link CategorizedNameVersion} */
-public class DefaultCategorizedNameVersion extends DefaultNameVersion implements CategorizedNameVersion {
- private String category;
-
- public DefaultCategorizedNameVersion() {
- }
-
- public DefaultCategorizedNameVersion(String category, String name, String version) {
- super(name, version);
- this.category = category;
- }
-
- public DefaultCategorizedNameVersion(String category, NameVersion nameVersion) {
- super(nameVersion);
- this.category = category;
- }
-
- @Override
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- @Override
- public String toString() {
- return category + ":" + super.toString();
- }
-
-}
--- /dev/null
+package org.argeo.slc;
+
+/** Canonical implementation of {@link CategoryNameVersion} */
+public class DefaultCategoryNameVersion extends DefaultNameVersion implements CategoryNameVersion {
+ private String category;
+
+ public DefaultCategoryNameVersion() {
+ }
+
+ public DefaultCategoryNameVersion(String category, String name, String version) {
+ super(name, version);
+ this.category = category;
+ }
+
+ public DefaultCategoryNameVersion(String category, NameVersion nameVersion) {
+ super(nameVersion);
+ this.category = category;
+ }
+
+ @Override
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ @Override
+ public String toString() {
+ return category + ":" + super.toString();
+ }
+
+}
package org.argeo.slc.repo;
-import org.argeo.slc.CategorizedNameVersion;
+import org.argeo.slc.CategoryNameVersion;
import org.argeo.slc.build.Distribution;
import org.argeo.slc.build.ModularDistribution;
/** Aether compatible OSGi distribution */
public interface ArgeoOsgiDistribution extends Distribution,
- CategorizedNameVersion, ModularDistribution {
+ CategoryNameVersion, ModularDistribution {
}
package org.argeo.slc.repo;
-import org.argeo.slc.CategorizedNameVersion;
+import org.argeo.slc.CategoryNameVersion;
import org.argeo.slc.build.Distribution;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
/** A {@link Distribution} based on an Aether {@link Artifact} */
public class ArtifactDistribution implements Distribution,
- CategorizedNameVersion {
+ CategoryNameVersion {
private final Artifact artifact;
public ArtifactDistribution(Artifact artifact) {
@Override
public boolean equals(Object obj) {
- if (obj instanceof CategorizedNameVersion) {
- CategorizedNameVersion cnv = (CategorizedNameVersion) obj;
+ if (obj instanceof CategoryNameVersion) {
+ CategoryNameVersion cnv = (CategoryNameVersion) obj;
return getCategory().equals(cnv.getCategory())
&& getName().equals(cnv.getName())
&& getVersion().equals(cnv.getVersion());
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.CategorizedNameVersion;
+import org.argeo.slc.CategoryNameVersion;
import org.argeo.slc.NameVersion;
import org.argeo.slc.SlcException;
import org.eclipse.aether.artifact.Artifact;
b.append("<dependencies>\n");
for (Iterator<? extends NameVersion> it = osgiDistribution.nameVersions(); it.hasNext();) {
NameVersion nameVersion = it.next();
- if (!(nameVersion instanceof CategorizedNameVersion))
+ if (!(nameVersion instanceof CategoryNameVersion))
throw new SlcException("Unsupported type " + nameVersion.getClass());
- CategorizedNameVersion nv = (CategorizedNameVersion) nameVersion;
+ CategoryNameVersion nv = (CategoryNameVersion) nameVersion;
b.append(getDependencySnippet(nv, false));
}
b.append("</dependencies>\n");
b.append("<dependencies>\n");
for (Iterator<? extends NameVersion> it = osgiDistribution.nameVersions(); it.hasNext();)
- b.append(getDependencySnippet((CategorizedNameVersion) it.next(), true));
+ b.append(getDependencySnippet((CategoryNameVersion) it.next(), true));
b.append("</dependencies>\n");
b.append("</dependencyManagement>\n");
return b.toString().getBytes();
}
- private String getDependencySnippet(CategorizedNameVersion cnv, boolean includeVersion) { // , String type, String
+ private String getDependencySnippet(CategoryNameVersion cnv, boolean includeVersion) { // , String type, String
// scope
StringBuilder b = new StringBuilder();
b.append("<dependency>\n");
}
private String getCsvLine(NameVersion nameVersion) throws RepositoryException {
- if (!(nameVersion instanceof CategorizedNameVersion))
+ if (!(nameVersion instanceof CategoryNameVersion))
throw new SlcException("Unsupported type " + nameVersion.getClass());
- CategorizedNameVersion cnv = (CategorizedNameVersion) nameVersion;
+ CategoryNameVersion cnv = (CategoryNameVersion) nameVersion;
StringBuilder builder = new StringBuilder();
builder.append(cnv.getName());
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.CategorizedNameVersion;
-import org.argeo.slc.DefaultCategorizedNameVersion;
+import org.argeo.slc.CategoryNameVersion;
+import org.argeo.slc.DefaultCategoryNameVersion;
import org.argeo.slc.NameVersion;
import org.argeo.slc.SlcException;
import org.argeo.slc.SlcNames;
// Helpers
private Node addModule(Node modules, NameVersion nameVersion) throws RepositoryException {
- CategorizedNameVersion cnv = (CategorizedNameVersion) nameVersion;
+ CategoryNameVersion cnv = (CategoryNameVersion) nameVersion;
Node moduleCoord = null;
moduleCoord = modules.addNode(cnv.getName(), SlcTypes.SLC_MODULE_COORDINATES);
moduleCoord.setProperty(SlcNames.SLC_CATEGORY, cnv.getCategory());
try {
jarIn = new JarInputStream(fileBinary.getStream());
- List<CategorizedNameVersion> modules = new ArrayList<CategorizedNameVersion>();
+ List<CategoryNameVersion> modules = new ArrayList<CategoryNameVersion>();
// meta data
manifest = jarIn.getManifest();
st.nextToken(); // moduleVersion
String relativeUrl = st.nextToken();
Artifact currModule = AetherUtils.convertPathToArtifact(relativeUrl, null);
- modules.add(new DefaultCategorizedNameVersion(currModule.getGroupId(), currModule.getArtifactId(),
+ modules.add(new DefaultCategoryNameVersion(currModule.getGroupId(), currModule.getArtifactId(),
currModule.getVersion()));
}
return new MyModularDistribution(distribution, modules);
*/
private class MyModularDistribution extends ArtifactDistribution implements ArgeoOsgiDistribution {
- private List<CategorizedNameVersion> modules;
+ private List<CategoryNameVersion> modules;
- public MyModularDistribution(Artifact artifact, List<CategorizedNameVersion> modules) {
+ public MyModularDistribution(Artifact artifact, List<CategoryNameVersion> modules) {
super(artifact);
this.modules = modules;
}
- public Iterator<CategorizedNameVersion> nameVersions() {
+ public Iterator<CategoryNameVersion> nameVersions() {
return modules.iterator();
}
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.CategorizedNameVersion;
+import org.argeo.slc.CategoryNameVersion;
import org.argeo.slc.DefaultNameVersion;
import org.argeo.slc.ModuleSet;
import org.argeo.slc.NameVersion;
@SuppressWarnings("resource")
protected Iterator<? extends NameVersion> osgiNameVersions() {
- List<CategorizedNameVersion> nvs = new ArrayList<CategorizedNameVersion>();
+ List<CategoryNameVersion> nvs = new ArrayList<CategoryNameVersion>();
Session distSession = null;
ZipInputStream zin = null;
if (nv != null) {
if (nv.getName().endsWith(".source"))
continue entries;
- CategorizedNameVersion cnv = new OsgiCategorizedNV(groupId, nv.getName(), nv.getVersion(),
+ CategoryNameVersion cnv = new ArchiveWrapperCNV(groupId, nv.getName(), nv.getVersion(),
this);
nvs.add(cnv);
// no need to process further includes
--- /dev/null
+package org.argeo.slc.repo.osgi;
+
+import org.argeo.slc.DefaultCategoryNameVersion;
+
+/** A module within an archive. */
+public class ArchiveWrapperCNV extends DefaultCategoryNameVersion implements Runnable {
+ /** Build runnable */
+ private ArchiveWrapper build;
+
+ public ArchiveWrapperCNV(String category, String name, String version, ArchiveWrapper build) {
+ super(category, name, version);
+ this.build = build;
+ }
+
+ @Override
+ public void run() {
+ if (build != null)
+ build.run();
+ }
+
+ public ArchiveWrapper getBuild() {
+ return build;
+ }
+
+}
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.CategorizedNameVersion;
+import org.argeo.slc.CategoryNameVersion;
import org.argeo.slc.ModuleSet;
import org.argeo.slc.NameVersion;
import org.argeo.slc.build.Distribution;
str = str + "\t(Maven)";
else if (nv instanceof UriWrapper)
str = str + "\t(URI)";
- else if (nv instanceof OsgiCategorizedNV)
+ else if (nv instanceof ArchiveWrapperCNV)
str = str + "\t(OSGi from archive)";
else if (nv instanceof BndWrapper)
str = str + "\t(Plain BND from archive)";
while (nvIt.hasNext()) {
NameVersion nv = nvIt.next();
try {
- if (nv instanceof CategorizedNameVersion) {
- CategorizedNameVersion cnv = (CategorizedNameVersion) nv;
+ if (nv instanceof CategoryNameVersion) {
+ CategoryNameVersion cnv = (CategoryNameVersion) nv;
// TODO add branch?
Path categoryBase = baseDir.resolve(cnv.getCategory());
Files.createDirectories(categoryBase);
if (log.isTraceEnabled())
log.trace("Wrote " + bndPath);
}
- } else if (cnv instanceof OsgiCategorizedNV) {
- OsgiCategorizedNV onv = (OsgiCategorizedNV) cnv;
+ } else if (cnv instanceof ArchiveWrapperCNV) {
+ ArchiveWrapperCNV onv = (ArchiveWrapperCNV) cnv;
ArchiveWrapper aw = onv.getBuild();
archiveWrappers.add(aw);
// TODO specify and implement archive wrapper support
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.CategorizedNameVersion;
+import org.argeo.slc.CategoryNameVersion;
import org.argeo.slc.SlcException;
import org.argeo.slc.build.Distribution;
import org.argeo.slc.build.License;
import aQute.bnd.osgi.Jar;
/** Utilities around the BND library, which manipulates OSGi metadata. */
-public class BndWrapper implements Constants, CategorizedNameVersion, Distribution, BeanNameAware {
+public class BndWrapper implements Constants, CategoryNameVersion, Distribution, BeanNameAware {
private final static Log log = LogFactory.getLog(BndWrapper.class);
private String groupId;
@Override
public boolean equals(Object obj) {
- if (obj instanceof CategorizedNameVersion) {
- CategorizedNameVersion cnv = (CategorizedNameVersion) obj;
+ if (obj instanceof CategoryNameVersion) {
+ CategoryNameVersion cnv = (CategoryNameVersion) obj;
return getCategory().equals(cnv.getCategory()) && getName().equals(cnv.getName())
&& getVersion().equals(cnv.getVersion());
} else
+++ /dev/null
-package org.argeo.slc.repo.osgi;
-
-import org.argeo.slc.DefaultCategorizedNameVersion;
-
-/** */
-class OsgiCategorizedNV extends DefaultCategorizedNameVersion implements Runnable {
- /** Build runnable */
- private ArchiveWrapper build;
-
- public OsgiCategorizedNV(String category, String name, String version, ArchiveWrapper build) {
- super(category, name, version);
- this.build = build;
- }
-
- @Override
- public void run() {
- if (build != null)
- build.run();
- }
-
- public ArchiveWrapper getBuild() {
- return build;
- }
-
-}
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.CategorizedNameVersion;
+import org.argeo.slc.CategoryNameVersion;
import org.argeo.slc.NameVersion;
import org.argeo.slc.SlcException;
import org.argeo.slc.repo.ArgeoOsgiDistribution;
// Check sources
for (Iterator<? extends NameVersion> it = osgiDistribution
.nameVersions(); it.hasNext();) {
- CategorizedNameVersion nv = (CategorizedNameVersion) it.next();
+ CategoryNameVersion nv = (CategoryNameVersion) it.next();
Artifact artifact = new DefaultArtifact(nv.getCategory(),
nv.getName() + ".source", "jar", nv.getVersion());
String path = MavenConventionsUtils.artifactPath("/", artifact);
NameVersion nameVersion) throws RepositoryException {
if (log.isTraceEnabled())
log.trace("Check " + nameVersion + "...");
- if (!(nameVersion instanceof CategorizedNameVersion))
+ if (!(nameVersion instanceof CategoryNameVersion))
throw new SlcException("Unsupported type " + nameVersion.getClass());
- CategorizedNameVersion nv = (CategorizedNameVersion) nameVersion;
+ CategoryNameVersion nv = (CategoryNameVersion) nameVersion;
Artifact artifact = new DefaultArtifact(nv.getCategory(), nv.getName(),
"jar", nv.getVersion());
String path = MavenConventionsUtils.artifactPath("/", artifact);