geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r425305 - in /geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car: AbstractCarMojo.java InstallConfigMojo.java InstallMojo.java PackageMojo.java PlanProcessorMojo.java
Date Tue, 25 Jul 2006 06:27:10 GMT
Author: jdillon
Date: Mon Jul 24 23:27:10 2006
New Revision: 425305

URL: http://svn.apache.org/viewvc?rev=425305&view=rev
Log:
Using File instead of String for fields that really point to local files
Added @required to fields that are... well required
Using default-value instead of expression for non-expression default values for fields
Removed redundant null checks, Mojo framework will handle this for us
Moved generateExplicitVersionProperties() to AbstractCarMojo so we can share this
car:installConfigs now uses generateExplicitVersionProperties() instead of ../../etc/*
Removed local MavenProject, picked up from AbstractCarMojo & breaks helpers when it is
present in subclass
Minor formatting normalization

Modified:
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/AbstractCarMojo.java
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallConfigMojo.java
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallMojo.java
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageMojo.java
    geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java

Modified: geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/AbstractCarMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/AbstractCarMojo.java?rev=425305&r1=425304&r2=425305&view=diff
==============================================================================
--- geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/AbstractCarMojo.java
(original)
+++ geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/AbstractCarMojo.java
Mon Jul 24 23:27:10 2006
@@ -29,11 +29,16 @@
 import org.apache.maven.model.Exclusion;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.FileOutputStream;
+import java.io.BufferedOutputStream;
+
 import java.util.Set;
 import java.util.List;
 import java.util.Iterator;
 import java.util.HashSet;
 import java.util.ArrayList;
+import java.util.Properties;
 
 /**
  * Support for <em>packaging</em> Mojos.
@@ -128,5 +133,26 @@
 
     protected Set getProjectArtifacts() {
         return getProjectArtifacts(project);
+    }
+    
+    protected void generateExplicitVersionProperties(final File outputFile) throws IOException
{
+        log.debug("Generating explicit version properties: " + outputFile);
+
+        // Generate explicit_versions for all our dependencies...
+        Properties props = new Properties();
+        Iterator iter = getProjectArtifacts().iterator();
+        while (iter.hasNext()) {
+            Artifact artifact = (Artifact)iter.next();
+            String name = artifact.getGroupId() + "/" + artifact.getArtifactId() + "//" +
artifact.getType();
+            String value = artifact.getVersion();
+
+            log.debug("Setting " + name + "=" + value);
+            props.setProperty(name, value);
+        }
+
+        BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(outputFile));
+        props.store(output, null);
+        output.flush();
+        output.close();
     }
 }

Modified: geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallConfigMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallConfigMojo.java?rev=425305&r1=425304&r2=425305&view=diff
==============================================================================
--- geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallConfigMojo.java
(original)
+++ geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallConfigMojo.java
Mon Jul 24 23:27:10 2006
@@ -42,6 +42,7 @@
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+
 import java.util.Iterator;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
@@ -61,15 +62,6 @@
     public static final FileWriteMonitor LOG_COPY_START = new StartFileWriteMonitor();
 
     /**
-     * The Maven Project.
-     *
-     * @parameter expression="${project}"
-     * @required
-     * @readonly
-     */
-    protected MavenProject project;
-
-    /**
      * Root file of the TargetRepository.
      *
      * @parameter expression="${project.build.directory}"
@@ -80,6 +72,7 @@
      * The location of the target repository relative to targetRoot.
      * 
      * @parameter default-value="archive-tmp/repository"
+     * @required
      */
     private String targetRepository;
 
@@ -96,17 +89,17 @@
      * Location of the source repository for the dependencies
      *
      * @parameter expression="${localRepository}"
+     * @required
      */
     private ArtifactRepository sourceRepository;
     
-    //
-    // FIXME: Need to generate this puppy just like we do for the packaging plugin
-    //
-    
     /**
-     * @parameter expression="${basedir}/../../etc/explicit_versions.properties"
+     * The location where the properties mapping will be generated.
+     *
+     * @parameter expression="${project.build.directory}/explicit-versions.properties"
+     * @required
      */
-    private String explicitResolutionLocation;
+    private File explicitResolutionProperties;
 
     private ArtifactResolver artifactResolver;
 
