You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/11/23 08:24:06 UTC
svn commit: r719954 - in /geronimo/gshell/trunk: gshell-assembly/
gshell-assembly/src/main/underlay/etc/
gshell-support/gshell-artifact-ivy/src/main/java/org/apache/geronimo/gshell/artifact/ivy/
gshell-support/gshell-artifact-maven/src/main/java/org/ap...
Author: jdillon
Date: Sat Nov 22 23:24:05 2008
New Revision: 719954
URL: http://svn.apache.org/viewvc?rev=719954&view=rev
Log:
Some work to get maven-artifact working again, still dosent't its a *ucking huge pile of crap all this maven *hit
Added:
geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactManagerConfigurator.java (with props)
Modified:
geronimo/gshell/trunk/gshell-assembly/pom.xml
geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/src/main/java/org/apache/geronimo/gshell/artifact/ivy/ArtifactResolverImpl.java
geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactResolverImpl.java
geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/DefaultArtifactManager.java
geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/gshell/components.xml
geronimo/gshell/trunk/gshell-support/gshell-artifact-mercury/src/main/java/org/apache/geronimo/gshell/artifact/mercury/ArtifactResolverImpl.java
Modified: geronimo/gshell/trunk/gshell-assembly/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-assembly/pom.xml?rev=719954&r1=719953&r2=719954&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-assembly/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-assembly/pom.xml Sat Nov 22 23:24:05 2008
@@ -51,7 +51,7 @@
<dependency>
<groupId>org.apache.geronimo.gshell.support</groupId>
- <artifactId>gshell-artifact-ivy</artifactId>
+ <artifactId>gshell-artifact-maven</artifactId>
</dependency>
<dependency>
Modified: geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml?rev=719954&r1=719953&r2=719954&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml (original)
+++ geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml Sat Nov 22 23:24:05 2008
@@ -28,6 +28,16 @@
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+ <bean class="org.apache.geronimo.gshell.artifact.maven.ArtifactManagerConfigurator">
+ <constructor-arg ref="artifactManager"/>
+ <property name="localRepository" value="${gshell.home}/var/repository"/>
+ <property name="remoteRepositories">
+ <map>
+ <entry key="cache" value="file:${user.home}/.m2/repository"/>
+ </map>
+ </property>
+ </bean>
+
<bean class="org.apache.geronimo.gshell.application.model.ApplicationModel">
<property name="groupId" value="org.apache.geronimo.gshell"/>
<property name="artifactId" value="gshell"/>
Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/src/main/java/org/apache/geronimo/gshell/artifact/ivy/ArtifactResolverImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/src/main/java/org/apache/geronimo/gshell/artifact/ivy/ArtifactResolverImpl.java?rev=719954&r1=719953&r2=719954&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/src/main/java/org/apache/geronimo/gshell/artifact/ivy/ArtifactResolverImpl.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/src/main/java/org/apache/geronimo/gshell/artifact/ivy/ArtifactResolverImpl.java Sat Nov 22 23:24:05 2008
@@ -87,8 +87,6 @@
Artifact resolved = createArtifact(downloadReport.getArtifact());
resolved.setFile(downloadReport.getLocalFile());
result.artifacts.add(resolved);
-
- log.debug(" {}", resolved.getId());
}
}
catch (Exception e) {
Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactManagerConfigurator.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactManagerConfigurator.java?rev=719954&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactManagerConfigurator.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactManagerConfigurator.java Sat Nov 22 23:24:05 2008
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.geronimo.gshell.artifact.maven;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.net.URI;
+import java.util.Map;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class ArtifactManagerConfigurator
+{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private final ArtifactManager artifactManager;
+
+ private File localRepository;
+
+ private Map<String, URI> remoteRepositories;
+
+ public ArtifactManagerConfigurator(final ArtifactManager artifactManager) {
+ assert artifactManager != null;
+ this.artifactManager = artifactManager;
+ }
+
+ public void setLocalRepository(final File dir) {
+ assert dir != null;
+ this.localRepository = dir;
+ }
+
+ public void setRemoteRepositories(final Map<String,URI> repositories) {
+ assert repositories != null;
+ this.remoteRepositories = repositories;
+ }
+
+ // @PostConstruct
+ public void init() throws Exception {
+ ArtifactRepositoryManager repositoryManager = artifactManager.getRepositoryManager();
+
+ if (localRepository != null) {
+ repositoryManager.setLocalRepository(localRepository);
+ }
+
+ if (remoteRepositories != null) {
+ for (Map.Entry<String,URI> entry : remoteRepositories.entrySet()) {
+ repositoryManager.addRemoteRepository(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactManagerConfigurator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactManagerConfigurator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactManagerConfigurator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactResolverImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactResolverImpl.java?rev=719954&r1=719953&r2=719954&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactResolverImpl.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactResolverImpl.java Sat Nov 22 23:24:05 2008
@@ -20,18 +20,99 @@
package org.apache.geronimo.gshell.artifact.maven;
import org.apache.geronimo.gshell.artifact.ArtifactResolver;
+import org.apache.geronimo.gshell.artifact.Artifact;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Set;
+import java.util.LinkedHashSet;
/**
- * ???
+ * <a href="http://maven.apache.org">Apache Maven (maven-artifact)</a> based {@link ArtifactResolver}.
*
* @version $Rev$ $Date$
*/
public class ArtifactResolverImpl
implements ArtifactResolver
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private final ArtifactManager artifactManager;
+
+ public ArtifactResolverImpl(final ArtifactManager artifactManager) {
+ assert artifactManager != null;
+ this.artifactManager = artifactManager;
+ }
+
public Result resolve(final Request request) throws Failure {
assert request != null;
-
- return null;
+
+ ArtifactResolutionRequest _request = new ArtifactResolutionRequest();
+
+ if (request.artifact != null) {
+ _request.setArtifact(createArtifact(request.artifact));
+ }
+
+ if (request.artifacts != null) {
+ Set<org.apache.maven.artifact.Artifact> artifacts = new LinkedHashSet<org.apache.maven.artifact.Artifact>();
+
+ for (Artifact source : request.artifacts) {
+ org.apache.maven.artifact.Artifact artifact = createArtifact(source);
+ artifacts.add(artifact);
+ }
+
+ _request.setArtifactDependencies(artifacts);
+ }
+
+ if (request.filter != null) {
+ _request.setFilter(new ArtifactFilter() {
+ public boolean include(final org.apache.maven.artifact.Artifact source) {
+ assert source != null;
+ Artifact artifact = createArtifact(source);
+ return request.filter.accept(artifact);
+ }
+ });
+ }
+
+ Result result = new Result();
+ try {
+ ArtifactResolutionResult _result = artifactManager.resolve(_request);
+ result.artifacts = new LinkedHashSet<Artifact>();
+
+ for (org.apache.maven.artifact.Artifact source : _result.getArtifacts()) {
+ Artifact artifact = createArtifact(source);
+ result.artifacts.add(artifact);
+ }
+ }
+ catch (ResolutionException e) {
+ throw new Failure(e);
+ }
+
+ return result;
+ }
+
+ private Artifact createArtifact(final org.apache.maven.artifact.Artifact source) {
+ assert source != null;
+
+ Artifact artifact = new Artifact();
+ artifact.setGroup(source.getGroupId());
+ artifact.setName(source.getArtifactId());
+ artifact.setVersion(source.getVersion());
+ artifact.setClassifier(source.getClassifier());
+ artifact.setType(source.getType());
+
+ return artifact;
+ }
+
+ private org.apache.maven.artifact.Artifact createArtifact(final Artifact source) {
+ assert source != null;
+
+ ArtifactFactory factory = artifactManager.getArtifactFactory();
+
+ return factory.createArtifact(source.getGroup(), source.getName(), source.getVersion(), null, source.getType());
}
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/DefaultArtifactManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/DefaultArtifactManager.java?rev=719954&r1=719953&r2=719954&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/DefaultArtifactManager.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/DefaultArtifactManager.java Sat Nov 22 23:24:05 2008
@@ -48,10 +48,6 @@
{
private final Logger log = LoggerFactory.getLogger(getClass());
- //
- // TODO: Look at implementing this with mercury
- //
-
@Requirement
private ArtifactFactory artifactFactory;
@@ -103,7 +99,7 @@
// If there is no artifact, then assume we want to do some full transitive resolve and install a dummy artifact
Artifact artifact = request.getArtifact();
if (artifact == null) {
- artifact = artifactFactory.createArtifact("dummy", "dummy", "dummy", null, "jar");
+ artifact = artifactFactory.createArtifact("dummy", "dummy", "dummy", null, "dummy");
request.setArtifact(artifact);
}
Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/gshell/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/gshell/components.xml?rev=719954&r1=719953&r2=719954&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/gshell/components.xml (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/gshell/components.xml Sat Nov 22 23:24:05 2008
@@ -26,5 +26,9 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="artifactManager" class="org.apache.geronimo.gshell.artifact.maven.ArtifactManagerFactory"/>
+
+ <bean id="artifactResolver" class="org.apache.geronimo.gshell.artifact.maven.ArtifactResolverImpl">
+ <constructor-arg ref="artifactManager"/>
+ </bean>
</beans>
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact-mercury/src/main/java/org/apache/geronimo/gshell/artifact/mercury/ArtifactResolverImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-mercury/src/main/java/org/apache/geronimo/gshell/artifact/mercury/ArtifactResolverImpl.java?rev=719954&r1=719953&r2=719954&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-mercury/src/main/java/org/apache/geronimo/gshell/artifact/mercury/ArtifactResolverImpl.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-mercury/src/main/java/org/apache/geronimo/gshell/artifact/mercury/ArtifactResolverImpl.java Sat Nov 22 23:24:05 2008
@@ -22,7 +22,7 @@
import org.apache.geronimo.gshell.artifact.ArtifactResolver;
/**
- * ???
+ * <a href="http://maven.apache.org">Apache Maven (mercury)</a> based {@link ArtifactResolver}.
*
* @version $Rev$ $Date$
*/