<!-- Extensions -->
<dependency>
<groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.support.simple</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.support.ant</artifactId>
+ <artifactId>org.argeo.slc.support</artifactId>
<version>2.1.1-SNAPSHOT</version>
</dependency>
<!-- SLC Repo -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.repo</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.rpmfactory</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.server.repo</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.server.repo.webapp</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
+<!-- <dependency> -->
+<!-- <groupId>org.argeo.slc</groupId> -->
+<!-- <artifactId>org.argeo.slc.repo</artifactId> -->
+<!-- <version>2.1.1-SNAPSHOT</version> -->
+<!-- </dependency> -->
+<!-- <dependency> -->
+<!-- <groupId>org.argeo.slc</groupId> -->
+<!-- <artifactId>org.argeo.slc.factory</artifactId> -->
+<!-- <version>2.1.1-SNAPSHOT</version> -->
+<!-- </dependency> -->
+<!-- <dependency> -->
+<!-- <groupId>org.argeo.slc</groupId> -->
+<!-- <artifactId>org.argeo.slc.server.repo</artifactId> -->
+<!-- <version>2.1.1-SNAPSHOT</version> -->
+<!-- </dependency> -->
+<!-- <dependency> -->
+<!-- <groupId>org.argeo.slc</groupId> -->
+<!-- <artifactId>org.argeo.slc.server.repo.webapp</artifactId> -->
+<!-- <version>2.1.1-SNAPSHOT</version> -->
+<!-- </dependency> -->
<!-- Node -->
<dependency>
- <groupId>org.argeo.commons.security</groupId>
+ <groupId>org.argeo.commons</groupId>
<artifactId>org.argeo.security.dep.node</artifactId>
<version>${version.argeo-commons}</version>
<type>pom</type>
<artifactId>org.argeo.slc.core</artifactId>
<version>2.1.1-SNAPSHOT</version>
</dependency>
+<!-- <dependency> -->
+<!-- <groupId>org.argeo.slc</groupId> -->
+<!-- <artifactId>org.argeo.slc.agent</artifactId> -->
+<!-- <version>2.1.1-SNAPSHOT</version> -->
+<!-- </dependency> -->
<dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.support.osgi</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.support.equinox</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.agent</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons.base</groupId>
+ <groupId>org.argeo.commons</groupId>
<artifactId>org.argeo.osgi.boot</artifactId>
<version>${version.argeo-commons}</version>
</dependency>
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>org.springframework.osgi.extender</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons.base</groupId>
- <artifactId>org.argeo.dep.log4j</artifactId>
- <version>${version.argeo-commons}</version>
- <type>pom</type>
- </dependency>
<!-- CLI Agent -->
<!-- <dependency> -->
<!-- <artifactId>org.argeo.slc.launcher</artifactId> -->
<!-- <version>1.1.12-SNAPSHOT</version> -->
<!-- </dependency> -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.agent.cli</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
+<!-- <dependency> -->
+<!-- <groupId>org.argeo.slc</groupId> -->
+<!-- <artifactId>org.argeo.slc.agent.cli</artifactId> -->
+<!-- <version>2.1.1-SNAPSHOT</version> -->
+<!-- </dependency> -->
<!-- JCR Agent -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.support.jcr</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.agent.jcr</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.node.jackrabbit</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
+<!-- <dependency> -->
+<!-- <groupId>org.argeo.slc</groupId> -->
+<!-- <artifactId>org.argeo.slc.agent.jcr</artifactId> -->
+<!-- <version>2.1.1-SNAPSHOT</version> -->
+<!-- </dependency> -->
+<!-- <dependency> -->
+<!-- <groupId>org.argeo.slc</groupId> -->
+<!-- <artifactId>org.argeo.slc.node.jackrabbit</artifactId> -->
+<!-- <version>2.1.1-SNAPSHOT</version> -->
+<!-- </dependency> -->
<!-- Node subset -->
<!-- Default JCR repositories configurations -->
<dependency>
- <groupId>org.argeo.commons.server</groupId>
- <artifactId>org.argeo.node.repo.jackrabbit</artifactId>
+ <groupId>org.argeo.commons</groupId>
+ <artifactId>org.argeo.cms</artifactId>
<version>${version.argeo-commons}</version>
</dependency>
<!-- Argeo Security -->
<dependency>
- <groupId>org.argeo.commons.security</groupId>
+ <groupId>org.argeo.commons</groupId>
<artifactId>org.argeo.security.core</artifactId>
<version>${version.argeo-commons}</version>
</dependency>
- <!-- VFS -->
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>org.apache.commons.vfs</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.argeo.tp</groupId>
- <artifactId>org.apache.xmlcommons</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- Xerces and Xalan -->
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>org.apache.xmlcommons</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>org.apache.xalan</artifactId>
- </dependency>
-
- <!-- Javax -->
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>javax.annotation</artifactId>
- </dependency>
-
- <!-- Jackrabbit -->
- <dependency>
- <groupId>org.argeo.commons.server</groupId>
- <artifactId>org.argeo.server.jackrabbit</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons.security</groupId>
- <artifactId>org.argeo.security.jackrabbit</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
-
- <!-- Security (Jackrabbit) -->
- <dependency>
- <groupId>org.argeo.commons.security</groupId>
- <artifactId>org.argeo.security.dao.jackrabbit</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
-
- <!-- Security (Standalone) -->
- <dependency>
- <groupId>org.argeo.commons.security</groupId>
- <artifactId>org.argeo.security.dao.os</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
-
- <!-- DB drivers -->
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>org.h2</artifactId>
- </dependency>
</dependencies>
<profiles>
<profile>
<name>SLC Dependencies</name>
<packaging>pom</packaging>
<modules>
- <module>org.argeo.slc.dep.detached</module>
<module>org.argeo.slc.dep.minimal</module>
<module>org.argeo.slc.dep.backend</module>
- <module>org.argeo.slc.dep.eclipse</module>
- <module>org.argeo.slc.dep.rcp</module>
- <module>org.argeo.slc.dep.rap</module>
+<!-- <module>org.argeo.slc.dep.eclipse</module> -->
+<!-- <module>org.argeo.slc.dep.rcp</module> -->
+<!-- <module>org.argeo.slc.dep.rap</module> -->
</modules>
<build>
<plugins>
+++ /dev/null
-# Set root logger level to DEBUG and its only appender to A1.\r
-log4j.rootLogger=WARN, console\r
-\r
-## Levels\r
-# Slc\r
-log4j.logger.org.argeo=DEBUG\r
-\r
-# Castor\r
-log4j.logger.org.exolab.castor=WARN\r
-\r
-# Spring\r
-log4j.logger.org.springframework=WARN\r
-\r
-\r
-## Appenders\r
-# A1 is set to be a ConsoleAppender.\r
-log4j.appender.console=org.apache.log4j.ConsoleAppender\r
-\r
-# A1 uses PatternLayout.\r
-log4j.appender.console.layout=org.apache.log4j.PatternLayout\r
-log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c%n\r
-\r
import org.argeo.slc.CategorizedNameVersion;
import org.argeo.slc.build.Distribution;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+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,
import org.argeo.slc.jcr.SlcNames;
import org.argeo.slc.jcr.SlcTypes;
import org.osgi.framework.Constants;
-import org.sonatype.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.Artifact;
/**
* Add {@link Artifact} properties to a {@link Node}. Does nothing if the node
import org.argeo.slc.NameVersion;
import org.argeo.slc.SlcException;
import org.osgi.framework.Constants;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
/**
* Creates a jar bundle from an ArgeoOsgiDistribution. This jar is then
import org.argeo.slc.jcr.SlcNames;
import org.argeo.slc.jcr.SlcTypes;
import org.osgi.framework.Constants;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
/**
* Create or update JCR meta-data for an SLC Modular Distribution
import org.argeo.slc.SlcException;
import org.argeo.slc.aether.AetherUtils;
import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
/**
* Creates pde sources from a source {@link Artifact} with name
import org.argeo.slc.repo.maven.MavenConventionsUtils;
import org.argeo.util.security.Keyring;
import org.osgi.framework.Constants;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
/** Utilities around repo */
public class RepoUtils implements ArgeoNames, SlcNames {
package org.argeo.slc.repo;
-import static org.freecompany.redline.header.Header.HeaderTag.HEADERIMMUTABLE;
-import static org.freecompany.redline.header.Signature.SignatureTag.SIGNATURES;
+import static org.redline_rpm.header.Header.HeaderTag.HEADERIMMUTABLE;
+import static org.redline_rpm.header.Signature.SignatureTag.SIGNATURES;
import java.io.InputStream;
import java.nio.ByteBuffer;
import org.argeo.slc.SlcException;
import org.argeo.slc.jcr.SlcNames;
import org.argeo.slc.jcr.SlcTypes;
-import org.freecompany.redline.ChannelWrapper.Key;
-import org.freecompany.redline.ReadableChannelWrapper;
-import org.freecompany.redline.header.AbstractHeader;
-import org.freecompany.redline.header.Format;
-import org.freecompany.redline.header.Header;
+import org.redline_rpm.ChannelWrapper.Key;
+import org.redline_rpm.ReadableChannelWrapper;
+import org.redline_rpm.header.AbstractHeader;
+import org.redline_rpm.header.Format;
+import org.redline_rpm.header.Header;
/** Indexes an RPM file. */
public class RpmIndexer implements NodeIndexer, SlcNames {
"org.apache.activemq.optional");
artifactMapping.put("org.argeo.dep.osgi.activemq.xmpp",
"org.apache.activemq.xmpp");
- artifactMapping.put("org.argeo.dep.osgi.aether", "org.sonatype.aether");
+ artifactMapping.put("org.argeo.dep.osgi.aether", "org.eclipse.aether");
artifactMapping.put("org.argeo.dep.osgi.boilerpipe",
"de.l3s.boilerpipe");
artifactMapping.put("org.argeo.dep.osgi.commons.cli",
import org.argeo.slc.repo.RepoConstants;
import org.argeo.slc.repo.RepoUtils;
import org.osgi.framework.Version;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
/**
* Generates binaries-, sources- and sdk-version.pom artifacts for a given
import org.argeo.slc.repo.JarFileIndexer;
import org.argeo.slc.repo.RepoConstants;
import org.argeo.slc.repo.RepoUtils;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.graph.DependencyNode;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.graph.DependencyNode;
+import org.eclipse.aether.artifact.DefaultArtifact;
/**
* Import all the dependencies listed in a POM and their dependency graphs to a
import org.argeo.slc.jcr.SlcNames;
import org.argeo.slc.jcr.SlcTypes;
import org.argeo.slc.repo.RepoConstants;
-import org.sonatype.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.Artifact;
/** Create a distribution node from a set of artifacts */
public class IndexDistribution implements Runnable {
import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
import org.argeo.slc.aether.AetherTemplate;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.argeo.slc.jcr.SlcTypes;
import org.argeo.slc.repo.MavenProxyService;
import org.argeo.slc.repo.RepoConstants;
-import org.sonatype.aether.repository.RemoteRepository;
+import org.eclipse.aether.repository.RemoteRepository;
/** Synchronises the node repository with remote Maven repositories */
public class MavenProxyServiceImpl extends AbstractUrlProxy implements
import org.argeo.slc.repo.RepoUtils;
import org.argeo.slc.repo.osgi.OsgiProfile;
import org.osgi.framework.Constants;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
/**
* Migrate the distribution from 1.2 to 1.4 by cleaning naming and dependencies.
import org.argeo.slc.build.License;
import org.argeo.slc.repo.OsgiFactory;
import org.argeo.slc.repo.RepoUtils;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;
import org.argeo.slc.build.Distribution;
import org.argeo.slc.build.License;
import org.osgi.framework.Version;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
import org.springframework.beans.factory.BeanNameAware;
import aQute.lib.osgi.Builder;
import org.argeo.slc.repo.ArtifactIndexer;
import org.argeo.slc.repo.JarFileIndexer;
import org.argeo.slc.repo.RepoUtils;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
/**
* Import all bundles in a zip file (typically an Eclipse distribution) into the
import org.argeo.slc.SlcException;
import org.argeo.slc.repo.OsgiFactory;
import org.argeo.slc.repo.RepoUtils;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.artifact.SubArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.util.artifact.SubArtifact;
/**
* BND wrapper based on a Maven artifact available from one of the configured
import org.argeo.slc.repo.maven.MavenConventionsUtils;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
/**
* Make sure that all JCR metadata and Maven metadata are consistent for this
import org.argeo.slc.repo.NodeIndexer;
import org.argeo.slc.repo.OsgiFactory;
import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
/** Default implementation of {@link OsgiFactory}. */
public class OsgiFactoryImpl implements OsgiFactory, SlcNames {
import org.argeo.slc.repo.ModularDistributionFactory;
import org.argeo.slc.repo.OsgiFactory;
import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
/** Executes the processes required so that all managed bundles are available. */
public class ProcessDistribution implements Runnable {
import org.argeo.slc.SlcException;
import org.argeo.slc.repo.OsgiFactory;
import org.argeo.slc.repo.RepoUtils;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
import aQute.lib.osgi.Jar;
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src"/>
+ <classpathentry kind="src" path="ext/test"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path="bin"/>
</classpath>
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.aether;
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+import junit.framework.TestCase;
+
+public class AetherUtilsTest extends TestCase {
+ public void testConvertPathToArtifact() throws Exception {
+ checkPathConversion("my.group.id:my-artifactId:pom:1.2.3",
+ "/my/group/id/my-artifactId/1.2.3/my-artifactId-1.2.3.pom");
+ checkPathConversion("my.group.id:my-artifactId:pom:1.2.3-SNAPSHOT",
+ "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-1.2.3-SNAPSHOT.pom");
+ checkPathConversion("my.group.id:my-artifactId:pom:myClassifier:1.2.3",
+ "/my/group/id/my-artifactId/1.2.3/my-artifactId-1.2.3-myClassifier.pom");
+ checkPathConversion(
+ "my.group.id:my-artifactId:pom:myClassifier:1.2.3-SNAPSHOT",
+ "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-1.2.3-SNAPSHOT-myClassifier.pom");
+ checkPathConversion(
+ "my.group.id:my-artifactId:pom:myClassifier:20110828.223836-2",
+ "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-20110828.223836-2-myClassifier.pom");
+ }
+
+ public void testConvertPathToArtifactRealLife() throws Exception {
+ checkPathConversion(
+ "org.apache.maven.plugins:maven-antrun-plugin:pom:1.1",
+ "org/apache/maven/plugins/maven-antrun-plugin/1.1/maven-antrun-plugin-1.1.pom");
+ checkPathConversion(
+ "org.apache.maven.plugins:maven-plugin-parent:pom:2.0.1",
+ "org/apache/maven/plugins/maven-plugin-parent/2.0.1/maven-plugin-parent-2.0.1.pom");
+ checkPathConversion(
+ "org.apache.avalon.framework:avalon-framework-impl:pom:4.3.1",
+ "org/apache/avalon/framework/avalon-framework-impl/4.3.1/avalon-framework-impl-4.3.1.pom");
+ checkPathConversion(
+ "org.apache.maven.shared:maven-dependency-tree:pom:1.2",
+ "org/apache/maven/shared/maven-dependency-tree/1.2/maven-dependency-tree-1.2.pom");
+ checkPathConversion(
+ "org.argeo.maven.plugins:maven-argeo-osgi-plugin:pom:1.0.33",
+ "org/argeo/maven/plugins/maven-argeo-osgi-plugin/1.0.33/maven-argeo-osgi-plugin-1.0.33.pom");
+ checkPathConversion(
+ "org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1",
+ "org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom");
+ }
+
+ protected void checkPathConversion(String expectedArtifact, String path) {
+ Artifact artifact = AetherUtils.convertPathToArtifact(path, null);
+ if (expectedArtifact == null)
+ assertNull(artifact);
+ else
+ assertEquals(new DefaultArtifact(expectedArtifact), artifact);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.aether;
+
+import java.io.File;
+import java.util.List;
+
+import org.argeo.slc.SlcException;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyNode;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResolutionException;
+import org.eclipse.aether.resolution.ArtifactResult;
+
+/** Simplifies access to Aether. */
+public class AetherTemplate {
+ private RepositorySystem repositorySystem;
+ private RepositorySystemSession repositorySystemSession;
+ private List<RemoteRepository> remoteRepositories;
+
+ /** Resolves the artifact in order to give access to its file. */
+ public File getResolvedFile(Artifact artifact) {
+ try {
+ ArtifactRequest artifactRequest = new ArtifactRequest(artifact,
+ remoteRepositories, null);
+ ArtifactResult result = repositorySystem.resolveArtifact(
+ repositorySystemSession, artifactRequest);
+ return result.getArtifact().getFile();
+ } catch (ArtifactResolutionException e) {
+ throw new SlcException("Cannot resolve " + artifact, e);
+ }
+ }
+
+ /**
+ * Transitively resolves the dependencies of this artifact (with scope
+ * 'compile')
+ *
+ * @param artifact
+ * the artifact to resolve
+ */
+ public DependencyNode resolveDependencies(Artifact artifact) {
+ return resolveDependencies(artifact, "compile");
+ }
+
+ /**
+ * Transitively resolves the dependencies of this artifact.
+ *
+ * @param artifact
+ * the artifact to resolve
+ * @param scope
+ * the scope
+ */
+ public DependencyNode resolveDependencies(Artifact artifact, String scope) {
+ try {
+ Dependency dependency = new Dependency(artifact, scope);
+ CollectRequest collectRequest = new CollectRequest();
+ collectRequest.setRoot(dependency);
+ for (RemoteRepository remoteRepository : remoteRepositories)
+ collectRequest.addRepository(remoteRepository);
+ DependencyNode node = repositorySystem.collectDependencies(
+ repositorySystemSession, collectRequest).getRoot();
+
+ // FIXME adapt to changes in Aether
+ // repositorySystem.resolveDependencies(repositorySystemSession,
+ // node,
+ // null);
+ return node;
+ } catch (Exception e) {
+ throw new SlcException("Cannot resolve dependencies of " + artifact
+ + " (scope: " + scope + ")", e);
+ }
+ }
+
+ public RepositorySystem getRepositorySystem() {
+ return repositorySystem;
+ }
+
+ public void setRepositorySystem(RepositorySystem repositorySystem) {
+ this.repositorySystem = repositorySystem;
+ }
+
+ public RepositorySystemSession getRepositorySystemSession() {
+ return repositorySystemSession;
+ }
+
+ public void setRepositorySystemSession(
+ RepositorySystemSession repositorySystemSession) {
+ this.repositorySystemSession = repositorySystemSession;
+ }
+
+ public List<RemoteRepository> getRemoteRepositories() {
+ return remoteRepositories;
+ }
+
+ public void setRemoteRepositories(List<RemoteRepository> remoteRepositories) {
+ this.remoteRepositories = remoteRepositories;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.aether;
+
+import java.util.regex.Pattern;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.graph.DependencyNode;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+/** Utilities related to Aether */
+public class AetherUtils {
+ public final static String SNAPSHOT = "SNAPSHOT";
+ // hacked from aether
+ public static final Pattern SNAPSHOT_TIMESTAMP = Pattern
+ .compile("^(.*-)?([0-9]{8}.[0-9]{6}-[0-9]+)$");
+
+ private final static Log log = LogFactory.getLog(AetherUtils.class);
+
+ /** Logs a dependency node and its transitive dependencies as a tree. */
+ public static void logDependencyNode(int depth,
+ DependencyNode dependencyNode) {
+ if (!log.isDebugEnabled())
+ return;
+
+ StringBuffer prefix = new StringBuffer(depth * 2 + 2);
+ // prefix.append("|-");
+ for (int i = 0; i < depth * 2; i++) {
+ prefix.append(' ');
+ }
+ Artifact artifact = dependencyNode.getDependency().getArtifact();
+ log.debug(prefix + "|-> " + artifact.getArtifactId() + " ["
+ + artifact.getVersion() + "]"
+ + (dependencyNode.getDependency().isOptional() ? " ?" : ""));
+ for (DependencyNode child : dependencyNode.getChildren()) {
+ logDependencyNode(depth + 1, child);
+ }
+ }
+
+ /**
+ * Converts a path (relative to a repository root) to an {@link Artifact}.
+ *
+ * @param path
+ * the relative path
+ * @param type
+ * the layout type, currently ignored because only the 'default'
+ * Maven 2 layout is currently supported:
+ * /my/group/id/artifactId/
+ * version/artifactId-version[-classifier].extension
+ * @return the related artifact or null if the file is not an artifact
+ * (Maven medata data XML files, check sums, etc.)
+ */
+ public static Artifact convertPathToArtifact(String path, String type) {
+ // TODO rewrite it with regexp (unit tests first!)
+
+ // normalize
+ if (path.startsWith("/"))
+ path = path.substring(1);
+
+ // parse group id
+ String[] tokensSlash = path.split("/");
+ if (tokensSlash.length < 4)
+ return null;
+ StringBuffer groupId = new StringBuffer(path.length());
+ for (int i = 0; i < tokensSlash.length - 3; i++) {
+ if (i != 0)
+ groupId.append('.');
+ groupId.append(tokensSlash[i]);
+ }
+ String artifactId = tokensSlash[tokensSlash.length - 3];
+ String baseVersion = tokensSlash[tokensSlash.length - 2];
+ String fileName = tokensSlash[tokensSlash.length - 1];
+
+ if (!fileName.startsWith(artifactId))
+ return null;
+ // FIXME make it configurable? (via an argument?)
+ if (FilenameUtils.isExtension(fileName, new String[] { "sha1", "md5" }))
+ return null;
+
+ String extension = FilenameUtils.getExtension(fileName);
+ String baseName = FilenameUtils.getBaseName(fileName);
+
+ // check since we assume hereafter
+ if (!baseName.startsWith(artifactId))
+ throw new SlcException("Base name '" + baseName
+ + " does not start with artifact id '" + artifactId
+ + "' in " + path);
+
+ boolean isSnapshot = baseVersion.endsWith("-" + SNAPSHOT);
+ String baseBaseVersion = isSnapshot ? baseVersion.substring(0,
+ baseVersion.length() - SNAPSHOT.length() - 1) : baseVersion;
+ int artifactAndBaseBaseVersionLength = artifactId.length() + 1
+ + baseBaseVersion.length() + 1;
+ String classifier = null;
+ if (baseName.length() > artifactAndBaseBaseVersionLength) {
+ String dashRest = baseName
+ .substring(artifactAndBaseBaseVersionLength);
+ String[] dashes = dashRest.split("-");
+
+ if (isSnapshot) {
+ if (dashes[0].equals(SNAPSHOT)) {
+ if (dashRest.length() > SNAPSHOT.length() + 1)
+ classifier = dashRest.substring(SNAPSHOT.length() + 1);
+
+ } else {
+ if (dashes.length > 2)// assume no '-' in classifier
+ classifier = dashes[2];
+ }
+ } else {
+ if (dashes.length > 0)
+ classifier = dashes[0];
+ }
+ }
+
+ // classifier
+ // String classifier = null;
+ // int firstDash = baseName.indexOf('-');
+ // int classifierDash = baseName.lastIndexOf('-');
+ // if (classifierDash > 0 && classifierDash != firstDash) {
+ // classifier = baseName.substring(classifierDash + 1);
+ // }
+ // if (isSnapshot && classifier != null) {
+ // if (classifier.equals(SNAPSHOT))
+ // classifier = null;
+ // else
+ // try {
+ // Long.parseLong(classifier); // build number
+ // // if not failed this is a timestamped version
+ // classifier = null;
+ // } catch (NumberFormatException e) {
+ // // silent
+ // }
+ // }
+
+ // version
+ String version = baseName.substring(artifactId.length() + 1);
+ if (classifier != null)
+ version = version.substring(0,
+ version.length() - classifier.length() - 1);
+
+ // consistency checks
+ if (!isSnapshot && !version.equals(baseVersion))
+ throw new SlcException("Base version '" + baseVersion
+ + "' and version '" + version + "' not in line in " + path);
+ if (!isSnapshot && isSnapshotVersion(version))
+ throw new SlcException("SNAPSHOT base version '" + baseVersion
+ + "' and version '" + version + "' not in line in " + path);
+
+ DefaultArtifact artifact = new DefaultArtifact(groupId.toString(),
+ artifactId, classifier, extension, version);
+ return artifact;
+ }
+
+ /** Hacked from aether */
+ public static boolean isSnapshotVersion(String version) {
+ return version.endsWith(SNAPSHOT)
+ || SNAPSHOT_TIMESTAMP.matcher(version).matches();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.aether;
+
+import java.util.Comparator;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * Compare two artifacts, for use in {@link TreeSet} / {@link TreeMap}, consider
+ * artifactId first THEN groupId
+ */
+public class ArtifactIdComparator implements Comparator<Artifact> {
+ public int compare(Artifact o1, Artifact o2) {
+ if (o1.getArtifactId().equals(o2.getArtifactId()))
+ return o1.getGroupId().compareTo(o2.getGroupId());
+ return o1.getArtifactId().compareTo(o2.getArtifactId());
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.aether;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.aether.AbstractRepositoryListener;
+import org.eclipse.aether.RepositoryEvent;
+
+public class ConsoleRepositoryListener extends AbstractRepositoryListener {
+
+ private final static Log log = LogFactory
+ .getLog(ConsoleRepositoryListener.class);
+
+ public void artifactDeployed(RepositoryEvent event) {
+ if (log.isDebugEnabled())
+ log.debug("Deployed " + event.getArtifact() + " to "
+ + event.getRepository());
+ }
+
+ public void artifactDeploying(RepositoryEvent event) {
+ if (log.isTraceEnabled())
+ log.trace("Deploying " + event.getArtifact() + " to "
+ + event.getRepository());
+ }
+
+ public void artifactDescriptorInvalid(RepositoryEvent event) {
+ if (log.isDebugEnabled())
+ log.warn("Invalid artifact descriptor for " + event.getArtifact()
+ + ": " + event.getException().getMessage());
+ }
+
+ public void artifactDescriptorMissing(RepositoryEvent event) {
+ if (log.isTraceEnabled())
+ log.warn("Missing artifact descriptor for " + event.getArtifact());
+ }
+
+ public void artifactInstalled(RepositoryEvent event) {
+ if (log.isDebugEnabled())
+ log.debug("Installed " + event.getArtifact() + " to "
+ + event.getFile());
+ }
+
+ public void artifactInstalling(RepositoryEvent event) {
+ if (log.isTraceEnabled())
+ log.trace("Installing " + event.getArtifact() + " to "
+ + event.getFile());
+ }
+
+ public void artifactResolved(RepositoryEvent event) {
+ if (log.isTraceEnabled())
+ log.trace("Resolved artifact " + event.getArtifact() + " from "
+ + event.getRepository());
+ }
+
+ public void artifactDownloading(RepositoryEvent event) {
+ if (log.isTraceEnabled())
+ log.trace("Downloading artifact " + event.getArtifact() + " from "
+ + event.getRepository());
+ }
+
+ public void artifactDownloaded(RepositoryEvent event) {
+ if (log.isDebugEnabled())
+ log.debug("Downloaded artifact " + event.getArtifact() + " from "
+ + event.getRepository());
+ }
+
+ public void artifactResolving(RepositoryEvent event) {
+ if (log.isTraceEnabled())
+ log.trace("Resolving artifact " + event.getArtifact());
+ }
+
+ public void metadataDeployed(RepositoryEvent event) {
+ if (log.isDebugEnabled())
+ log.debug("Deployed " + event.getMetadata() + " to "
+ + event.getRepository());
+ }
+
+ public void metadataDeploying(RepositoryEvent event) {
+ if (log.isTraceEnabled())
+ log.trace("Deploying " + event.getMetadata() + " to "
+ + event.getRepository());
+ }
+
+ public void metadataInstalled(RepositoryEvent event) {
+ if (log.isDebugEnabled())
+ log.debug("Installed " + event.getMetadata() + " to "
+ + event.getFile());
+ }
+
+ public void metadataInstalling(RepositoryEvent event) {
+ if (log.isTraceEnabled())
+ log.trace("Installing " + event.getMetadata() + " to "
+ + event.getFile());
+ }
+
+ public void metadataInvalid(RepositoryEvent event) {
+ if (log.isDebugEnabled())
+ log.debug("Invalid metadata " + event.getMetadata());
+ }
+
+ public void metadataResolved(RepositoryEvent event) {
+ if (log.isTraceEnabled())
+ log.trace("Resolved metadata " + event.getMetadata() + " from "
+ + event.getRepository());
+ }
+
+ public void metadataResolving(RepositoryEvent event) {
+ if (log.isTraceEnabled())
+ log.trace("Resolving metadata " + event.getMetadata() + " from "
+ + event.getRepository());
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.aether;
+
+import java.io.PrintStream;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.aether.transfer.AbstractTransferListener;
+import org.eclipse.aether.transfer.TransferEvent;
+import org.eclipse.aether.transfer.TransferResource;
+
+public class ConsoleTransferListener extends AbstractTransferListener {
+ private final static Log log = LogFactory
+ .getLog(ConsoleTransferListener.class);
+
+ private PrintStream out;
+
+ private Map<TransferResource, Long> downloads = new ConcurrentHashMap<TransferResource, Long>();
+
+ private int lastLength;
+
+ public ConsoleTransferListener(PrintStream out) {
+ this.out = (out != null) ? out : System.out;
+ }
+
+ @Override
+ public void transferInitiated(TransferEvent event) {
+ String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading"
+ : "Downloading";
+
+ if (log.isDebugEnabled())
+ log.debug(message + ": " + event.getResource().getRepositoryUrl()
+ + event.getResource().getResourceName());
+ }
+
+ @Override
+ public void transferProgressed(TransferEvent event) {
+ TransferResource resource = event.getResource();
+ downloads.put(resource, Long.valueOf(event.getTransferredBytes()));
+
+ StringBuilder buffer = new StringBuilder(64);
+
+ for (Map.Entry<TransferResource, Long> entry : downloads.entrySet()) {
+ long total = entry.getKey().getContentLength();
+ long complete = entry.getValue().longValue();
+
+ buffer.append(getStatus(complete, total)).append(" ");
+ }
+
+ int pad = lastLength - buffer.length();
+ lastLength = buffer.length();
+ pad(buffer, pad);
+ buffer.append('\r');
+
+ out.print(buffer);
+ }
+
+ private String getStatus(long complete, long total) {
+ if (total >= 1024) {
+ return toKB(complete) + "/" + toKB(total) + " KB ";
+ } else if (total >= 0) {
+ return complete + "/" + total + " B ";
+ } else if (complete >= 1024) {
+ return toKB(complete) + " KB ";
+ } else {
+ return complete + " B ";
+ }
+ }
+
+ private void pad(StringBuilder buffer, int spaces) {
+ String block = " ";
+ while (spaces > 0) {
+ int n = Math.min(spaces, block.length());
+ buffer.append(block, 0, n);
+ spaces -= n;
+ }
+ }
+
+ @Override
+ public void transferSucceeded(TransferEvent event) {
+ transferCompleted(event);
+
+ TransferResource resource = event.getResource();
+ long contentLength = event.getTransferredBytes();
+ if (contentLength >= 0) {
+ String type = (event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded"
+ : "Downloaded");
+ String len = contentLength >= 1024 ? toKB(contentLength) + " KB"
+ : contentLength + " B";
+
+ String throughput = "";
+ long duration = System.currentTimeMillis()
+ - resource.getTransferStartTime();
+ if (duration > 0) {
+ DecimalFormat format = new DecimalFormat("0.0",
+ new DecimalFormatSymbols(Locale.ENGLISH));
+ double kbPerSec = (contentLength / 1024.0)
+ / (duration / 1000.0);
+ throughput = " at " + format.format(kbPerSec) + " KB/sec";
+ }
+
+ out.println(type + ": " + resource.getRepositoryUrl()
+ + resource.getResourceName() + " (" + len + throughput
+ + ")");
+ }
+ }
+
+ @Override
+ public void transferFailed(TransferEvent event) {
+ transferCompleted(event);
+
+ log.error(event.getException().getMessage()
+ + (event.getException().getCause() != null ? " : "
+ + event.getException().getCause().getMessage() : ""));
+ // event.getException().printStackTrace( out );
+ }
+
+ private void transferCompleted(TransferEvent event) {
+ downloads.remove(event.getResource());
+
+ StringBuilder buffer = new StringBuilder(64);
+ pad(buffer, lastLength);
+ buffer.append('\r');
+ out.print(buffer);
+ }
+
+ public void transferCorrupted(TransferEvent event) {
+ event.getException().printStackTrace(out);
+ }
+
+ protected long toKB(long bytes) {
+ return (bytes + 1023) / 1024;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.aether;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.impl.ArtifactDescriptorReader;
+import org.eclipse.aether.resolution.ArtifactDescriptorException;
+import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
+import org.eclipse.aether.resolution.ArtifactDescriptorResult;
+
+public class SimpleArtifactDescriptorReader implements ArtifactDescriptorReader {
+
+ public ArtifactDescriptorResult readArtifactDescriptor(
+ RepositorySystemSession session, ArtifactDescriptorRequest request)
+ throws ArtifactDescriptorException {
+ ArtifactDescriptorResult result = new ArtifactDescriptorResult(request);
+ return result;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.aether;
+
+import org.argeo.slc.aether.osgi.OsgiVersion;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.impl.VersionRangeResolver;
+import org.eclipse.aether.resolution.VersionRangeRequest;
+import org.eclipse.aether.resolution.VersionRangeResolutionException;
+import org.eclipse.aether.resolution.VersionRangeResult;
+import org.eclipse.aether.version.Version;
+
+public class SimpleVersionRangeResolver implements VersionRangeResolver {
+
+ public VersionRangeResult resolveVersionRange(
+ RepositorySystemSession session, VersionRangeRequest request)
+ throws VersionRangeResolutionException {
+ VersionRangeResult versionRangeResult = new VersionRangeResult(request);
+ Version version = new OsgiVersion(request.getArtifact()
+ .getBaseVersion());
+ versionRangeResult.addVersion(version);
+ return null;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.aether;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.impl.VersionResolver;
+import org.eclipse.aether.resolution.VersionRequest;
+import org.eclipse.aether.resolution.VersionResolutionException;
+import org.eclipse.aether.resolution.VersionResult;
+
+public class SimpleVersionResolver implements VersionResolver {
+
+ public VersionResult resolveVersion(RepositorySystemSession session,
+ VersionRequest request) throws VersionResolutionException {
+ VersionResult versionResult = new VersionResult(request);
+ versionResult.setVersion(request.getArtifact().getBaseVersion());
+ return versionResult;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.aether.osgi;
+
+import org.osgi.framework.Version;
+
+/**
+ * Wraps an OSGi {@link Version} as an Aether
+ * {@link org.eclipse.aether.version.Version}.
+ */
+public class OsgiVersion implements org.eclipse.aether.version.Version {
+ final private Version version;
+
+ public OsgiVersion(String str) {
+ version = Version.parseVersion(str);
+ }
+
+ public Version getVersion() {
+ return version;
+ }
+
+ public int compareTo(org.eclipse.aether.version.Version v) {
+ if (!(v instanceof OsgiVersion))
+ return 0;
+ OsgiVersion ov = (OsgiVersion) v;
+ return version.compareTo(ov.version);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.aether.spring;
+
+import org.eclipse.aether.repository.Authentication;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.beans.factory.FactoryBean;
+
+/** Simplifies the definition of a remote factory using Spring */
+public class RemoteRepositoryFactory implements BeanNameAware, FactoryBean {
+ private String beanName;
+ private String id;
+ private String url;
+ private String type = "default";
+ private String username;
+ private String password;
+
+ public Object getObject() throws Exception {
+ // FIXME Adapt to changes in Aether
+// RemoteRepository remoteRepository = new RemoteRepository(
+// id != null ? id : beanName, type, url);
+// if (username != null) {
+// Authentication authentication = new Authentication(username,
+// password);
+// remoteRepository.setAuthentication(authentication);
+// }
+ return null;
+ }
+
+ public Class<?> getObjectType() {
+ return RemoteRepository.class;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public void setBeanName(String name) {
+ this.beanName = name;
+
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+}
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.argeo.commons</groupId>
<module>org.argeo.slc.api</module>
<module>org.argeo.slc.core</module>
<module>org.argeo.slc.unit</module>
+ <module>org.argeo.slc.support</module>
<module>org.argeo.slc.repo</module>
-<!-- <module>runtime</module> -->
-<!-- <module>modules</module> -->
-<!-- <module>plugins</module> -->
-<!-- <module>archetypes</module> -->
+ <!-- <module>runtime</module> -->
+ <!-- <module>modules</module> -->
+ <!-- <module>plugins</module> -->
+ <!-- <module>archetypes</module> -->
-<!-- <module>lib</module> -->
-<!-- <module>dep</module> -->
-<!-- <module>dist</module> -->
-<!-- <module>demo</module> -->
+ <!-- <module>lib</module> -->
+ <module>dep</module>
+ <!-- <module>dist</module> -->
+ <!-- <module>demo</module> -->
</modules>
<url>http://projects.argeo.org/slc/</url>
<scm>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
- <!--
- <repository>
- <id>argeo-tp-extras</id>
- <url>https://forge.argeo.org/data/public/java/argeo-tp-extras-2.1</url>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>daily</updatePolicy>
- <checksumPolicy>warn</checksumPolicy>
- </releases>
- </repository>
- -->
+ <!-- <repository> <id>argeo-tp-extras</id> <url>https://forge.argeo.org/data/public/java/argeo-tp-extras-2.1</url>
+ <releases> <enabled>true</enabled> <updatePolicy>daily</updatePolicy> <checksumPolicy>warn</checksumPolicy>
+ </releases> </repository> -->
<repository>
<id>argeo-tp-extras-local</id>
<url>http://localhost:7080/data/public/java/argeo-tp-extras-2.1</url>
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.aether;
-
-import java.io.File;
-import java.util.List;
-
-import org.argeo.slc.SlcException;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.collection.CollectRequest;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.DependencyNode;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.resolution.ArtifactRequest;
-import org.sonatype.aether.resolution.ArtifactResolutionException;
-import org.sonatype.aether.resolution.ArtifactResult;
-
-/** Simplifies access to Aether. */
-public class AetherTemplate {
- private RepositorySystem repositorySystem;
- private RepositorySystemSession repositorySystemSession;
- private List<RemoteRepository> remoteRepositories;
-
- /** Resolves the artifact in order to give access to its file. */
- public File getResolvedFile(Artifact artifact) {
- try {
- ArtifactRequest artifactRequest = new ArtifactRequest(artifact,
- remoteRepositories, null);
- ArtifactResult result = repositorySystem.resolveArtifact(
- repositorySystemSession, artifactRequest);
- return result.getArtifact().getFile();
- } catch (ArtifactResolutionException e) {
- throw new SlcException("Cannot resolve " + artifact, e);
- }
- }
-
- /**
- * Transitively resolves the dependencies of this artifact (with scope
- * 'compile')
- *
- * @param artifact
- * the artifact to resolve
- */
- public DependencyNode resolveDependencies(Artifact artifact) {
- return resolveDependencies(artifact, "compile");
- }
-
- /**
- * Transitively resolves the dependencies of this artifact.
- *
- * @param artifact
- * the artifact to resolve
- * @param scope
- * the scope
- */
- public DependencyNode resolveDependencies(Artifact artifact, String scope) {
- try {
- Dependency dependency = new Dependency(artifact, scope);
- CollectRequest collectRequest = new CollectRequest();
- collectRequest.setRoot(dependency);
- for (RemoteRepository remoteRepository : remoteRepositories)
- collectRequest.addRepository(remoteRepository);
- DependencyNode node = repositorySystem.collectDependencies(
- repositorySystemSession, collectRequest).getRoot();
-
- repositorySystem.resolveDependencies(repositorySystemSession, node,
- null);
- return node;
- } catch (Exception e) {
- throw new SlcException("Cannot resolve dependencies of " + artifact
- + " (scope: " + scope + ")", e);
- }
- }
-
- public RepositorySystem getRepositorySystem() {
- return repositorySystem;
- }
-
- public void setRepositorySystem(RepositorySystem repositorySystem) {
- this.repositorySystem = repositorySystem;
- }
-
- public RepositorySystemSession getRepositorySystemSession() {
- return repositorySystemSession;
- }
-
- public void setRepositorySystemSession(
- RepositorySystemSession repositorySystemSession) {
- this.repositorySystemSession = repositorySystemSession;
- }
-
- public List<RemoteRepository> getRemoteRepositories() {
- return remoteRepositories;
- }
-
- public void setRemoteRepositories(List<RemoteRepository> remoteRepositories) {
- this.remoteRepositories = remoteRepositories;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.aether;
-
-import java.util.regex.Pattern;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.graph.DependencyNode;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-
-/** Utilities related to Aether */
-public class AetherUtils {
- public final static String SNAPSHOT = "SNAPSHOT";
- // hacked from aether
- public static final Pattern SNAPSHOT_TIMESTAMP = Pattern
- .compile("^(.*-)?([0-9]{8}.[0-9]{6}-[0-9]+)$");
-
- private final static Log log = LogFactory.getLog(AetherUtils.class);
-
- /** Logs a dependency node and its transitive dependencies as a tree. */
- public static void logDependencyNode(int depth,
- DependencyNode dependencyNode) {
- if (!log.isDebugEnabled())
- return;
-
- StringBuffer prefix = new StringBuffer(depth * 2 + 2);
- // prefix.append("|-");
- for (int i = 0; i < depth * 2; i++) {
- prefix.append(' ');
- }
- Artifact artifact = dependencyNode.getDependency().getArtifact();
- log.debug(prefix + "|-> " + artifact.getArtifactId() + " ["
- + artifact.getVersion() + "]"
- + (dependencyNode.getDependency().isOptional() ? " ?" : ""));
- for (DependencyNode child : dependencyNode.getChildren()) {
- logDependencyNode(depth + 1, child);
- }
- }
-
- /**
- * Converts a path (relative to a repository root) to an {@link Artifact}.
- *
- * @param path
- * the relative path
- * @param type
- * the layout type, currently ignored because only the 'default'
- * Maven 2 layout is currently supported:
- * /my/group/id/artifactId/
- * version/artifactId-version[-classifier].extension
- * @return the related artifact or null if the file is not an artifact
- * (Maven medata data XML files, check sums, etc.)
- */
- public static Artifact convertPathToArtifact(String path, String type) {
- // TODO rewrite it with regexp (unit tests first!)
-
- // normalize
- if (path.startsWith("/"))
- path = path.substring(1);
-
- // parse group id
- String[] tokensSlash = path.split("/");
- if (tokensSlash.length < 4)
- return null;
- StringBuffer groupId = new StringBuffer(path.length());
- for (int i = 0; i < tokensSlash.length - 3; i++) {
- if (i != 0)
- groupId.append('.');
- groupId.append(tokensSlash[i]);
- }
- String artifactId = tokensSlash[tokensSlash.length - 3];
- String baseVersion = tokensSlash[tokensSlash.length - 2];
- String fileName = tokensSlash[tokensSlash.length - 1];
-
- if (!fileName.startsWith(artifactId))
- return null;
- // FIXME make it configurable? (via an argument?)
- if (FilenameUtils.isExtension(fileName, new String[] { "sha1", "md5" }))
- return null;
-
- String extension = FilenameUtils.getExtension(fileName);
- String baseName = FilenameUtils.getBaseName(fileName);
-
- // check since we assume hereafter
- if (!baseName.startsWith(artifactId))
- throw new SlcException("Base name '" + baseName
- + " does not start with artifact id '" + artifactId
- + "' in " + path);
-
- boolean isSnapshot = baseVersion.endsWith("-" + SNAPSHOT);
- String baseBaseVersion = isSnapshot ? baseVersion.substring(0,
- baseVersion.length() - SNAPSHOT.length() - 1) : baseVersion;
- int artifactAndBaseBaseVersionLength = artifactId.length() + 1
- + baseBaseVersion.length() + 1;
- String classifier = null;
- if (baseName.length() > artifactAndBaseBaseVersionLength) {
- String dashRest = baseName
- .substring(artifactAndBaseBaseVersionLength);
- String[] dashes = dashRest.split("-");
-
- if (isSnapshot) {
- if (dashes[0].equals(SNAPSHOT)) {
- if (dashRest.length() > SNAPSHOT.length() + 1)
- classifier = dashRest.substring(SNAPSHOT.length() + 1);
-
- } else {
- if (dashes.length > 2)// assume no '-' in classifier
- classifier = dashes[2];
- }
- } else {
- if (dashes.length > 0)
- classifier = dashes[0];
- }
- }
-
- // classifier
- // String classifier = null;
- // int firstDash = baseName.indexOf('-');
- // int classifierDash = baseName.lastIndexOf('-');
- // if (classifierDash > 0 && classifierDash != firstDash) {
- // classifier = baseName.substring(classifierDash + 1);
- // }
- // if (isSnapshot && classifier != null) {
- // if (classifier.equals(SNAPSHOT))
- // classifier = null;
- // else
- // try {
- // Long.parseLong(classifier); // build number
- // // if not failed this is a timestamped version
- // classifier = null;
- // } catch (NumberFormatException e) {
- // // silent
- // }
- // }
-
- // version
- String version = baseName.substring(artifactId.length() + 1);
- if (classifier != null)
- version = version.substring(0,
- version.length() - classifier.length() - 1);
-
- // consistency checks
- if (!isSnapshot && !version.equals(baseVersion))
- throw new SlcException("Base version '" + baseVersion
- + "' and version '" + version + "' not in line in " + path);
- if (!isSnapshot && isSnapshotVersion(version))
- throw new SlcException("SNAPSHOT base version '" + baseVersion
- + "' and version '" + version + "' not in line in " + path);
-
- DefaultArtifact artifact = new DefaultArtifact(groupId.toString(),
- artifactId, classifier, extension, version);
- return artifact;
- }
-
- /** Hacked from aether */
- public static boolean isSnapshotVersion(String version) {
- return version.endsWith(SNAPSHOT)
- || SNAPSHOT_TIMESTAMP.matcher(version).matches();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.aether;
-
-import java.util.Comparator;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.sonatype.aether.artifact.Artifact;
-
-/**
- * Compare two artifacts, for use in {@link TreeSet} / {@link TreeMap}, consider
- * artifactId first THEN groupId
- */
-public class ArtifactIdComparator implements Comparator<Artifact> {
- public int compare(Artifact o1, Artifact o2) {
- if (o1.getArtifactId().equals(o2.getArtifactId()))
- return o1.getGroupId().compareTo(o2.getGroupId());
- return o1.getArtifactId().compareTo(o2.getArtifactId());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.aether;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.sonatype.aether.AbstractRepositoryListener;
-import org.sonatype.aether.RepositoryEvent;
-
-public class ConsoleRepositoryListener extends AbstractRepositoryListener {
-
- private final static Log log = LogFactory
- .getLog(ConsoleRepositoryListener.class);
-
- public void artifactDeployed(RepositoryEvent event) {
- if (log.isDebugEnabled())
- log.debug("Deployed " + event.getArtifact() + " to "
- + event.getRepository());
- }
-
- public void artifactDeploying(RepositoryEvent event) {
- if (log.isTraceEnabled())
- log.trace("Deploying " + event.getArtifact() + " to "
- + event.getRepository());
- }
-
- public void artifactDescriptorInvalid(RepositoryEvent event) {
- if (log.isDebugEnabled())
- log.warn("Invalid artifact descriptor for " + event.getArtifact()
- + ": " + event.getException().getMessage());
- }
-
- public void artifactDescriptorMissing(RepositoryEvent event) {
- if (log.isTraceEnabled())
- log.warn("Missing artifact descriptor for " + event.getArtifact());
- }
-
- public void artifactInstalled(RepositoryEvent event) {
- if (log.isDebugEnabled())
- log.debug("Installed " + event.getArtifact() + " to "
- + event.getFile());
- }
-
- public void artifactInstalling(RepositoryEvent event) {
- if (log.isTraceEnabled())
- log.trace("Installing " + event.getArtifact() + " to "
- + event.getFile());
- }
-
- public void artifactResolved(RepositoryEvent event) {
- if (log.isTraceEnabled())
- log.trace("Resolved artifact " + event.getArtifact() + " from "
- + event.getRepository());
- }
-
- public void artifactDownloading(RepositoryEvent event) {
- if (log.isTraceEnabled())
- log.trace("Downloading artifact " + event.getArtifact() + " from "
- + event.getRepository());
- }
-
- public void artifactDownloaded(RepositoryEvent event) {
- if (log.isDebugEnabled())
- log.debug("Downloaded artifact " + event.getArtifact() + " from "
- + event.getRepository());
- }
-
- public void artifactResolving(RepositoryEvent event) {
- if (log.isTraceEnabled())
- log.trace("Resolving artifact " + event.getArtifact());
- }
-
- public void metadataDeployed(RepositoryEvent event) {
- if (log.isDebugEnabled())
- log.debug("Deployed " + event.getMetadata() + " to "
- + event.getRepository());
- }
-
- public void metadataDeploying(RepositoryEvent event) {
- if (log.isTraceEnabled())
- log.trace("Deploying " + event.getMetadata() + " to "
- + event.getRepository());
- }
-
- public void metadataInstalled(RepositoryEvent event) {
- if (log.isDebugEnabled())
- log.debug("Installed " + event.getMetadata() + " to "
- + event.getFile());
- }
-
- public void metadataInstalling(RepositoryEvent event) {
- if (log.isTraceEnabled())
- log.trace("Installing " + event.getMetadata() + " to "
- + event.getFile());
- }
-
- public void metadataInvalid(RepositoryEvent event) {
- if (log.isDebugEnabled())
- log.debug("Invalid metadata " + event.getMetadata());
- }
-
- public void metadataResolved(RepositoryEvent event) {
- if (log.isTraceEnabled())
- log.trace("Resolved metadata " + event.getMetadata() + " from "
- + event.getRepository());
- }
-
- public void metadataResolving(RepositoryEvent event) {
- if (log.isTraceEnabled())
- log.trace("Resolving metadata " + event.getMetadata() + " from "
- + event.getRepository());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.aether;
-
-import java.io.PrintStream;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.sonatype.aether.transfer.AbstractTransferListener;
-import org.sonatype.aether.transfer.TransferEvent;
-import org.sonatype.aether.transfer.TransferResource;
-
-public class ConsoleTransferListener extends AbstractTransferListener {
- private final static Log log = LogFactory
- .getLog(ConsoleTransferListener.class);
-
- private PrintStream out;
-
- private Map<TransferResource, Long> downloads = new ConcurrentHashMap<TransferResource, Long>();
-
- private int lastLength;
-
- public ConsoleTransferListener(PrintStream out) {
- this.out = (out != null) ? out : System.out;
- }
-
- @Override
- public void transferInitiated(TransferEvent event) {
- String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading"
- : "Downloading";
-
- if (log.isDebugEnabled())
- log.debug(message + ": " + event.getResource().getRepositoryUrl()
- + event.getResource().getResourceName());
- }
-
- @Override
- public void transferProgressed(TransferEvent event) {
- TransferResource resource = event.getResource();
- downloads.put(resource, Long.valueOf(event.getTransferredBytes()));
-
- StringBuilder buffer = new StringBuilder(64);
-
- for (Map.Entry<TransferResource, Long> entry : downloads.entrySet()) {
- long total = entry.getKey().getContentLength();
- long complete = entry.getValue().longValue();
-
- buffer.append(getStatus(complete, total)).append(" ");
- }
-
- int pad = lastLength - buffer.length();
- lastLength = buffer.length();
- pad(buffer, pad);
- buffer.append('\r');
-
- out.print(buffer);
- }
-
- private String getStatus(long complete, long total) {
- if (total >= 1024) {
- return toKB(complete) + "/" + toKB(total) + " KB ";
- } else if (total >= 0) {
- return complete + "/" + total + " B ";
- } else if (complete >= 1024) {
- return toKB(complete) + " KB ";
- } else {
- return complete + " B ";
- }
- }
-
- private void pad(StringBuilder buffer, int spaces) {
- String block = " ";
- while (spaces > 0) {
- int n = Math.min(spaces, block.length());
- buffer.append(block, 0, n);
- spaces -= n;
- }
- }
-
- @Override
- public void transferSucceeded(TransferEvent event) {
- transferCompleted(event);
-
- TransferResource resource = event.getResource();
- long contentLength = event.getTransferredBytes();
- if (contentLength >= 0) {
- String type = (event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded"
- : "Downloaded");
- String len = contentLength >= 1024 ? toKB(contentLength) + " KB"
- : contentLength + " B";
-
- String throughput = "";
- long duration = System.currentTimeMillis()
- - resource.getTransferStartTime();
- if (duration > 0) {
- DecimalFormat format = new DecimalFormat("0.0",
- new DecimalFormatSymbols(Locale.ENGLISH));
- double kbPerSec = (contentLength / 1024.0)
- / (duration / 1000.0);
- throughput = " at " + format.format(kbPerSec) + " KB/sec";
- }
-
- out.println(type + ": " + resource.getRepositoryUrl()
- + resource.getResourceName() + " (" + len + throughput
- + ")");
- }
- }
-
- @Override
- public void transferFailed(TransferEvent event) {
- transferCompleted(event);
-
- log.error(event.getException().getMessage()
- + (event.getException().getCause() != null ? " : "
- + event.getException().getCause().getMessage() : ""));
- // event.getException().printStackTrace( out );
- }
-
- private void transferCompleted(TransferEvent event) {
- downloads.remove(event.getResource());
-
- StringBuilder buffer = new StringBuilder(64);
- pad(buffer, lastLength);
- buffer.append('\r');
- out.print(buffer);
- }
-
- public void transferCorrupted(TransferEvent event) {
- event.getException().printStackTrace(out);
- }
-
- protected long toKB(long bytes) {
- return (bytes + 1023) / 1024;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.aether;
-
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.impl.ArtifactDescriptorReader;
-import org.sonatype.aether.resolution.ArtifactDescriptorException;
-import org.sonatype.aether.resolution.ArtifactDescriptorRequest;
-import org.sonatype.aether.resolution.ArtifactDescriptorResult;
-
-public class SimpleArtifactDescriptorReader implements ArtifactDescriptorReader {
-
- public ArtifactDescriptorResult readArtifactDescriptor(
- RepositorySystemSession session, ArtifactDescriptorRequest request)
- throws ArtifactDescriptorException {
- ArtifactDescriptorResult result = new ArtifactDescriptorResult(request);
- return result;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.aether;
-
-import org.argeo.slc.aether.osgi.OsgiVersion;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.impl.VersionRangeResolver;
-import org.sonatype.aether.resolution.VersionRangeRequest;
-import org.sonatype.aether.resolution.VersionRangeResolutionException;
-import org.sonatype.aether.resolution.VersionRangeResult;
-import org.sonatype.aether.version.Version;
-
-public class SimpleVersionRangeResolver implements VersionRangeResolver {
-
- public VersionRangeResult resolveVersionRange(
- RepositorySystemSession session, VersionRangeRequest request)
- throws VersionRangeResolutionException {
- VersionRangeResult versionRangeResult = new VersionRangeResult(request);
- Version version = new OsgiVersion(request.getArtifact()
- .getBaseVersion());
- versionRangeResult.addVersion(version);
- return null;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.aether;
-
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.impl.VersionResolver;
-import org.sonatype.aether.resolution.VersionRequest;
-import org.sonatype.aether.resolution.VersionResolutionException;
-import org.sonatype.aether.resolution.VersionResult;
-
-public class SimpleVersionResolver implements VersionResolver {
-
- public VersionResult resolveVersion(RepositorySystemSession session,
- VersionRequest request) throws VersionResolutionException {
- VersionResult versionResult = new VersionResult(request);
- versionResult.setVersion(request.getArtifact().getBaseVersion());
- return versionResult;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.aether.osgi;
-
-import org.osgi.framework.Version;
-
-/**
- * Wraps an OSGi {@link Version} as an Aether
- * {@link org.sonatype.aether.version.Version}.
- */
-public class OsgiVersion implements org.sonatype.aether.version.Version {
- final private Version version;
-
- public OsgiVersion(String str) {
- version = Version.parseVersion(str);
- }
-
- public Version getVersion() {
- return version;
- }
-
- public int compareTo(org.sonatype.aether.version.Version v) {
- if (!(v instanceof OsgiVersion))
- return 0;
- OsgiVersion ov = (OsgiVersion) v;
- return version.compareTo(ov.version);
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.aether.spring;
-
-import org.sonatype.aether.repository.Authentication;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.springframework.beans.factory.BeanNameAware;
-import org.springframework.beans.factory.FactoryBean;
-
-/** Simplifies the definition of a remote factory using Spring */
-public class RemoteRepositoryFactory implements BeanNameAware, FactoryBean {
- private String beanName;
- private String id;
- private String url;
- private String type = "default";
- private String username;
- private String password;
-
- public Object getObject() throws Exception {
- RemoteRepository remoteRepository = new RemoteRepository(
- id != null ? id : beanName, type, url);
- if (username != null) {
- Authentication authentication = new Authentication(username,
- password);
- remoteRepository.setAuthentication(authentication);
- }
- return remoteRepository;
- }
-
- public Class<?> getObjectType() {
- return RemoteRepository.class;
- }
-
- public boolean isSingleton() {
- return true;
- }
-
- public void setBeanName(String name) {
- this.beanName = name;
-
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.aether;
-
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-
-import junit.framework.TestCase;
-
-public class AetherUtilsTest extends TestCase {
- public void testConvertPathToArtifact() throws Exception {
- checkPathConversion("my.group.id:my-artifactId:pom:1.2.3",
- "/my/group/id/my-artifactId/1.2.3/my-artifactId-1.2.3.pom");
- checkPathConversion("my.group.id:my-artifactId:pom:1.2.3-SNAPSHOT",
- "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-1.2.3-SNAPSHOT.pom");
- checkPathConversion("my.group.id:my-artifactId:pom:myClassifier:1.2.3",
- "/my/group/id/my-artifactId/1.2.3/my-artifactId-1.2.3-myClassifier.pom");
- checkPathConversion(
- "my.group.id:my-artifactId:pom:myClassifier:1.2.3-SNAPSHOT",
- "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-1.2.3-SNAPSHOT-myClassifier.pom");
- checkPathConversion(
- "my.group.id:my-artifactId:pom:myClassifier:20110828.223836-2",
- "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-20110828.223836-2-myClassifier.pom");
- }
-
- public void testConvertPathToArtifactRealLife() throws Exception {
- checkPathConversion(
- "org.apache.maven.plugins:maven-antrun-plugin:pom:1.1",
- "org/apache/maven/plugins/maven-antrun-plugin/1.1/maven-antrun-plugin-1.1.pom");
- checkPathConversion(
- "org.apache.maven.plugins:maven-plugin-parent:pom:2.0.1",
- "org/apache/maven/plugins/maven-plugin-parent/2.0.1/maven-plugin-parent-2.0.1.pom");
- checkPathConversion(
- "org.apache.avalon.framework:avalon-framework-impl:pom:4.3.1",
- "org/apache/avalon/framework/avalon-framework-impl/4.3.1/avalon-framework-impl-4.3.1.pom");
- checkPathConversion(
- "org.apache.maven.shared:maven-dependency-tree:pom:1.2",
- "org/apache/maven/shared/maven-dependency-tree/1.2/maven-dependency-tree-1.2.pom");
- checkPathConversion(
- "org.argeo.maven.plugins:maven-argeo-osgi-plugin:pom:1.0.33",
- "org/argeo/maven/plugins/maven-argeo-osgi-plugin/1.0.33/maven-argeo-osgi-plugin-1.0.33.pom");
- checkPathConversion(
- "org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1",
- "org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom");
- }
-
- protected void checkPathConversion(String expectedArtifact, String path) {
- Artifact artifact = AetherUtils.convertPathToArtifact(path, null);
- if (expectedArtifact == null)
- assertNull(artifact);
- else
- assertEquals(new DefaultArtifact(expectedArtifact), artifact);
- }
-}