How do I recreate command run by Maven's antrun plugin? - maven

I'm using Maven 3.0.3 on Solaris 10. I am using the antrun exec plugin. How do I figure out the command line statement that is actually being run? When running my command (designed to checkout code from the StarTeam version control system), I'm getting a permission denied error, although I have verified my user has proper perms. I would like to run the same command Maven is running from a shell so that I can compare the two commands.
Below is the relevant section from my pom.xml file …
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>verify</phase>
<configuration>
<tasks>
<!-- Backup CIRQUE_COMPLETE and freeze the backup label -->
<exec failonerror="true" executable="stcmd" dir="/opt/StarTeamCP_2009/bin/">
<arg value="label" />
<arg value="-p" />
<arg value="user:#mydomain.com:49201/myco/myco/Technology/nna/mycoUSA/cirquedusoleil" />
<arg value="-vl" />
<arg value="CIRQUE_${env}_COMPLETE" />
<arg value="-nl" />
<arg value="CIRQUE_${env}_COMPLETE_`date +"%Y%m%d-%T"`" />
<arg value="-f" />
<arg value="-r" />
</exec>
<!-- Slide CIRQUE_COMPLETE label up to build label -->
<exec failonerror="true" executable="stcmd" dir="/opt/StarTeamCP_2009/bin/">
<arg value="apply-label" />
<arg value="-p" />
<arg value="user:#mydomain.com:49201/myco/myco/Technology/nna/mycoUSA/cirquedusoleil" />
<arg value="-vl" />
<arg value="${env.BUILD_ID}" />
<arg value="-lbl" />
<arg value="CIRQUE_${env}_COMPLETE" />
<arg value="-is" />
<arg value="*" />
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

You can run maven with the -X option. This will give you more (debug) information and it will also run ant with the -debug option.

Use the 'chmod' tag before 'exec' to guarantee the right to execute the command, as follows:
<chmod file="/opt/StarTeamCP_2009/bin/stcmd" perm="a+x"/>
<exec failonerror="true" executable="stcmd" dir="/opt/StarTeamCP_2009/bin/">
...
</exec>

Related

How to set ANTLR3 extended option -Xmaxinlinedfastates in maven configuration?

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>

Migrating from ant to gradle

