What is the best way to avoid maven-jar?

In Maven 3.0.x (I tried 3.0.2) you can disable maven-jar-plugin by binding the default-jar execution to a nonexistent phase, as @bmargulies suggested. Unfortunately that doesn’t work in 2.2.1, but you can prevent it from interfering with your own jar by setting an alternative <finalName> and <classifier> for the default-jar execution; it will still create a … Read more

Java project: should .classpath .project file be committed into repository? [duplicate]

There is nothing wrong with checking in .project and .classpath. I would do so, if your build.xml isn’t able to create both of the files for you. As you said, it’s uncomfortable to miss these files when you try to create a new eclipse workspace. Before you check in .classpath you should be sure that … Read more

Use Ant for running program with command line arguments

Extending Richard Cook’s answer. Here’s the ant task to run any program (including, but not limited to Java programs): <target name=”run”> <exec executable=”name-of-executable”> <arg value=”${arg0}”/> <arg value=”${arg1}”/> </exec> </target> Here’s the task to run a Java program from a .jar file: <target name=”run-java”> <java jar=”path for jar”> <arg value=”${arg0}”/> <arg value=”${arg1}”/> </java> </target> You can … Read more

How to Pass parameters for a Ant script , which is invoked via shell script?

Do you mean assigning value to a property from command line? If so, try -DpropertyName=itsValue For example, <project> <target name=”hi”> <property name=”person” value=”world”/> <echo message=”Hello ${person}”/> </target> </project> and then ant -Dperson=”MerryPrankster” hi yields [echo] Hello MerryPrankster

How to lookup the latest git commit hash from an ant build script

I wrote the following ant target for a project on github. Usage: stores version in property “repository.version” works if no git is installed or no .git directory is present (fallback) other targets must depend on this target if they need the git version only one git command gets executed (–always) <available file=”.git” type=”dir” property=”git.present”/> <target … Read more

Make javac treat warnings as errors

Use the -Werror flag. It’s not listed in the -help output, but it works. I found it through this blog entry and tested on my own code (in NetBeans with Ant). The output was: MyClass.java:38: warning: [serial] serializable class MyClass has no definition of serialVersionUID public class MyClass extends JComponent { 1 warning BUILD FAILED … Read more

Why does ANT tell me that JAVA_HOME is wrong when it is not?

In Eclipse click Run → External Tools → External Tools Configurations. Click the JRE tab. Click the Installed JREs… button. Click the Add button. (Select Standard VM, where applicable.) Click the Directory button. Browse to your JDK version (not JRE) of your installed Java (e.g. C:\Program Files\Java\jdk1.7.0_04). Click Finish and OK. Select the JDK at … Read more