maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject cvs commit: maven-components/maven-plugins/maven-repository-plugin .cvsignore pom.xml
Date Thu, 17 Mar 2005 15:02:46 GMT
carlos      2005/03/17 07:02:46

  Added:       maven-plugins/maven-repository-plugin/src/main/java/org/apache/maven/plugin/repository
                        ChecksumValidateMojo.java
               maven-plugins/maven-repository-plugin .cvsignore pom.xml
  Log:
  Mojo to manage repository
  
  Revision  Changes    Path
  1.1                  maven-components/maven-plugins/maven-repository-plugin/src/main/java/org/apache/maven/plugin/repository/ChecksumValidateMojo.java
  
  Index: ChecksumValidateMojo.java
  ===================================================================
  package org.apache.maven.plugin.repository;
  
  /*
   * Copyright 2001-2004 The Apache Software Foundation.
   *
   * 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.
   */
  
  import java.io.File;
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Set;
  
  import org.apache.maven.artifact.Artifact;
  import org.apache.maven.artifact.manager.WagonManager;
  import org.apache.maven.artifact.repository.ArtifactRepository;
  import org.apache.maven.plugin.AbstractPlugin;
  import org.apache.maven.plugin.PluginExecutionRequest;
  import org.apache.maven.plugin.PluginExecutionResponse;
  import org.apache.maven.repository.ChecksumValidator;
  import org.apache.maven.repository.RepositoryTools;
  import org.apache.maven.wagon.TransferFailedException;
  import org.apache.maven.wagon.UnsupportedProtocolException;
  import org.apache.maven.wagon.Wagon;
  import org.apache.maven.wagon.observers.ChecksumObserver;
  
  /**
   * @goal checksumvalidate
   * 
   * @description validates checksums in local repository
   * 
   * @parameter
   *  name="localRepository"
   *  type="org.apache.maven.artifact.repository.ArtifactRepository"
   *  required="true"
   *  validator=""
   *  expression="#localRepository"
   *  description=""
   * 
   * @parameter
   *  name="wagonManager"
   *  type="org.apache.maven.artifact.manager.WagonManager"
   *  required="true"
   *  validator=""
   *  expression="#component.org.apache.maven.artifact.manager.WagonManager"
   *  description=""
   */
  public class ChecksumValidateMojo
      extends AbstractPlugin
  {
      
      public void execute( PluginExecutionRequest request, PluginExecutionResponse response
) throws Exception
      {
          ArtifactRepository localRepository = (ArtifactRepository) request.getParameter(
"localRepository" );
  
          WagonManager wagonManager = (WagonManager) request.getParameter( "wagonManager"
);
  
          //ChecksumValidator checksumValidator = new ChecksumValidator();
  
          List artifacts = RepositoryTools.getAllArtifacts( localRepository );
  
          Iterator it = artifacts.iterator();
  
          while ( it.hasNext() )
          {
              Artifact artifact = (Artifact) it.next();
              
              System.out.println( artifact );
              boolean b = isValidChecksum( wagonManager, artifact, localRepository );
              
              if (!b) System.out.println( "NOT VALID" );
              
  //            if ( !artifact.getChecksumFile().exists() )
  //            {
  //                // System.out.println( artifact );
  //            }
  //            else if ( !isValidChecksum( wagonManager, artifact, localRepository ) )
  //            {
  //                System.out.println( artifact );
  //            }
          }
      }
  
      public boolean isValidChecksum( WagonManager wagonManager, Artifact artifact, ArtifactRepository
localRepository )
          throws TransferFailedException, UnsupportedProtocolException
      {
          ChecksumObserver checksumObserver = new ChecksumObserver();
  
          ArtifactRepository tempRepository = new ArtifactRepository();
  
          File f = new File( "target/test-classes/temp/" );
  
          tempRepository.setUrl( "file://" + f.getPath() );
  
          Set set = new HashSet();
  
          set.add( localRepository );
  
          Wagon wagon = wagonManager.getWagon( "file://" );
  
          wagon.addTransferListener( checksumObserver );
  
          wagonManager.get( artifact, set, tempRepository );
  
          // File file = artifact.getFile();
          //
          // TransferEvent transferEvent = new TransferEvent( wagon, new
          // Resource(), TransferEvent.TRANSFER_COMPLETED,
          // TransferEvent.REQUEST_GET );
          //
          // checksumObserver.transferStarted( transferEvent );
          // checksumObserver.transferProgress(transferEvent, file);
  
          return true;
      }
  
  }
  
  
  
  1.1                  maven-components/maven-plugins/maven-repository-plugin/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  target
  *~
  *.log
  .classpath
  .project
  *.ipr
  *.iws
  *.iml
  
  
  
  1.1                  maven-components/maven-plugins/maven-repository-plugin/pom.xml
  
  Index: pom.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <project>
    <parent>
      <groupId>maven</groupId>
      <artifactId>maven-plugin-parent</artifactId>
      <version>2.0-SNAPSHOT</version>
    </parent>
    <groupId>maven</groupId>
    <artifactId>maven-repository-plugin</artifactId>
    <type>plugin</type>  
    <name>Maven Repository Plugin</name>
    <version>1.0-SNAPSHOT</version>
    <package>org.apache.maven.plugin.repository</package>
    <dependencies>
      <dependency>
        <groupId>maven</groupId>
        <artifactId>maven-repository-tools</artifactId>
        <version>1.0-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>maven</groupId>
        <artifactId>wagon-file</artifactId>
        <version>1.0-alpha-2-SNAPSHOT</version>
      </dependency>
    </dependencies>
  </project>
  
  
  

Mime
View raw message