Hi,

I've been looking through the maven source and understand it a lot
better now. I noticed that all callbacks have a pre- and a post-, so I
did a quick patch so that in the Control.vm's, instead of:

$callbacks.put( "$plugin", [ "pre-test", "post-test",
"pre-run-singletest", "post-run-singletest" ] )

You can do:

$callbacks.put( "$plugin", [ "test", "run-singletest" ] )

Then the build.init.target automatically generates the pre- and post-
version. I've attached the patch of the minor hack job I did. I think
standardizing on having a pre and post for each callback makes sense,
but that may not be the consensus of the regular developers, which is
fine, too.

Also, I was hoping to refactor:

  <target 
    name="test" 
 
depends="local-init,#callback("pre-test"),do-test,#callback("post-test")
"
    description="runs (junit) unit tests"/>

  <target 
    name="do-test" 
    depends="run-tests"
    if="maven.test.failure">

into:

  #callback-target( test, "runs (junit) unit tests", local-init )

But my VTL skills aren't to where I could come up with anything elegant,
especially with the possibly if/depends/etc. in each of the targets.
Which is perhaps why it remains as it is, I was just hoping to factor
out the pre- and post- target. 

It's a less elegant but I was also thinking of something like:

  <target 
    name="test" 
    depends="local-init,#callbacks("test")"
    description="runs (junit) unit tests"/>

To have the callbacks macro expand out into the pre-, do-, and post-.
It's a fairly minor change, much like the patch I'm submitting, so I
wanted to beef it up by auto-generating to the do- target. If someone
else has an elegant way of doing this, I think it'd be cool.

Course, it depends on how dependent on VTL you want the generation to
be; if you'd like the plugin source to remain as close to the target XML
file as possible, which is a valid goal, the current solution is fine.

