maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject cvs commit: maven-components/maven-core/src/main/resources/org/apache/maven/project pom-4.0.0.xml pom.xml
Date Thu, 16 Sep 2004 14:26:18 GMT
jdcasey     2004/09/16 07:26:18

  Modified:    maven-core/src/main/java/org/apache/maven/project
                        DefaultMavenProjectBuilder.java
               maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar
                        JarMojo.java
  Added:       maven-core/src/main/resources/org/apache/maven/project
                        pom-4.0.0.xml
  Removed:     maven-core/src/main/resources/org/apache/maven/project
                        pom.xml
  Log:
  o Changed maven-core's super-pom from pom.xml to pom-4.0.0.xml
  o Added validation logic for non-heritable pom elements to the default project builder
  o Changed default builder to select the correct super-pom from the project pom's modelVersion.
  
  Revision  Changes    Path
  1.12      +34 -3     maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
  
  Index: DefaultMavenProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultMavenProjectBuilder.java	15 Sep 2004 12:34:16 -0000	1.11
  +++ DefaultMavenProjectBuilder.java	16 Sep 2004 14:26:18 -0000	1.12
  @@ -101,9 +101,6 @@
   
           try
           {
  -            // TODO: rename to super-pom.xml so it is not used by the reactor
  -            superModel = modelReader.read( new InputStreamReader( DefaultMavenProjectBuilder.class.getResourceAsStream(
"pom.xml" ) ) );
  -
               Model userModel = null;
               // TODO: use maven home local instead of user.home/.m2
               File userModelFile = new File( System.getProperty( "user.home" ) + "/.m2",
"override.xml" );
  @@ -119,6 +116,12 @@
                   {
                       localRepositoryValue = userModel.getLocal().getRepository();
                   }
  +                
  +                validateLeafModel(userModel);
  +                
  +                // TODO: rename to super-pom.xml so it is not used by the reactor
  +                superModel = modelReader.read( new InputStreamReader( DefaultMavenProjectBuilder.class.getResourceAsStream(
"pom-" + userModel.getModelVersion() + ".xml" ) ) );
  +                
                   superModel.getRepositories().addAll( userModel.getRepositories() );
               }
   
  @@ -216,6 +219,34 @@
           {
               throw new ProjectBuildingException( "Error building project from " + projectDescriptor,
e );
           }
  +    }
  +
  +    private void validateLeafModel( Model userModel )
  +    {
  +        String modelVersion = userModel.getModelVersion();
  +        if ( modelVersion == null || modelVersion.length() < 1 )
  +        {
  +            throw new IllegalStateException( "POM element \'modelVersion\' must be specified;
it may not be inherited" );
  +        }
  +
  +        String name = userModel.getName();
  +        if ( name == null || name.length() < 1 )
  +        {
  +            throw new IllegalStateException( "POM element \'name\' must be specified; it
may not be inherited" );
  +        }
  +
  +        String artifactId = userModel.getArtifactId();
  +        if ( artifactId == null || artifactId.length() < 1 )
  +        {
  +            throw new IllegalStateException( "POM element \'artifactId\' must be specified;
it may not be inherited" );
  +        }
  +
  +        String version = userModel.getVersion();
  +        if ( version == null || version.length() < 1 )
  +        {
  +            throw new IllegalStateException( "POM element \'version\' must be specified;
it may not be inherited" );
  +        }
  +
       }
   
       private MavenProject assembleLineage( File projectDescriptor, 
  
  
  
  1.12      +12 -1     maven-components/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java
  
  Index: JarMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JarMojo.java	8 Sep 2004 04:05:40 -0000	1.11
  +++ JarMojo.java	16 Sep 2004 14:26:18 -0000	1.12
  @@ -18,6 +18,7 @@
   
   import org.apache.maven.plugin.PluginExecutionRequest;
   import org.apache.maven.plugin.PluginExecutionResponse;
  +import org.apache.maven.project.MavenProject;
   
   import java.io.File;
   import java.util.LinkedHashMap;
  @@ -52,6 +53,13 @@
    *  validator=""
    *  expression="#project.build.directory"
    *  description=""
  + * @parameter
  + *  name="project"
  + *  type="org.apache.maven.project.MavenProject"
  + *  required="true"
  + *  validator=""
  + *  expression="#project"
  + *  description="current MavenProject instance"
    *
    * @author <a href="michal@codehaus">Michal Maczka</a>
    * @version $Id$
  @@ -82,6 +90,9 @@
           Map includes = new LinkedHashMap();
           
           addDirectory(includes, "**/**", "**/package.html", "", new File( outputDirectory
) );
  +        
  +        MavenProject project = (MavenProject)request.getParameter("project");
  +        includes.put("META-INF/maven/pom.xml", project.getFile());
           
           createJar( jarFile, includes );
       }
  
  
  
  1.1                  maven-components/maven-core/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
  
  Index: pom-4.0.0.xml
  ===================================================================
  <project>
    <modelVersion>4.0.0</modelVersion>
    <name>Maven Super Model</name>
  
    <repositories>
      <repository>
        <id>central</id>
        <name>Maven Central Repository at ibiblio</name>
        <url>http://www.ibiblio.org/maven</url>
      </repository>
    </repositories>
  
  <!--
    <pluginRepositories>
      <repository>
        <id>pluginCentral</id>
        <name>Maven Central Repository at ibiblio</name>
        <url>http://www.ibiblio.org/maven</url>
      </repository>
    </pluginRepositories>
  -->
  
    <!-- TODO: should be the maven local home -->
    <!-- TODO: substitution not working -->
  <!--
    <local>
      <repository>${user.home}/.m2/repository</repository>
    </local>
  -->
  
    <!-- Default plugins
    <plugins>
      <plugin>
        <id></id>
      </plugin>
    </plugins>
    -->
  
    <build>
      <!-- This all may just fold into plugin parameters -->
      <directory>target</directory>
      <output>target/classes</output>
      <testOutput>target/test-classes</testOutput>
      <sourceDirectory>src/main/java</sourceDirectory>
      <unitTestSourceDirectory>src/test/java</unitTestSourceDirectory>
      <unitTest>
        <includes>
          <include>**/*Test.java</include>
        </includes>
        <excludes>
          <exclude>**/*Abstract*.java</exclude>
        </excludes>
        <resources>
          <resource>
            <directory>src/test/resources</directory>
          </resource>
        </resources>
      </unitTest>
      <resources>
        <resource>
          <directory>src/main/resources</directory>
        </resource>
      </resources>
    </build>
  </project>
  
  
  

Mime
View raw message