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>
Related
In Maven, we can use exec-maven-plugin to execute bash commands in the build.
Which plugin of Central Repository can perform the same task?
I ask it because I have to execute a bash command after another plugin that needs to be executed in the same phase only after exec-maven-plugin, so I can't do it directly inside the exec-maven-plugin.
The bash command that I want to execute in the Maven build is the following:
cat file1 >> file2
Thanks in advance.
I managed to solve my issue with maven-antrun-plugin with the <concat> task:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>final step</id>
<phase>install</phase>
<configuration>
<target>
<concat destfile="${project.build.directory}/${project.artifactId}-${project.version}.sh" binary="yes">
<fileset file="${project.build.directory}/script/self-installer.sh" />
<fileset file="${project.build.directory}/${project.artifactId}-${project.version}.tar.gz" />
</concat>
<chmod file="${project.build.directory}/${project.artifactId}-${project.version}.sh" perm="+x"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
This is the equivalent of the bash cat command.
Keep in mind that if you are concatenating a binary file, you have to set binary="yes", otherwise the Ant task will corrupt the final file.
In any case, this is still not a bash-based solution, it's only a trick that uses Ant routines, so it's not a real equivalent of exec-maven-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.
I’m using Maven 3.2.3. I have this for my ant run plugin …
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>20020829</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>create-dodeploy-file</id>
<phase>package</phase>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<property environment="env"/>
<if>
<isset property="env.JBOSS_HOME"/>
<then>
<echo file="${JBOSS_HOME}/standalone/deployments/${project.artifactId}.war.dodeploy" append="false" message="" />
</then>
</if>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Despite the fact I know $JBOSS_HOME is defined in my environment (I’m able to run
echo $JBOSS_HOME
from the same bash shell in which I run my Maven build), the “isset” directive always returns false. Is there a better way to test for the existence of an environment variable in the Antrun plugin?
A target also has the ability to perform its execution if (or unless) a property has been set. To make a target sense this property, you should add the if (or unless) attribute with the name of the property that the target should react to.
<target name="build-if" if="env.JBOSS_HOME"/>
<target name="build-unless" unless="env.JBOSS_HOME"/>
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>