- Stephen 
cvs diff src\templates\build\plugins\core\Control.vm 
src\templates\build\plugins\docs\Control.vm 
src\templates\build\plugins\iutest\Control.vm 
src\templates\build\plugins\j2ee\Control.vm 
src\templates\build\plugins\metrics\Control.vm 
src\templates\build\plugins\reactor\Control.vm 
src\templates\build\plugins\struts\Control.vm 
src\templates\build\plugins\test\Control.vm src\templates\build\build.init.target (in 
directory C:\cvs\jakarta-turbine-maven\)
Index: src/templates/build/plugins/core/Control.vm
===================================================================
RCS file: 
/home/cvspublic/jakarta-turbine-maven/src/templates/build/plugins/core/Control.vm,v
retrieving revision 1.1
diff -r1.1 Control.vm
33c33
< $callbacks.put( "$plugin", [ "pre-jar", "post-jar","pre-install-jar", 
"post-install-jar", "pre-env", "post-env", "pre-clean", "post-clean", "pre-dist", 
"post-dist", "pre-dist-build", "post-dist-build", "pre-deploy-dist", 
"post-deploy-dist", "pre-gump-descriptor", "post-gump-descriptor", "pre-compile", 
"post-compile", "pre-check-source", "post-check-source", "pre-update-jars", 
"post-update-jars", "pre-announce", "post-announce", "pre-maven-update", 
"post-maven-update", "pre-validate-pom", "post-validate-pom" ] )
---
> $callbacks.put( "$plugin", [ "jar","install-jar", "env", "clean", "dist", 
>"dist-build", "deploy-dist", "gump-descriptor", "compile", "check-source", 
>"update-jars", "announce", "maven-update", "validate-pom" ] )
Index: src/templates/build/plugins/docs/Control.vm
===================================================================
RCS file: 
/home/cvspublic/jakarta-turbine-maven/src/templates/build/plugins/docs/Control.vm,v
retrieving revision 1.1
diff -r1.1 Control.vm
28c28
< $callbacks.put( "$plugin", ["pre-site", "post-site", "pre-fo", "post-fo", "pre-pdf", 
"post-pdf", "pre-docs", "post-docs", "pre-docs-quick", "post-docs-quick", 
"pre-deploy-site", "post-deploy-site", "pre-cross-ref", "post-cross-ref", 
"pre-cvs-change-log", "post-cvs-change-log", "pre-activity-log", "post-activity-log", 
"pre-task-list", "post-task-list", "pre-javadocs", "post-javadocs" ] )
---
> $callbacks.put( "$plugin", ["site", "fo", "pdf", "docs", "docs-quick", 
>"deploy-site", "cross-ref", "cvs-change-log", "activity-log", "task-list", "javadocs" 
>] )
Index: src/templates/build/plugins/iutest/Control.vm
===================================================================
RCS file: 
/home/cvspublic/jakarta-turbine-maven/src/templates/build/plugins/iutest/Control.vm,v
retrieving revision 1.1
diff -r1.1 Control.vm
18c18
< $callbacks.put( "$plugin", [ "pre-iutest", "post-iutest" ] )
---
> $callbacks.put( "$plugin", [ "iutest" ] )
Index: src/templates/build/plugins/j2ee/Control.vm
===================================================================
RCS file: 
/home/cvspublic/jakarta-turbine-maven/src/templates/build/plugins/j2ee/Control.vm,v
retrieving revision 1.4
diff -r1.4 Control.vm
22c22
< $callbacks.put( "$plugin", [ "pre-war", "post-war", "pre-ejb", "post-ejb", 
"pre-validate-war", "post-validate-war", "pre-ear",  "post-ear" ] )
---
> $callbacks.put( "$plugin", [ "war", "ejb", "validate-war",  "ear" ] )
Index: src/templates/build/plugins/metrics/Control.vm
===================================================================
RCS file: 
/home/cvspublic/jakarta-turbine-maven/src/templates/build/plugins/metrics/Control.vm,v
retrieving revision 1.1
diff -r1.1 Control.vm
18c18
< $callbacks.put( "$plugin", [ "pre-metrics", "post-metrics" ] )
---
> $callbacks.put( "$plugin", [ "metrics" ] )
Index: src/templates/build/plugins/reactor/Control.vm
===================================================================
RCS file: 
/home/cvspublic/jakarta-turbine-maven/src/templates/build/plugins/reactor/Control.vm,v
retrieving revision 1.1
diff -r1.1 Control.vm
18c18
< $callbacks.put( "$plugin", ["pre-generate-reactor", "post-generate-reactor" ] )
---
> $callbacks.put( "$plugin", ["generate-reactor" ] )
Index: src/templates/build/plugins/struts/Control.vm
===================================================================
RCS file: 
/home/cvspublic/jakarta-turbine-maven/src/templates/build/plugins/struts/Control.vm,v
retrieving revision 1.1
diff -r1.1 Control.vm
19c19
< $callbacks.put( "$plugin", [ "pre-validate-struts-war", "post-validate-struts-war"] )
---
> $callbacks.put( "$plugin", [ "validate-struts-war"] )
Index: src/templates/build/plugins/test/Control.vm
===================================================================
RCS file: 
/home/cvspublic/jakarta-turbine-maven/src/templates/build/plugins/test/Control.vm,v
retrieving revision 1.2
diff -r1.2 Control.vm
19c19
< $callbacks.put( "$plugin", [ "pre-test", "post-test", "pre-run-singletest", 
"post-run-singletest" ] )
---
> $callbacks.put( "$plugin", [ "test", "run-singletest" ] )
Index: src/templates/build/build.init.target
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-maven/src/templates/build/build.init.target,v
retrieving revision 1.33
diff -r1.33 build.init.target
341,342c341,344
<   #set( $buildFile = "${cbPrefix}.${plugin}.callback.${cbName}.${cbFile}" )
<   #set( $buildTarget = "${cbPrefix}.${plugin}.callback.${cbName}.${cbTarget}" )
---
> 
>   #set( $cbNamePre = "pre-${cbName}" )
>   #set( $buildFile = "${cbPrefix}.${plugin}.callback.${cbNamePre}.${cbFile}" )
>   #set( $buildTarget = "${cbPrefix}.${plugin}.callback.${cbNamePre}.${cbTarget}" )
344,345c346,347
<   <target name="${cbName}-callback-check">
<     <condition property="maven.callback.${cbName}.ok">
---
>   <target name="${cbNamePre}-callback-check">
>     <condition property="maven.callback.${cbNamePre}.ok">
357,359c359,361
<   <target name="#callback( $cbName )"
<           depends="${cbName}-callback-check"
<           if="maven.callback.${cbName}.ok">
---
>   <target name="#callback( $cbNamePre )"
>           depends="${cbNamePre}-callback-check"
>           if="maven.callback.${cbNamePre}.ok">
366a369,372
> 
>   #set( $cbNamePost = "post-${cbName}" )
>   #set( $buildFile = "${cbPrefix}.${plugin}.callback.${cbNamePost}.${cbFile}" )
>   #set( $buildTarget = "${cbPrefix}.${plugin}.callback.${cbNamePost}.${cbTarget}" )
367a374,397
>   <target name="${cbNamePost}-callback-check">
>     <condition property="maven.callback.${cbNamePost}.ok">
>       <not>
>         <or>
>           <equals arg1="$buildFile"
>                   arg2="$$buildFile" />
>           <equals arg1="$buildTarget"
>                   arg2="$$buildTarget" />
>         </or>
>       </not>
>     </condition>
>   </target>
>   
>   <target name="#callback( $cbNamePost )"
>           depends="${cbNamePost}-callback-check"
>           if="maven.callback.${cbNamePost}.ok">
> 
>     <ant antfile="$buildFile"
>          target="$buildTarget">
>       <property name="maven.build.classpath" value="classpath" />
>     </ant>
> 
>   </target>
> 

*****CVS exited normally with code 1*****


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to