Hi,

I've been playing with the <extend/> tag, which allows a project to get
its properties from
another project.

This rocks and avoids a lot of typing and repetitive stuff.
So, I created a new project holding my company's infos, cvs layout,
mailing-lists, etc.
This project lives only as a project to be extended.

Then, all others projects extend it, so that I could create a new
project in seconds.

One problem here is that if I work on 2 different machines, the blank
project could not
be found in the same place, so it complains that the parent project
doesn't exist.

So, I tried and find a way to be able to extend a project without having
to specify a path
to it.

This is why I patched MavenUtils so that I could define a template,
which is found under:
${maven.home}/templates/${project-to-extend}/project.xml.

So, now, my projects extend the blank project using:
<extend>template:company-project</extend>

This way, as long as the template exists, I can move any project to
another dir without
affecting the extend feature.

Cool ...

Now, it could be MUCH better ...
What I would like is to be able to have cascading templates, ie a
template can extend
another one, so that Maven could be shipped with a default template
hierarchy like:
- standard
* jakarta
* jakarta-commons
* turbine-2.1-webapp
* jelly-tag-library
* maven-plugin
* sourceforge
* my-company
* my-company-webapp (extending both "turbine-2.1-webapp" and
"my-company")

etc...

This way, when we want to create a new jelly tag lib, we only have this POM:

<project>

<extend>template:jelly-tag-library</extend>

<id>jeldap</id>

<shortDescription>A Jelly Tag Library to deal with LDAP</shortDescription>

<dependencies>
<dependency>
<id>ldapjdk</id>
<version>1.0</version>
</dependency>
</dependencies>

</project>

so, we get:
- from "jelly-tag-library", inherited dependencies (1)(jelly &
commons-logging), mailing-lists,
- from "jakarta" the cvs, organization, url, site*, and
- from "standard", we get the build section, the pomVersion,
currentVersion (1.0), inceptionYear, etc.

(1) this is not possible yet, as the lists are not updated correctly
right now, so that if you set dependencies
in your child project, the parent's dependencies will never be inherited.

So, what's needed in order to get that ?

1) implement the check of "template:foo" so that it finds it under
${maven.home}/templates/${project} (DONE - see the attached patch)
2) fix MavenUtils's valueNeedsPopulating so that we deal correctly with
lists, to copy dependencies between
projects
3) check if a template extends another so that we can inherit from the
chain of projects
4) provide standard templates (I've got some of them ready (sourceforge,
jelly-tag-library))
5) copy the templates when we install Maven.

This should not be too hard (maybe 2) is a bit harder) ...

If would be cool also if the child project could inherit the parent's
maven.xml file and project.properties.
Those could also live under ${maven.home}/templates/${project}.

For instance, if we build a new maven plugin, we would get
plugin:deploy, plugin:install for free, and the date
would be in the same place on the generated site.

This will be a bit harder, I guess ...

I didn't apply the patch because I wanted to know what people feel about
it, if there are things that I forgot,
other ways of doing it, etc.

Anyway, feel free to comment, and if you think that would be cool, I'll
apply and start implementing the rest.

Sorry for that long mail.

Cheers,
St�phane
Index: src/java/org/apache/maven/MavenUtils.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/MavenUtils.java,v
retrieving revision 1.50
diff -u -r1.50 MavenUtils.java
--- src/java/org/apache/maven/MavenUtils.java   1 Nov 2002 13:27:56 -0000       1.50
+++ src/java/org/apache/maven/MavenUtils.java   1 Nov 2002 15:40:40 -0000
@@ -72,6 +72,7 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.StringTokenizer;
 
 import javax.xml.parsers.SAXParserFactory;
 
