Im on CC.Net 1.6, where <sequential> is supposed to work.
When I try to run it with something like the sample shown below, I get ERROR level exceptions saying "Unused node detected" on the sequential node.
What am I missing?
Mark
<sequential>
<tasks>
<powershell>yada...</powershell>
<buildpublisher>yada...</buildpublisher>
<ftp>yada...</ftp>
</tasks>
</sequential>
Are you sure you have put the sequential node in the right place, i.e. inside another tasks node where it belongs? I tried constructing the project configuration below and it passed validation without errors.
<project>
<name>Test project</name>
<tasks>
<sequential>
<tasks>
<powershell>
<script>script.ps1</script>
</powershell>
<buildpublisher />
<ftp>
<ftpFolderName>upload</ftpFolderName>
<localFolderName>test</localFolderName>
<userName>user</userName>
<password>pwd</password>
<serverName>ftp.server.com</serverName>
</ftp>
</tasks>
</sequential>
</tasks>
</project>
It's also not clear from your post why exactly you need the sequential task. The task in CC.Net are executed sequentially by default so you would only need to use it inside a parallel task to specify a block of tasks to be executed sequentially:
<project>
<name>Test project</name>
<tasks>
<parallel>
<tasks>
<sequential>
<tasks>
<!-- other tasks here -->
</tasks>
</sequential>
<sequential>
<tasks>
<!-- other tasks here -->
</tasks>
</sequential>
</tasks>
</parallel>
</tasks>
</project>
Hope that helps.
Related
Is it possible to set the max DFA states before table used rather than inlining in the configuration of the plugin maven antlr3 like the extended option -Xmaxinlinedfastates in the command line of antlr.Tool ?
I find it for ant script but nothing with maven.
If yes, how to ?
Thanks.
Thanks to Jiri Tousek.
I found an alternative to what I call a gap in the maven antlr3 plugin. Using the maven antrun plugin allowed me to solve this problem.
Here is the statement I made in pom.xml and that works for me:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target>
<!-- Place any Ant task here. You can add anything you can add between
<target> and </target> in a build.xml. -->
<java classname="org.antlr.Tool" fork="true"
failonerror="true">
<arg value="-verbose" />
<arg value="-Xmaxinlinedfastates"/>
<arg value="10"/> <!-- Value for the exended option -Xmaxinlinedfastates -->
<arg path="./src/main/antlr3/*.g" />
</java>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
I'm trying to run an Ant job within Maven to look at a folder, and based on how many folders are in that folder, to create x number of zip files with the name of the folder. I have it working manually, but it would be nice if I didn't have to edit the pom each time I added a new folder to this structure.
<configuration>
<target name="zip">
<zip destfile="root/sub1/sub1.jar">
<zipfileset dir="root/sub1/unpacked/" includes="**" ></zipfileset>
</zip>
</target>
</configuration>
If I were to add sub2 to the root dir, I would like it to be picked up automagically, and create a sub2.jar file (yes, I'm aware I'm using .jar, but the program that is taking these files expects .jar files, but they're not jar files in that they contain any Java code, they're just zip files with jar extensions)
I've tried this
Thanks I had a look at the first link, but perhaps I'm doing it wrong
<target name="checkDir">
<foreach target="zip" param="theFile">
<dirset dir="root" casesensitive="yes">
<include name="**"/>
</dirset>
</foreach>
</target>
<target name="zip">
<!-- <zip destfile="root/${theFile}/${theFile}.jar">
<zipfileset dir="root/${theFile}/unpacked/" includes="**" ></zipfileset>
</zip> -->
<echo message="${theFile}"/>
</target>
I just get
[INFO] --- maven-antrun-plugin:1.7:run (process-javascript-plugin) # war---
[INFO] Executing tasks
zip:
[echo] ${theFile}
[INFO] Executed tasks
Still doesn't seem to be working.
pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>process-cartridges</id>
<phase>compile</phase>
<configuration>
<target>
<ant antfile="root/build-main.xml"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
build-main.xml
<?xml version="1.0" encoding="UTF-8" ?>
<project>
<target name="checkDir">
<foreach target="zip" param="theFile">
<dirset dir="root" casesensitive="yes">
<include name="**"/>
</dirset>
</foreach>
</target>
<target name="zip">
<zip destfile="root/${theFile}/${theFile}.jar">
<zipfileset dir="root/${theFile}/unpacked/" includes="**" />
</zip>
<echo message="TESTZIP ${theFile}"/>
</target>
</project>
Doesn't seem to be working. Am I missing anything?
You could use the foreach task of Ant to do this, combining the answers from those two posts: Ant: How to execute a command for each file in directory? and Calling foreach in maven-antrun-plugin.
However, you can also have a Maven solution using the iterator-maven-plugin to iterate over all sub-folders and then use the maven-jar-plugin to make the jar:
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>iterator-maven-plugin</artifactId>
<version>0.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>iterator</goal>
</goals>
<configuration>
<folder>root/</folder>
<pluginExecutors>
<pluginExecutor>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
</plugin>
<goal>jar</goal>
<configuration>
<classesDirectory>root/#item#/unpacked</classesDirectory>
<outputDirectory>root/#item#</outputDirectory>
<finalName>#item#.jar</finalName>
</configuration>
</pluginExecutor>
</pluginExecutors>
</configuration>
</execution>
</executions>
</plugin>
This is bound to the package phase. It will iterate over all direct subfolders of the root folder and invoke the jar plugin with the given configuration. #item# is used to refer to the current directory name.
It's easy to use org.apache.maven.plugins:maven-antrun-plugin to copy resources and rename them but is there a way to do this intelligently with wildcards or other mecanisms to conform personnal rules ?
For example if I have those files :
${project.artifactId}-${project.version}.swf
a.swf
b.swf
...
z.swf
I would like to copy all those files inside directory and rename only ${project.artifactId}-${project.version}.swf to foo.swf. I know I can use :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>copy-swf-files</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="copy swf files to web project">
<copy file="${project.build.directory}/${project.artifactId}-${project.version}.swf" tofile="${swf.output.location}/foo.swf" />
<copy file="${project.build.directory}/a.swf" tofile="${swf.output.location}/a.swf" />
<copy file="${project.build.directory}/z.swf" tofile="${swf.output.location}/z.swf" />
</target>
</configuration>
</execution>
</executions>
</plugin>
it's work but is there another convenient way to do that because if I have 1000 files to copy, it will be very boring...Thanks
Do you know Ant? All the Maven Ant plugin is doing is calling Ant with the tasks you list. You can do any Ant task including <taskdef>, etc.
What it looks like you're doing can be done with fileset:
<copy todir="${swf.output.location}">
<fileset dir="${project.build.directory}">
<include name="*.swf"/>
</fileset>
</copy>
This will copy all *.swf files located directly under in the ${project.build.directory} (and no subdirectories) to the ${swf.output.location} directory. If you want to copy the entire directory tree of *.swf files, just change the <include>:
<copy todir="${swf.output.location}">
<fileset dir="${project.build.directory}">
<include name="**/*.swf"/> <!--NOTE DIFFERENCE HERE-->
</fileset>
</copy>
If you need to munge the file names, you can use Mappers. The simplest mapper would be the flatten mapper:
<copy todir="${swf.output.location}">
<fileset dir="${project.build.directory}">
<include name="**/*.swf"/> <!--NOTE DIFFERENCE HERE-->
</fileset>
<mapper type="flatten"/>
</copy>
This will copy the entire directory tree and flatten all the files into a single directory. There are mappers that can match globs, regular expressions, and even scripting.
The <include> is a selector and not a mapper because it selects what files you want to act upon. These too can be quite complex, and you can match file based upon their names iva regular expressions, or even their contents.
I'm surprised there isn't a Maven plugin that allows you to do this.
Ok I finally used this plugin to do this :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>copy-swf-files</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="copy swf files to web project">
<copy todir="${swf.output.location}">
<fileset dir="${project.build.directory}" includes="*.swf">
<filename regex="^sim-flex.*"/>
</fileset>
<mapper type="regexp" from=".*" to="sim.swf"/>
</copy>
<copy todir="${swf.output.location}" >
<fileset dir="${project.build.directory}" includes="*.swf">
<not>
<filename regex="^sim-flex.*"/>
</not>
</fileset>
</copy>
</target>
</configuration>
</execution>
</executions>
</plugin>
Use maven-assembly-plugin with assembly descriptor of "dir" "formats/format", a "fileSets/fileSet" which will copy majority of swf's excluding the special swf, and a "files/file" which will copy that one swf to a file with different name.
I would like to add a custom key/value pair to the MANIFEST.MF of several existing jar files in my war project (those jars are not the project dependencies).
I already can pack/repack those jars using an ant task.
I read about "manifest" task, how can I apply that task to a fileset (if there is a way)? Thanks in advance.
This is my first answer at StackOverflow. Hope it suits you :)
I've done it like this:
<target name="xxx.modifyManifests">
<echo message="Modifying jar manifests to add trusted-library" />
<apply executable="jar">
<arg value="umf" />
<arg line="${xxx.resources}/manifest/custom_manifest.mf" />
<srcfile />
<fileset dir="${xxx.target}/applets" includes="*.jar" />
</apply>
</target>
The call is a simple one using maven-antrun-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>xxx.modifyManifests</id>
<phase>compile</phase>
<configuration>
<target>
<property environment="windows" />
<property name="xxx.resources"
value="${project.build.directory}/../src/main/resources" />
<property name="xxx.target"
value="${project.build.directory}/${project.artifactId}-${project.version}" />
<ant antfile="${basedir}/build.xml">
<target name="xxx.modifyManifests" />
</ant>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
And my custom_manifest.mf is like this:
Trusted-Only: true
Trusted-Library: true
there is -f option in maven, that allows to specify alternate pom.xml file. Is there a possibility, that I can also bring this behaviour to the executed modules? Now it looks like, that when I have this structure: projectA: pom.xml pom.xml2
projectB: pom.xml pom.xml2
And when I run maven with -f pom.xml2 option as reactor with projectB specified as module, it looks like that it picks pom.xml2 from the projectA, and it picks pom.xml from projectB. Is there a way, how can I propagate the -f option to the modules?
Thanks for answering.
Because we can specified pom file in module definition.1
Here's an example for using alternative pom file in module.
<modules>
<module>child1/pom-jdk14.xml</module>
<module>child2/pom-jdk14.xml</module>
</modules>
As Jörn Horstmann comments I would try lots of things to get this working with profiles in one pom.
If that's not possible the only way I can think of to get this working is to bypass the normal maven mechanism by using a "switching pom" with profiles. This pom is put as pom.xml in each module and has a profile for each of your pom.xml2 (or others) and in that profile executes another maven build f.e. via the antrun-plugin with the -f for the pom you need:
<profile>
<id>xml2</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>build pom.xml2</id>
<phase>prepare-package</phase> <!-- whatever suits you -->
<configuration>
<target>
<echo level="info" message="Building pom.xml2..." />
<exec executable="cmd" dir=".">
<arg value="/c" />
<arg value="mvn" />
<arg value="-f" />
<arg value="pom.xml2" />
<arg value="install" /> <!-- enter which phase you need -->
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>