Build.xml
<project name="DikshaPortal" default="dist" basedir=".">
<description>Build file for Portalv2.0 project</description>
<!-- set global properties for this build -->
<property name="src" location="src" />
<property name="conf" location="src/conf" />
<property name="build" location="${BUILD_TARGET}/Portal" />
<property name="GUI" location="../GUI" />
<property name="dist" location="${BUILD_EXPORT}/Portal" />
<property name="BaseDir" location="../DikshaPortal-Release-2013-12-12" />
<property name="UIBaseDir" location="../Portalv2.0_FlexCompileFiles" />
<property name="history" location="${UIBaseDir}/history" />
<property name="META-INF" location="WebContent/META-INF" />
<property name="com" location="${UIBaseDir}/com" />
<property name="pages" location="${UIBaseDir}/pages" />
<property name="WEB-INF" location="WebContent/WEB-INF" />
<property name="data" location="WebContent/data" />
<property name="temp" location="WebContent/temp" />
<property name="policies" location="WebContent/assets/images/Policies" />
<property name="TPL" value="${LIBRARIES}/ThirdParty" />
<property name="apache" value="${TPL}/apache_libs" />
<path id="classpath">
<fileset dir="${TPL}" includes="*.jar" />
<fileset dir="${apache}" includes="**/*.jar" />
<fileset dir="${WEB-INF}" includes="**/*.jar" />
</path>
<target name="clean" description="Removes the temporary directories used">
<delete dir="${GUI}" />
<delete dir="${build}" />
</target>
<target name="init" depends="clean">
<!-- Create the time stamp -->
<tstamp />
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}" />
<mkdir dir="${dist}" />
<mkdir dir="${GUI}" />
<mkdir dir="${data}" />
<mkdir dir="${temp}" />
</target>
<target name="compile" depends="init" description="Compile the source code">
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}" debug="on" debuglevel="lines,vars,source" classpathref="classpath" />
</target>
<target name="dist" depends="compile" description="generate the distribution">
<copy todir="${GUI}">
<fileset dir="${UIBaseDir}" includes="*.js,*.html,*.swf,*.jsp,favicon.png,favicon.ico" />
</copy>
<mkdir dir="${GUI}/assets/images/Policies" />
<copy todir="${GUI}/assets/images/Policies">
<fileset dir="${policies}" includes="*.*" />
</copy>
<mkdir dir="${GUI}/data" />
<copy todir="${GUI}/data">
<fileset dir="${data}" includes="**" />
</copy>
<mkdir dir="${GUI}/temp" />
<copy todir="${GUI}/temp">
<fileset dir="${temp}" includes="*.*" />
</copy>
<mkdir dir="${GUI}/history" />
<copy todir="${GUI}/history">
<fileset dir="${history}" includes="*.*" />
</copy>
<mkdir dir="${GUI}/com" />
<copy todir="${GUI}/com">
<fileset dir="${com}" includes="**" />
</copy>
<mkdir dir="${GUI}/pages" />
<copy todir="${GUI}/pages">
<fileset dir="${pages}" includes="**" />
</copy>
<mkdir dir="${GUI}/WEB-INF/flex" />
<copy todir="${GUI}/WEB-INF/flex">
<fileset dir="${WEB-INF}/flex" includes="*.*">
</fileset>
</copy>
<mkdir dir="${GUI}/WEB-INF/pages" />
<copy todir="${GUI}/WEB-INF/pages">
<fileset dir="${WEB-INF}/pages" includes="*.*">
</fileset>
</copy>
<mkdir dir="${dist}/conf" />
<copy todir="${dist}/conf">
<fileset dir="${BaseDir}/conf" includes="email.properties, Portal.properties" />
</copy>
<copy todir="${dist}">
<fileset dir="${BaseDir}/conf" includes="readme.txt" />
</copy>
<mkdir dir="${dist}/email/templates" />
<copy todir="${dist}/email/templates">
<fileset dir="${BaseDir}/email/templates" includes="*.*" />
</copy>
<mkdir dir="${dist}/jasper" />
<copy todir="${dist}/jasper">
<fileset dir="${BaseDir}/jasper" includes="*.*" />
</copy>
<mkdir dir="${dist}/conf" />
<copy todir="${dist}">
<fileset dir="${BaseDir}/db_scripts" includes="*.*" />
</copy>
<mkdir dir="${dist}/jars" />
<copy todir="${dist}/jars">
<fileset dir="${TPL}" includes="*.*" />
</copy>
<copy todir="${build}" file="src/MessageResources.properties">
</copy>
<!--
Put everything in ${build} into the MyProject-${DSTAMP}.war file
-->
<war destfile="${dist}/DikshaPortalv2.0.war" webxml="${WEB-INF}/web.xml" basedir="${GUI}">
<classes dir="${build}" />
<lib dir="${WEB-INF}/lib" />
<webinf dir="${WEB-INF}" includes="*.xml" excludes="web.xml" />
<fileset dir="${META-INF}" />
</war>
<copy todir="${build}">
<fileset dir="${dist}" includes="*.war" />
</copy>
<delete dir="${GUI}" />
<delete dir="${build}" />
</target>
Iam completely new to gradle, I was told to migrate the existing ant
script into gradle at my company. Somebody please help me on How to
convert the above given ant script into gradle.
Iam completely new to gradle, I was told to migrate the existing ant
script into gradle at my company. Somebody please help me on How to
convert the above given ant script into gradle.
I would start with a very basic build.gradle file in your root directory of the DikshaPortal project, run gradle build from the terminal or command line and see what happens. Do you understand your dependencies for this project? If so, then you can add that block into your gradle script.
apply plugin: 'war'
dependencies {
//enter your dependenices here such as
compile group: 'com.junit' name: 'junit' version: '4.12'
}
This is a start. Gradle docs are decent so I'd start to acquaint yourself with them. I just completed a decent size project converting Ant to Gradle in my first job as a developer and it took a while! Run a gradle build to check for errors. Even when it's successful check your war (or any generated artifact) against the Ant and keep on going. Hope that helps.
https://gradle.org/guides/
https://github.com/shekhargulati/gradle-tips
http://dougborg.org/what-makes-a-good-build-dot-gradle
https://docs.gradle.org/3.3/dsl/ You can change the version to whichever you are using.
Not an exact answer but a possible alternative solution.
I dont believe that there is a conversion tool for ant to gradle, but you can just import your ant file into gradle and run it from there.
Here is how to do it:
https://docs.gradle.org/current/userguide/ant.html?_ga=2.102231682.2042183466.1518506088-863573233.1518506088#sec:import_ant_build
Seems more viable than trying to rewrite the whole script to gradle.
build.gradle file
ant.importBuild 'build.xml'

maven ant run plugin - killing process that was spawned

Can somebody tell me if it is possible to spawn a process and then kill that process when integration tests have finished running?
I am currently using the ant run plugin to start a grunt connect server and I am using cargo to deploy my rest app to tomcat, this allows me to integration test against the running angular web app which calls rest services.
I almost have everything how I want it but.. when the build has finished the grunt server is still running because I have set keep alive to true.
Ideally when my build finishes I would like to somehow kill the process the for the server.
I came back to this as the final piece I needed to fix to get my multi-module project building and running integration tests against an angular front end and java back end as my build runs in maven.
The final thing to do to kill the node server which is spawned is to use the ant run plugin to kill it (simple really!).
Anyway hopefull this might help someone else in the future:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>Run grunt integration-test task in pre-integration-test phase</id>
<phase>pre-integration-test</phase>
<configuration>
<target name="starting">
<echo>
</echo>
<exec executable="cmd" spawn="true" dir="${project.basedir}"
osfamily="windows">
<arg line="/c grunt int-test --no-color > grunt.status " />
</exec>
<exec executable="bash" spawn="true" dir="${project.basedir}"
osfamily="unix">
<arg line="grunt int-test --no-color > grunt.status" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>Kill NodeServer in post-integration-test phase</id>
<phase>post-integration-test</phase>
<configuration>
<target name="ending">
<echo>
</echo>
<exec executable="cmd" spawn="true" dir="${project.basedir}"
osfamily="windows">
<arg line="/c Taskkill /IM node.exe /F " />
</exec>
<exec executable="bash" spawn="true" dir="${project.basedir}"
osfamily="unix">
<arg line="kill -9 $(ps aux | grep '\snode\s' | awk '{print $2}')" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

batch updating manifest.mf for existing jars using maven

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

Does sequential work on CC.Net 1.6?

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.

Resources