maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason van Zyl <ja...@sonatype.com>
Subject Re: svn commit: r1086237 - in /maven/sandbox/trunk/examples: MNG-3989-maven3/ MNG-3989-maven3/modules/ MNG-3989-maven3/modules/repository/ MNG-3989-maven3/repository/src/repository/ extensions/bundled-repository-extension/ extensions/bundled-repository-ext...
Date Mon, 28 Mar 2011 14:00:12 GMT
As an extension that people could optionally download I think would be fine.

I'd be -1 on including this in the core.

On Mar 28, 2011, at 9:55 AM, brett@apache.org wrote:

> Author: brett
> Date: Mon Mar 28 13:55:50 2011
> New Revision: 1086237
> 
> URL: http://svn.apache.org/viewvc?rev=1086237&view=rev
> Log:
> draft of a way that MNG-3989 could be handled in Maven 3.x, though there are probably
better ways
> 
> Added:
>    maven/sandbox/trunk/examples/MNG-3989-maven3/
>      - copied from r1086232, maven/sandbox/trunk/examples/MNG-3989/
>    maven/sandbox/trunk/examples/MNG-3989-maven3/modules/repository/
>      - copied from r1086232, maven/sandbox/trunk/examples/MNG-3989/repository/src/repository/
>    maven/sandbox/trunk/examples/extensions/bundled-repository-extension/   (with props)
>    maven/sandbox/trunk/examples/extensions/bundled-repository-extension/pom.xml   (with
props)
>    maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/
>    maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/
>    maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/java/
>    maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/java/org/
>    maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/java/org/apache/
>    maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/java/org/apache/maven/
>    maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/java/org/apache/maven/examples/
>    maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/java/org/apache/maven/examples/bundledrepository/
>    maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/java/org/apache/maven/examples/bundledrepository/BundledRepositoryMavenExtension.java
  (with props)
