On 04/06/07, James Abley <[EMAIL PROTECTED]> wrote:
Hi,

I am trying to create an assembly that I can deploy to our internal repository.

The envisaged steps in this process are:

1) Get all of the dependencies.
2) Do some final packaging; e.g. consolidate all SQL creation scripts
into a single script.
3) Create a zip file ready for deployment.

I'm trying to work out the best way of structuring the module
responsible for doing this.

Can I do it all in a single module, by binding different plugins to
the appropriately sequenced phase?

e.g.

1) Use maven-assembly-plugin bound to compile to create a temporary
working directory of all of the dependencies.
2) Use maven-antrun-plugin bound to test to do the final packaging.
3) Use the maven-assembly-plugin bound to package to create a zip file.

Does this sound reasonable / feasible, should I be looking at multiple
modules straight away or some other approach?

It doesn't look like I can do this in one step. I can't declare the
maven-assembly-plugin twice in the same pom - it doesn't see the
second assembly descriptor.

   <build>
       <plugins>
           <!-- Get all of the dependencies for the installer -->
           <plugin>
               <artifactId>maven-assembly-plugin</artifactId>
               <configuration>
                   <appendAssemblyId>false</appendAssemblyId>
                   <descriptors>
                       <descriptor>
                           src/main/assembly/dep.xml
                       </descriptor>
                   </descriptors>
               </configuration>
               <executions>
                   <execution>
                       <id>create-directories</id>
                       <phase>compile</phase>
                       <goals>
                           <goal>directory-inline</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>
           <plugin>
               <!-- Do any final packaging tasks. -->
               <artifactId>maven-antrun-plugin</artifactId>
               <executions>
                   <execution>
                       <!--
                           this needs to get executed before the
final assembly plugin.
                       -->
                       <phase>test</phase>
                       <goals>
                           <goal>run</goal>
                       </goals>
                       <configuration>
                           <tasks>
                               <!-- Create single DDL file for each
database vendor -->
                               <ant
                                   antfile="${basedir}/src/main/ant/ddl.xml"
                                   inheritRefs="true">
                                   <property
                                       name="mpinstall.dependencies.dir"

value="${project.build.directory}/${project.build.finalName}.dir" />
                               </ant>
                           </tasks>
                       </configuration>
                   </execution>
               </executions>
               <dependencies>
                   <dependency>
                       <!-- Include for <echoproperties/> -->
                       <groupId>org.apache.ant</groupId>
                       <artifactId>ant-nodeps</artifactId>
                       <version>1.7.0</version>
                   </dependency>
               </dependencies>
           </plugin>
           <plugin>
               <artifactId>maven-assembly-plugin</artifactId>
               <configuration>
                   <descriptor>
                       src/main/assembly/package.xml
                   </descriptor>
               </configuration>
               <executions>
                   <execution>
                       <id>make-assembly</id>
                       <!--
                           append to the packaging phase. This will let us
                           deploy the zip file to the internal repository
                           sites.
                       -->
                       <phase>package</phase>
                       <goals>
                           <goal>attached</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>
       </plugins>
   </build>


The second use of the maven-assembly-plugin shows that it is using the
descriptor src/main/assembly/dep.xml again, which isn't what I want.
That means that it misses out the changes done in the ANT target which
is the point of splitting out the process into more steps.

If I don't declare the plugin twice and instead specify two
descriptors in the single maven-assembly-plugin declaration, how do I
ensure that the correct descriptor is used at the correct time?



So I tried the other way of splitting it out into multiple modules:

I have one module that draws in all the dependencies and does the
inline-directory thing prior to using ANT to do some other stuff, and
then have a second module which uses a fileset to reference the
artifacts generated by the first assembly plugin / ANT combination.

This seems to do more or less what I want, but the baseDirectory of
the resulting zip is not what is required.

e.g.

MyProject module containing MyProject-dependencies and
MyProject-packaging modules.

ls  MyProject-dependencies/target/MyProject-dependencies-finalName

wars
db
docs

(Looks good.)

unzip -l MyProjectp-packaging/target/MyProject-packaging-finalName.zip
../MyProject-dependencies/target/MyProject-dependencies-finalName/wars
./MyProject-dependencies/target/MyProject-dependencies-finalName/db
./MyProject-dependencies/target/MyProject-dependencies-finalName/docs

(I don't want that MyProject-dependencies/target prefix here!)

How best to get rid of the ../MyProject-dependencies/target directory?
My initial reaction is to use another ANT task before the final zip to
copy the content into MyProject-packaging, maybe do the zip in ANT if
I need that level of control and use a <files/> element in the
assembly descriptor.

That would seem like not the Maven way. Any other suggestions?

Cheers,

James


Cheers,

James


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

Reply via email to