You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Trevor Harmon <tr...@vocaro.com> on 2008/08/18 20:46:59 UTC
Launching a Java application from Maven (vs. Ant)
Hi all,
I'm an experienced Ant user but new to Maven, and I'm a little shocked
at how verbose Maven is, even compared to Ant, which is notorious for
its verbosity. For example, if I want to launch a Java application in
Ant, I do this:
<target name="run">
<java classname="foo.Bar" classpath="${my.classpath}">
<sysproperty key="mykey" value="myvalue"/>
<arg value="-h"/>
</java>
</target>
These six lines of Ant explode into 27 lines when ported to Maven:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>foo.Bar</mainClass>
<arguments>
<argument>-h</argument>
</arguments>
<systemProperties>
<systemProperty>
<key>mykey</key>
<value>myvalue</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
Plus, when I want to run the Ant task, I only have to type this:
# ant run
But in Maven I have to type all this:
# mvn org.codehaus.mojo:exec-maven-plugin:java
Everything about Maven seems more complex, more verbose, and more
difficult, at least for this example. Am I missing something? I
thought Maven was supposed to make things simpler...
Trevor
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Launching a Java application from Maven (vs. Ant)
Posted by John Casey <jd...@commonjava.org>.
BTW, unless I'm misataken, the following invocation should also work:
mvn exec:java
-j
Trevor Harmon wrote:
> Hi all,
>
> I'm an experienced Ant user but new to Maven, and I'm a little shocked
> at how verbose Maven is, even compared to Ant, which is notorious for
> its verbosity. For example, if I want to launch a Java application in
> Ant, I do this:
>
> <target name="run">
> <java classname="foo.Bar" classpath="${my.classpath}">
> <sysproperty key="mykey" value="myvalue"/>
> <arg value="-h"/>
> </java>
> </target>
>
> These six lines of Ant explode into 27 lines when ported to Maven:
>
> <build>
> <plugins>
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>exec-maven-plugin</artifactId>
> <executions>
> <execution>
> <goals>
> <goal>java</goal>
> </goals>
> </execution>
> </executions>
> <configuration>
> <mainClass>foo.Bar</mainClass>
> <arguments>
> <argument>-h</argument>
> </arguments>
> <systemProperties>
> <systemProperty>
> <key>mykey</key>
> <value>myvalue</value>
> </systemProperty>
> </systemProperties>
> </configuration>
> </plugin>
> </plugins>
> </build>
>
> Plus, when I want to run the Ant task, I only have to type this:
>
> # ant run
>
> But in Maven I have to type all this:
>
> # mvn org.codehaus.mojo:exec-maven-plugin:java
>
> Everything about Maven seems more complex, more verbose, and more
> difficult, at least for this example. Am I missing something? I thought
> Maven was supposed to make things simpler...
>
> Trevor
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
--
John Casey
Developer, PMC Member - Apache Maven (http://maven.apache.org)
Blog: http://www.ejlife.net/blogs/buildchimp/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Launching a Java application from Maven (vs. Ant)
Posted by Brett Porter <br...@gmail.com>.
2008/8/19 Trevor Harmon <tr...@vocaro.com>:
> But isn't this a pretty common use case? I mean, launching a Java
> application happens pretty often in most Java development life cycles. You
> can only go so far with unit tests; eventually you need to run the thing and
> see how it looks.
Not generally within the main build lifecycle (so in fact, you can
probably remove the <executions> element entirely).
>
> Even if this were an atypical use case, in Ant there are mechanisms for
> reducing complex blocks of code to simple statements. MacroDef and
> PreSetDef, for example. Is there a similar mechanism in Maven?
That is what plugins are for, though admittedly the XML to construct
them is quite verbose at the moment.
- Brett
--
Brett Porter
Blog: http://blogs.exist.com/bporter/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Launching a Java application from Maven (vs. Ant)
Posted by Trevor Harmon <tr...@vocaro.com>.
On Aug 18, 2008, at 2:51 PM, John Casey wrote:
> Maven does make the development process simpler in many ways, but
> it's a mistake to think that every possible activity in that process
> will be simpler. Obviously, the power Maven brings in terms of
> dependency handling, standardized lifecycles and lifecycle
> vocabulary, etc. will be completely irrelevant for this use case.
But isn't this a pretty common use case? I mean, launching a Java
application happens pretty often in most Java development life cycles.
You can only go so far with unit tests; eventually you need to run the
thing and see how it looks.
Even if this were an atypical use case, in Ant there are mechanisms
for reducing complex blocks of code to simple statements. MacroDef and
PreSetDef, for example. Is there a similar mechanism in Maven?
Trevor
P.S. Your "exec:java" trick works; thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Launching a Java application from Maven (vs. Ant)
Posted by John Casey <jd...@commonjava.org>.
Maven does make the development process simpler in many ways, but it's a
mistake to think that every possible activity in that process will be
simpler. Obviously, the power Maven brings in terms of dependency
handling, standardized lifecycles and lifecycle vocabulary, etc. will be
completely irrelevant for this use case.
-john
Trevor Harmon wrote:
> Hi all,
>
> I'm an experienced Ant user but new to Maven, and I'm a little shocked
> at how verbose Maven is, even compared to Ant, which is notorious for
> its verbosity. For example, if I want to launch a Java application in
> Ant, I do this:
>
> <target name="run">
> <java classname="foo.Bar" classpath="${my.classpath}">
> <sysproperty key="mykey" value="myvalue"/>
> <arg value="-h"/>
> </java>
> </target>
>
> These six lines of Ant explode into 27 lines when ported to Maven:
>
> <build>
> <plugins>
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>exec-maven-plugin</artifactId>
> <executions>
> <execution>
> <goals>
> <goal>java</goal>
> </goals>
> </execution>
> </executions>
> <configuration>
> <mainClass>foo.Bar</mainClass>
> <arguments>
> <argument>-h</argument>
> </arguments>
> <systemProperties>
> <systemProperty>
> <key>mykey</key>
> <value>myvalue</value>
> </systemProperty>
> </systemProperties>
> </configuration>
> </plugin>
> </plugins>
> </build>
>
> Plus, when I want to run the Ant task, I only have to type this:
>
> # ant run
>
> But in Maven I have to type all this:
>
> # mvn org.codehaus.mojo:exec-maven-plugin:java
>
> Everything about Maven seems more complex, more verbose, and more
> difficult, at least for this example. Am I missing something? I thought
> Maven was supposed to make things simpler...
>
> Trevor
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
--
John Casey
Developer, PMC Member - Apache Maven (http://maven.apache.org)
Blog: http://www.ejlife.net/blogs/buildchimp/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org