> Removed:
>    maven/sandbox/trunk/examples/MNG-3989-maven3/repository/src/repository/
> Modified:
>    maven/sandbox/trunk/examples/MNG-3989-maven3/modules/pom.xml
>    maven/sandbox/trunk/examples/MNG-3989-maven3/pom.xml
> 
> Modified: maven/sandbox/trunk/examples/MNG-3989-maven3/modules/pom.xml
> URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/examples/MNG-3989-maven3/modules/pom.xml?rev=1086237&r1=1086232&r2=1086237&view=diff
> ==============================================================================
> --- maven/sandbox/trunk/examples/MNG-3989-maven3/modules/pom.xml (original)
> +++ maven/sandbox/trunk/examples/MNG-3989-maven3/modules/pom.xml Mon Mar 28 13:55:50
2011
> @@ -9,15 +9,16 @@
>   <artifactId>modules</artifactId>
>   <name>modules</name>
>   <packaging>pom</packaging>
> -  <dependencies>
> -    <dependency>
> -      <groupId>test.MNG3989</groupId>
> -      <artifactId>repository</artifactId>
> -      <version>${project.version}</version>
> -      <type>pom</type>
> -    </dependency>
> -  </dependencies>
>   <modules>
>     <module>my-artifact</module>
>   </modules>
> +  <build>
> +    <extensions>
> +      <extension>
> +        <groupId>org.apache.maven.examples</groupId>
> +        <artifactId>bundled-repository-extension</artifactId>
> +        <version>1.0-SNAPSHOT</version>
> +      </extension>
> +    </extensions>
> +  </build>
> </project>
> 
> Modified: maven/sandbox/trunk/examples/MNG-3989-maven3/pom.xml
> URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/examples/MNG-3989-maven3/pom.xml?rev=1086237&r1=1086232&r2=1086237&view=diff
> ==============================================================================
> --- maven/sandbox/trunk/examples/MNG-3989-maven3/pom.xml (original)
> +++ maven/sandbox/trunk/examples/MNG-3989-maven3/pom.xml Mon Mar 28 13:55:50 2011
> @@ -7,7 +7,6 @@
>   <name>MNG-3989</name>
>   <packaging>pom</packaging>
>   <modules>
> -    <module>repository</module>
>     <module>modules</module>
>   </modules>
> </project>
> 
> Propchange: maven/sandbox/trunk/examples/extensions/bundled-repository-extension/
> ------------------------------------------------------------------------------
> --- svn:ignore (added)
> +++ svn:ignore Mon Mar 28 13:55:50 2011
> @@ -0,0 +1 @@
> +target
> 
> Added: maven/sandbox/trunk/examples/extensions/bundled-repository-extension/pom.xml
> URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/examples/extensions/bundled-repository-extension/pom.xml?rev=1086237&view=auto
> ==============================================================================
> --- maven/sandbox/trunk/examples/extensions/bundled-repository-extension/pom.xml (added)
> +++ maven/sandbox/trunk/examples/extensions/bundled-repository-extension/pom.xml Mon
Mar 28 13:55:50 2011
> @@ -0,0 +1,41 @@
> +<?xml version="1.0"?>
> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
> +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> +  <modelVersion>4.0.0</modelVersion>
> +  <groupId>org.apache.maven.examples</groupId>
> +  <version>1.0-SNAPSHOT</version>
> +  <artifactId>bundled-repository-extension</artifactId>
> +  <name>bundled-repository-extension</name>
> +  <properties>
> +    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> +  </properties>
> +  <dependencies>
> +    <dependency>
> +      <groupId>org.apache.maven</groupId>
> +      <artifactId>maven-compat</artifactId>
> +      <version>3.0</version>
> +    </dependency>
> +    <dependency>
> +      <groupId>org.apache.maven</groupId>
> +      <artifactId>maven-core</artifactId>
> +      <version>3.0</version>
> +    </dependency>
> +  </dependencies>
> +  <build>
> +    <plugins>
> +      <plugin>
> +        <groupId>org.codehaus.plexus</groupId>
> +        <artifactId>plexus-component-metadata</artifactId>
> +        <version>1.5.5</version>
> +        <executions>
> +          <execution>
> +            <goals>
> +              <goal>generate-metadata</goal>
> +              <goal>generate-test-metadata</goal>
> +            </goals>
> +          </execution>
> +        </executions>
> +      </plugin>
> +    </plugins>
> +  </build>
> +</project>
> 
> Propchange: maven/sandbox/trunk/examples/extensions/bundled-repository-extension/pom.xml
> ------------------------------------------------------------------------------
>    svn:eol-style = native
> 
> Added: maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/java/org/apache/maven/examples/bundledrepository/BundledRepositoryMavenExtension.java
> URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/java/org/apache/maven/examples/bundledrepository/BundledRepositoryMavenExtension.java?rev=1086237&view=auto
> ==============================================================================
> --- maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/java/org/apache/maven/examples/bundledrepository/BundledRepositoryMavenExtension.java
(added)
> +++ maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/java/org/apache/maven/examples/bundledrepository/BundledRepositoryMavenExtension.java
Mon Mar 28 13:55:50 2011
> @@ -0,0 +1,61 @@
> +package org.apache.maven.examples.bundledrepository;
> +
> +import org.apache.maven.AbstractMavenLifecycleParticipant;
> +import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
> +import org.apache.maven.artifact.repository.ArtifactRepository;
> +import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
> +import org.apache.maven.execution.MavenSession;
> +import org.apache.maven.execution.RuntimeInformation;
> +import org.apache.maven.project.MavenProject;
> +import org.codehaus.plexus.component.annotations.Component;
> +import org.codehaus.plexus.component.annotations.Requirement;
> +import org.codehaus.plexus.logging.Logger;
> +
> +import java.io.File;
> +import java.net.MalformedURLException;
> +import java.util.List;
> +import java.util.ArrayList;
> +
> +@Component( role = AbstractMavenLifecycleParticipant.class, hint = "bundledrepository"
)
> +public class BundledRepositoryMavenExtension
> +    extends AbstractMavenLifecycleParticipant
> +{
> +    @Requirement
> +    private Logger logger;
> +
> +    @Requirement
> +    RuntimeInformation runtime;
> +
> +    @Requirement
> +    private ArtifactRepositoryFactory factory;
> +
> +    public void afterProjectsRead( MavenSession session ) {
> +        // Currently a dumb implementation - some searching & configuration via
execution properties might help
> +        //  or better adding in to the resolution model with a new repository type
> +
> +        // Search for projects that have a repository
> +        boolean found = false;
> +        List<ArtifactRepository> artifactRepositories = new ArrayList<ArtifactRepository>();
> +        for ( MavenProject project : session.getProjects() ) {
> +            File repositoryDir = new File( project.getBasedir(), "repository" );
> +            if ( repositoryDir.exists() && repositoryDir.isDirectory() ) {
> +                try {
> +                    logger.debug( "Found repository in project " + project.getId() +
" under " + repositoryDir );
> +                    artifactRepositories.add( factory.createArtifactRepository( "bundledrepository",
repositoryDir.toURL().toExternalForm(), new DefaultRepositoryLayout(), null, null ) );
> +                }
> +                catch ( MalformedURLException e ) {
> +                    logger.error( "Ignoring bad URL: " + e.getMessage() );
> +                }
> +            }
> +        }
> +
> +        // Add the repository to all projects
> +        for ( MavenProject project : session.getProjects() ) {
> +            List<ArtifactRepository> repos = new ArrayList<ArtifactRepository>(
project.getRemoteArtifactRepositories() );
> +            repos.addAll( artifactRepositories );
> +            project.setRemoteArtifactRepositories( repos );
> +            logger.debug( "Project " + project.getId() + " now using repositories: "
+ repos );
> +        }
> +    }
> +
> +}
> 
> Propchange: maven/sandbox/trunk/examples/extensions/bundled-repository-extension/src/main/java/org/apache/maven/examples/bundledrepository/BundledRepositoryMavenExtension.java
> ------------------------------------------------------------------------------
>    svn:eol-style = native
> 
> 

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
http://twitter.com/jvanzyl
---------------------------------------------------------

We all have problems. How we deal with them is a measure of our worth.

 -- Unknown




Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message