@@ -198,6 +199,26 @@
         String pomToExtend = project.getExtend();
         if (pomToExtend != null)
         {
+            if (pomToExtend.startsWith("template:"))
+            {
+                JellyContext context = null;
+    
+                if (parentContext != null)
+                {
+                    context = new JellyContext(parentContext);
+                    context.setInherit(true);
+                }
+                else
+                {
+                    context = new JellyContext();
+                } 
+
+                String mavenHome = (String) 
+context.findVariable(parentContext.MAVEN_HOME);
+                StringTokenizer st = new StringTokenizer(pomToExtend, ":");
+                st.nextToken();
+                pomToExtend = mavenHome + "/templates/" + st.nextToken() + 
+"/project.xml";
+            }
+
             Project parent = (Project) projectBeanReader.parse(
                 new File(pomToExtend));
             

<?xml version="1.0" encoding="ISO-8859-1"?>
<project>

  <pomVersion>3</pomVersion>
  <currentVersion>1.0</currentVersion>
  <organization>
    <name>SourceForge</name>
    <url>http://sourceforge.net/projects/${pom.id}/</url>
    <logo>http://sourceforge.net/sflogo.php?group_id=61626&amp;type=5</logo>
  </organization>
  <inceptionYear>2002</inceptionYear>

  <!-- Gump integration -->
  <gumpRepositoryId>${pom.id}</gumpRepositoryId>

  <url>http://${pom.id}.sourceforge.net</url>
  <issueTrackingUrl>http://sourceforge.net/tracker/?group_id=61626</issueTrackingUrl>
  <siteAddress>${pom.id}.sourceforge.net</siteAddress>
  <siteDirectory>/home/groups/${pom.id.substring(0,1)}/${pom.id.substring(0,2)}/${pom.id}/htdocs/</siteDirectory>
  <distributionDirectory>/home/groups/${pom.id.substring(0,1)}/${pom.id.substring(0,2)}/${pom.id}/htdocs/distributions/</distributionDirectory>

  <repository>
    <connection>scm:cvs:pserver:anoncvs@cvs.${pom.id}.sourceforge.net:/cvsroot/${pom.id}:${pom.id}</connection>
    <url>http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/${pom.id}/${pom.id}/</url>
  </repository>

  <versions>
  </versions>

  <branches>
  </branches>

  <mailingLists>
    <mailingList>
      <name>${pom.name} User List</name>
      <subscribe>${pom.id}[EMAIL PROTECTED]</subscribe>
      <unsubscribe>${pom.id}[EMAIL PROTECTED]</unsubscribe>
      <archive>http://sourceforge.net/mailarchive/forum.php?forum_id=11777</archive>
    </mailingList>
    <mailingList>
      <name>${pom.name} Developer List</name>
      <subscribe>${pom.id}[EMAIL PROTECTED]</subscribe>
      <unsubscribe>${pom.id}[EMAIL PROTECTED]</unsubscribe>
      <archive>http://sourceforge.net/mailarchive/forum.php?forum_id=11782</archive>
    </mailingList>
    <mailingList>
      <name>${pom.name} CVS Commits List</name>
      <subscribe>${pom.id}[EMAIL PROTECTED]</subscribe>
      <unsubscribe>${pom.id}[EMAIL PROTECTED]</unsubscribe>
      <archive>http://sourceforge.net/mailarchive/forum.php?forum_id=11781</archive>
    </mailingList>
  </mailingLists>

  <build>

    <nagEmailAddress>${pom.id}@sourceforge.net</nagEmailAddress>

    <sourceDirectory>src/java</sourceDirectory>

    <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
    <integrationUnitTestSourceDirectory/>

    <aspectSourceDirectory></aspectSourceDirectory>

    <!-- Unit test classes -->
    <unitTest>
      <includes>
        <include>**/*Test.java</include>
      </includes>
    </unitTest>
    
    <!-- J A R  R E S O U R C E S -->
    <!-- Resources that are packaged up inside the JAR file -->

    <resources>
    </resources>

    <jars>
    </jars>
  </build>
</project>


<?xml version="1.0" encoding="ISO-8859-1"?>

<project>

  <extend>template:maven-base-project</extend>
  <pomVersion>3</pomVersion>
  <currentVersion>1.0</currentVersion>
  <logo>/images/jakarta-logo-blue.gif</logo>
  <organization>
    <name>Apache Software Foundation</name>
    <url>http://www.apache.org/</url>
    <logo>/images/jakarta-logo-blue.gif</logo>
  </organization>
  <inceptionYear>2002</inceptionYear>
  <package>org.apache.commons.jelly.tags</package>
  <url>http://jakarta.apache.org/commons/sandbox/jelly/</url>

  <issueTrackingUrl>http://jira.werken.com/BrowseProject.jspa?id=10012</issueTrackingUrl>
  <siteAddress>jakarta.apache.org</siteAddress>
  <siteDirectory>/www/jakarta.apache.org/commons/sandbox/jelly/</siteDirectory>
  <distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons-sandbox/jelly/</distributionDirectory>
  <repository>
    <connection>scm:cvs:pserver:[EMAIL PROTECTED]:/home/cvspublic:jakarta-commons-sandbox/jelly</connection>
    <url>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/</url>
  </repository>

  <distributions>
  </distributions>

  <branches/>

  <mailingLists>
    <mailingList>
      <name>Commons Dev List${pom.id}</name>
      <subscribe>[EMAIL PROTECTED]</subscribe>
      <unsubscribe>[EMAIL PROTECTED]</unsubscribe>
      <archive>http://nagoya.apache.org/eyebrowse/SummarizeList?listName=commons-dev@;jakarta.apache.org</archive>
    </mailingList>
    <mailingList>
      <name>Commons User List</name>
      <subscribe>[EMAIL PROTECTED]</subscribe>
      <unsubscribe>[EMAIL PROTECTED]</unsubscribe>
      <archive>http://nagoya.apache.org/eyebrowse/SummarizeList?listName=commons-user@;jakarta.apache.org</archive>
    </mailingList>
  </mailingLists>

  <developers>
  </developers>

  <dependencies>

    <dependency>
      <id>commons-jelly</id>
      <version>SNAPSHOT</version>
      <url>http://jakarta.apache.org/commons/sandbox/jelly/</url>
    </dependency>

    <dependency>
      <id>commons-logging</id>
      <version>1.0</version>
    </dependency>

  </dependencies>

  <build>

    <sourceDirectory>src/java</sourceDirectory>

    <unitTestSourceDirectory>src/test</unitTestSourceDirectory>

    <integrationUnitTestSourceDirectory/>

    <aspectSourceDirectories/>
    <!-- Unit test classes -->

    <unitTestPatterns>
      <unitTestPattern>**/*Test.java</unitTestPattern>
    </unitTestPatterns>
    <!-- Integration unit test classes -->

    <integrationUnitTestPatterns/>
    <!-- J A R  R E S O U R C E S -->
    <!-- Resources that are packaged up inside the JAR file -->

    <resources/>

    <jars/>

  </build>

</project>

<?xml version="1.0" encoding="ISO-8859-1"?>
<project>

  <extend>template:sourceforge</extend>
  <id>maven-plugins</id>
  <name>Maven Plugins</name>
  <package>org.apache.maven.plugins</package>
  <logo>/images/maven-plugins-logo.gif</logo>

  <shortDescription>Collection of plugins for Apache Jakarta Maven</shortDescription>

  <developers>

    <developer>
      <name>dIon Gillard</name>
      <id>dion</id>
      <email>[EMAIL PROTECTED]</email>
      <organization>Multitask Consulting</organization>
      <roles>
        <role>Java Developer</role>
      </roles>
    </developer>

    <developer>
      <name>Siegfried Goeschl</name>
      <id>wdsgoe</id>
      <email>[EMAIL PROTECTED]</email>
      <organization>IT20one GmbH</organization>
      <roles>
        <role>Java Developer</role>
      </roles>
    </developer>

    <developer>
      <name>J�rn A Hansen</name>
      <id>jornh</id>
      <email>[EMAIL PROTECTED]</email>
      <organization></organization>
      <roles>
        <role>Java Developer</role>
      </roles>
    </developer>

    <developer>
      <name>St�phane Mor</name>
      <id>stephanemor</id>
      <email>[EMAIL PROTECTED]</email>
      <organization>Hasgard Syst�mes et R�seaux</organization>
      <roles>
        <role>Java Developer</role>
        <role>Release Technician</role>
      </roles>
    </developer>

  </developers>

</project>



--
To unsubscribe, e-mail:   <mailto:turbine-maven-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:turbine-maven-dev-help@;jakarta.apache.org>

Reply via email to