Ludwig
This was very helpful, and I now have it all working, the Perl script is run by
the exec-maven-plugin; and I use maven-resources-plugin to copy the generated
PNG files, both are tied pre-site phase.
One gottcha is the exec-maven-plugin is not platform agnostic, so while I have
ActiveState Perl (Community edition) configured to run from the DOS command
line on windows; I need to have a different configuration to execute it
compared to my Fedora host.
The "exec-maven-plugin" (of which there can only be one per lifecycle phase) is
declared before the "maven-resources-plugin" in the <build>/<plugins> section.
I have added snippets from my POM.xml below and I also used <properties> to
allow me to change them rather than edit the "exec-maven-plugin" section.
So that is the next thing to tackle is trying to make this platform agnostic.
Many thanks
- Geoff
Properties:
<properties>
<beginWeek>01</beginWeek>
<weekCount>16</weekCount>
</properties>
Maven-resources-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<outputDirectory>src/site/resources</outputDirectory>
</configuration>
<executions>
<execution>
<id>copy-resources</id>
<phase>pre-site</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/site/resources/images</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target/gnuplot</directory>
<filtering>false</filtering>
<includes>
<include>**/*.png</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Linux "exec-maven-plugin":
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<executable>src/main/generateGraphs.pl</executable>
<commandlineArgs>--begin ${beginWeek} --weeks ${weekCount}
data/2011.txt</commandlineArgs>
</configuration>
<executions>
<execution>
<id>exec-maven-plugin</id>
<phase>pre-site</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
Windows "exec-maven-plugin"
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<executable>cmd</executable>
<arguments>
<argument>/C</argument>
<argument>src\main\generateGraphs.pl</argument>
<argument>--begin=${beginWeek}</argument>
<argument>--weeks ${weekCount}</argument>
<argument>data/2011.txt</argument>
</arguments>
</configuration>
<executions>
<execution>
<id>exec-maven-plugin</id>
<phase>pre-site</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
From: Ludwig Magnusson <[email protected]>
To: 'Maven Users List' <[email protected]>; 'Geoffrey Collis'
<[email protected]>
Cc:
Sent: Sunday, 6 February 2011, 12:16
Subject: RE: Generating site content with Maven 2 site-plugin
Generating site content with Maven 2 site-plugin
Yes, you only need to do two things:
1. Run the perl script
2. Copy the files to the right location (if they can’t be generated
directly to the location)
I have never used perl but according to google this plugin can help you execute
perl scripts:
http://mojo.codehaus.org/exec-maven-plugin/exec-mojo.html
The resource plugin can then copy the resources with the copy-resources goal
http://maven.apache.org/plugins/maven-resources-plugin/
You need to include both plugins in your pom and tie them to the pre-site
phase. You can read more about lifecycle phases and how to tie plugins to them
here:
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
When you have managed to do this, you will probably have a good basic
understanding of how maven works and no need to call yourself a newbe =)
/Ludwig
From:Geoffrey Collis [mailto:[email protected]]
Sent: den 5 februari 2011 22:27
To: [email protected]
Cc: [email protected]
Subject: Generating site content with Maven 2 site-plugin
I want to automatically generate GIF files to be included in a web site
generated using the maven-2 site plugin.
Part of the "site" contains an ASCII data file from which I need to
[re]generate a number of GIF files using Perl and GNUPlot.
Site maintenance consists of updating the ASCII data file, regenerating the GIF
files, adding some comments to APT files and pushing it live.
Is it possible to get the "mvn site:site" to run my Perl script which generates
the GIF files and copies them to the site/resources/images directory so they
get pushed to the site automatically?
Despite several days of reading through Doxia Macros, Mylyn, Wagon, Maven and
ANT integration tips and various other plugins I am still clueless.
Can anyone provide any hints? I suspect I am missing something obvious, but I
confess to being a relative newbie with respect to maven.
I am happy to rewrite the Perl script in Java if this makes it easier.
Regards
- Geoff
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1204 / Virus Database: 1435/3425 - Release Date: 02/05/11
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]