@@ -117,11 +110,13 @@
     private RepositoryConfigurationStore sourceStore;
 
     protected void doExecute() throws Exception {
+        generateExplicitVersionProperties(explicitResolutionProperties);
+        
         sourceRepo = new Maven2Repository(new File(sourceRepository.getBasedir()));
         sourceStore = new RepositoryConfigurationStore(sourceRepo);
 
         File targetRepoFile = new File(targetRoot, targetRepository);
-        if (  !targetRepoFile.exists() ) {
+        if (!targetRepoFile.exists()) {
             targetRepoFile.mkdirs();
         }
         
@@ -130,8 +125,11 @@
 
         Artifact configId;
         ArtifactManager artifactManager = new DefaultArtifactManager();
-        artifactResolver = new ExplicitDefaultArtifactResolver(explicitResolutionLocation,
-                artifactManager, Collections.singleton(sourceRepo), null);
+        artifactResolver = new ExplicitDefaultArtifactResolver(
+            explicitResolutionProperties.getPath(),
+            artifactManager,
+            Collections.singleton(sourceRepo),
+            null);
 
         if ( artifact != null ) {
             configId = Artifact.create(artifact);
@@ -139,9 +137,9 @@
         }
         else {
             Iterator itr = getDependencies().iterator();
-            while ( itr.hasNext() ) {
-                org.apache.maven.artifact.Artifact  mavenArtifact = (org.apache.maven.artifact.Artifact)
itr.next();
-                if ( "car".equals(mavenArtifact.getType()) ) {
+            while (itr.hasNext()) {
+                org.apache.maven.artifact.Artifact mavenArtifact = (org.apache.maven.artifact.Artifact)
itr.next();
+                if ("car".equals(mavenArtifact.getType())) {
                     configId = new Artifact(mavenArtifact.getGroupId(), mavenArtifact.getArtifactId(),
mavenArtifact.getVersion(), "car");
                     execute(configId);
                 }
@@ -157,15 +155,13 @@
     protected Set getDependencies() {
         Set dependenciesSet = new HashSet();
 
-        if ( project.getArtifact() != null && project.getArtifact().getFile() !=
null )
-        {
+        if (project.getArtifact() != null && project.getArtifact().getFile() != null)
{
             dependenciesSet.add( project.getArtifact() );
         }
 
         Set projectArtifacts = project.getArtifacts();
-        if ( projectArtifacts != null )
-        {
-            dependenciesSet.addAll( projectArtifacts );
+        if (projectArtifacts != null) {
+            dependenciesSet.addAll(projectArtifacts);
         }
 
         return dependenciesSet;

Modified: geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallMojo.java?rev=425305&r1=425304&r2=425305&view=diff
==============================================================================
--- geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallMojo.java
(original)
+++ geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/InstallMojo.java
Mon Jul 24 23:27:10 2006
@@ -40,32 +40,38 @@
     private static final Class[] STORE_ARGS = { WritableListableRepository.class };
 
     /**
-     * @parameter expression="org.apache.geronimo.system.repository.Maven2Repository"
+     * @parameter default-value="org.apache.geronimo.system.repository.Maven2Repository"
+     * @required
      */
     private String sourceRepositoryClass;
 
     /**
-     * @parameter expression="org.apache.geronimo.system.repository.Maven2Repository"
+     * @parameter default-value="org.apache.geronimo.system.repository.Maven2Repository"
+     * @required
      */
     private String targetRepositoryClass;
 
     /**
-     * @parameter expression="org.apache.geronimo.system.configuration.RepositoryConfigurationStore"
+     * @parameter default-value="org.apache.geronimo.system.configuration.RepositoryConfigurationStore"
+     * @required
      */
     private String sourceConfigurationStoreClass;
 
     /**
-     * @parameter expression="org.apache.geronimo.plugin.car.MavenConfigStore"
+     * @parameter default-value="org.apache.geronimo.plugin.car.MavenConfigStore"
+     * @required
      */
     private String targetConfigurationStoreClass;
 
     /**
      * @parameter expression="${project.build.directory}/repository"
+     * @required
      */
     private File sourceRepositoryLocation;
 
     /**
      * @parameter expression="${settings.LocalRepository}"
+     * @required
      */
     private File targetRepositoryLocation;
 

Modified: geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageMojo.java?rev=425305&r1=425304&r2=425305&view=diff
==============================================================================
--- geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageMojo.java
(original)
+++ geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackageMojo.java
Mon Jul 24 23:27:10 2006
@@ -77,6 +77,7 @@
 
     /**
      * @parameter expression="org.apache.geronimo.configs/geronimo-gbean-deployer/${geronimoVersion}/car?j2eeType=Deployer,name=Deployer"
+     * @required
      */
     private String deployerName;
 
@@ -131,12 +132,14 @@
     private ArrayList classPath;
 
     /**
-     * @parameter expression="lib/endorsed"
+     * @parameter default-value="lib/endorsed"
+     * @required
      */
     private String endorsedDirs;
 
     /**
-     * @parameter expression="lib/ext"
+     * @parameter default-value="lib/ext"
+     * @required
      */
     private String extensionDirs;
 
@@ -148,7 +151,8 @@
     private File explicitResolutionProperties;
 
     /**
-     * @parameter expression="WARN"
+     * @parameter default-value="WARN"
+     * @required
      */
     private String logLevel;
 
@@ -169,7 +173,7 @@
         }
         log.debug("Deployment configs: " + deploymentConfigs);
 
-        generateExplicitVersionProperties();
+        generateExplicitVersionProperties(explicitResolutionProperties);
 
         if (boot) {
             executeBootShell();
@@ -180,27 +184,6 @@
 
         // copy configuration from target/repository to maven repo
         project.getArtifact().setFile(packageFile);
-    }
-
-    private void generateExplicitVersionProperties() throws IOException {
-        log.debug("Generating explicit version properties: " + explicitResolutionProperties);
-
-        // Generate explicit_versions for all our dependencies...
-        Properties props = new Properties();
-        Iterator iter = getProjectArtifacts().iterator();
-        while (iter.hasNext()) {
-            Artifact artifact = (Artifact)iter.next();
-            String name = artifact.getGroupId() + "/" + artifact.getArtifactId() + "//" +
artifact.getType();
-            String value = artifact.getVersion();
-
-            log.debug("Setting " + name + "=" + value);
-            props.setProperty(name, value);
-        }
-
-        BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(explicitResolutionProperties));
-        props.store(output, null);
-        output.flush();
-        output.close();
     }
 
     public void executeBootShell() throws Exception {

Modified: geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java?rev=425305&r1=425304&r2=425305&view=diff
==============================================================================
--- geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java
(original)
+++ geronimo/sandbox/svkmerge/m2migration/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java
Mon Jul 24 23:27:10 2006
@@ -65,23 +65,27 @@
 
     /**
      * @parameter expression="${basedir}/src/plan"
+     * @required
      */
-    private String sourceDir;
+    private File sourceDir;
 
     /**
      * @parameter expression="${project.build.directory}/plan"
+     * @required
      */
-    private String targetDir;
+    private File targetDir;
 
     /**
-     * @parameter expression="plan.xml"
+     * @parameter default-value="plan.xml"
+     * @required
      */
-    private String planFile;
+    private String planFileName;
 
     /**
      * @parameter expression="${project.build.directory}/plan/plan.xml"
+     * @required
      */
-    private String targetFile;
+    private File targetFile;
 
     //
     // FIXME: Resolve what to do about this comment...
@@ -112,27 +116,19 @@
     }
 
     protected void doExecute() throws Exception {
-        if (project == null) {
-            throw new RuntimeException("project not supplied");
-        }
-        if (targetDir == null) {
-            throw new RuntimeException("No target directory supplied");
-        }
-        if (planFile == null) {
-            throw new RuntimeException("No source plan supplied");
-        }
-        if (targetFile == null) {
-            throw new RuntimeException("No target plan supplied");
-        }
-
+        //
+        // FIXME: Do not need velocity here, we only need to filter,
+        //        could use resources plugin to do this for us, or
+        //        implement what resources plugin does here
+        //
+        
         VelocityContext context = createContext();
 
-        File sourceD = new File(sourceDir);
         VelocityEngine velocity = new VelocityEngine();
-        velocity.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, sourceD.getAbsolutePath());
+        velocity.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, sourceDir.getAbsolutePath());
         velocity.init();
 
-        Template template = velocity.getTemplate(planFile);
+        Template template = velocity.getTemplate(planFileName);
         StringWriter writer = new StringWriter();
         template.merge(context, writer);
 
@@ -145,8 +141,7 @@
 
         try {
             mergeEnvironment(xmlCursor, configId, dependencies);
-            File targetDir = new File(this.targetDir);
-
+            
             if (targetDir.exists()) {
                 if (!targetDir.isDirectory()) {
                     throw new RuntimeException("TargetDir: " + this.targetDir + " exists
and is not a directory");
@@ -156,10 +151,11 @@
                 targetDir.mkdirs();
             }
 
-            File output = new File(targetFile);
             XmlOptions xmlOptions = new XmlOptions();
             xmlOptions.setSavePrettyPrint();
-            doc.save(output, xmlOptions);
+            doc.save(targetFile, xmlOptions);
+            
+            log.info("Generated: " + targetFile);
         }
         finally {
             xmlCursor.dispose();
@@ -254,10 +250,13 @@
         //!"org.apache.geronimo.specs".equals(groupId) jacc spec needed in plan.xml
         if ("jar".equalsIgnoreCase(type) && !"junit".equals(groupId)) {
             if (dependency.getVersion() != null) {
-                artifact = new Artifact(artifact.getGroupId(), artifact.getArtifactId(),
dependency.getVersion(), artifact.getType());
+                artifact = new Artifact(
+                    artifact.getGroupId(),
+                    artifact.getArtifactId(),
+                    dependency.getVersion(),
+                    artifact.getType());
             }
             return new org.apache.geronimo.kernel.repository.Dependency(artifact, ImportType.CLASSES);
-        // } else if ("true".equals(dependency.getProperty(REFERENCE_PROPERTY))) {
         }
         else if ("car".equalsIgnoreCase(type) && ("runtime").equalsIgnoreCase(type))
{
             return new org.apache.geronimo.kernel.repository.Dependency(artifact, ImportType.SERVICES);



Mime
View raw message