0

I'm using maven-ant-run plugin to run jar batch through maven, it works cool, what I need is to be able to read system.out.println strings in maven build report.

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <phase>clean</phase>
                        <configuration>
                            <target>
                                <echo>
                                    Language synchronization is being started
                                </echo>
                                <exec executable="cmd.exe"
                                      spawn="true">
                                    <arg value="/c"/>
                                    <arg value="${languagesynch.path}"/>
                                    <arg value="C:\ContinuousIntegration\res" /> <!--copy from-->
                                    <arg value="${project.basedir}\res" /> <!--to this directory-->


                                </exec>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

it only shows executing tasks and executed tasks.

[INFO] --- maven-antrun-plugin:1.6:run (default) ---
[INFO] Executing tasks

main:
     [echo] Language synchronization is being started through D:\Projects\MavenI
nHerd\LanguageSynch\out\artifacts\LanguageSynch_jar\LanguageSynch.jar
[INFO] Executed tasks
Mustafa Güven
  • 15,526
  • 11
  • 63
  • 83

1 Answers1

1

If you use spawn="true", this is not possible. Set spawn to false (default), and it works.

Update:

Try using:

<java fork="true" 
      jar="${languagesynch.path}/dist/test.jar">
    <arg value="C:\ContinuousIntegration\res" /> <!--copy from-->
    <arg value="${project.basedir}\res" /> <!--to this directory-->
</java>

Or if for any reason you MUST use exec:

<exec executable="cmd.exe" spawn="false">
    <arg value="/c"/>
    <arg value="java"/>
    <arg value="-jar"/>
    <arg value="${languagesynch.path}"/>
    <arg value="C:\ContinuousIntegration\res" /> <!--copy from-->
    <arg value="${project.basedir}\res" /> <!--to this directory-->
</exec>
blackbuild
  • 5,026
  • 1
  • 23
  • 35
  • when I set to false it wont run the batch file [echo] Language synchronization is being started through D:\Projects\MavenI nHerd\LanguageSynch\out\artifacts\LanguageSynch_jar\LanguageSynch.jar [exec] 'D:\Projects\MavenInHerd\LanguageSynch\out\artifacts\LanguageSynch_j ar\LanguageSynch.jar' is not recognized as an internal or external command, [exec] operable program or batch file. [exec] Result: 1 [INFO] Executed tasks – Mustafa Güven Mar 05 '14 at 08:13
  • @MustafaGüven Try not calling the jar file directly but calling `cmd /c java -jar myjar.jar`. You could also use `` instead of `exec` which would reduce path problems. – blackbuild Mar 05 '14 at 09:11
  • what do you mean try not to call directly? could you share a simple sample? (I'm also looking for java fork on the net as you said) – Mustafa Güven Mar 05 '14 at 09:33
  • @MustafaGüven Reading from your outpu, you call `cmd /c my.jar ...`, correct? I updated my answer, try the hava version above. – blackbuild Mar 05 '14 at 09:46