EzDevInfo.com

ant interview questions

Top ant frequently asked interview questions

Error executing command 'ant' on Mac OS X 10.9 Mavericks when building for Android with PhoneGap/Cordova

Today I tried PhoneGap/Cordova with Mac OS X Mavericks. Building for iOS went just fine, but building for Android wasn't without some guesswork.

I installed Android 4.2.2 via the Android SDK Manager (I had to use the older API v17 since it wasn't compatible with a newer one), added the PATH environment variables for the SDK's platform-tools and tools and thought I was ready to take off by running the command:

phonegap run android

Nevertheless, I got the following error:

[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project. ERROR : executing command 'ant', make sure you have ant installed and added to your path.

Source: (StackOverflow)

How can I install Apache Ant on Mac OS X?

I tried to install Apache Ant on my Mac and I followed the next steps :

  1. I downloaded apache-ant-1.8.1-bin.tar.gz into my Downloads folder.
  2. I moved the file to /usr/local/ using this commands : sudo sh and mv apache-ant-1.8.1-bin.tar.gz /usr/local/

Now I want to use cd /usr/local/ but it's not working, I get back "No such file or directory".

Then I used cd /usr/ and ls commands and it seems that the local folder is there. If I try to access it I get the same error.

Since I already used sudo su why I can't access it? Any ideas?


Source: (StackOverflow)

Advertisements

Why is no one using make for Java?

Just about every Java project that I've seen either uses Maven or Ant. They are fine tools and I think just about any project can use them. But what ever happened to make? It's used for a variety of non-Java projects and can easily handle Java. Sure you have to download make.exe if you use Windows, but Ant and Maven also don't come with the JDK.

Is there some fundamental flaw with make when used with Java? Is it just because Ant and Maven are written in Java?


Source: (StackOverflow)

Ant: How to execute a command for each file in directory?

I want to execute a command from an Ant buildfile, for each file in a directory.
I am looking for a platform-independent solution.

How do I do this?

Sure, I could write a script in some scripting language, but this would add further dependencies to the project.


Source: (StackOverflow)

SASS implementation for Java? [closed]

I'm looking for SASS implementation in Java (could be used with JSP/JSF). For Python I've found CleverCSS, but there is nothing for Java. Anyone heard something about this sort of tool for generating CSS?


Source: (StackOverflow)

Any way to generate ant build.xml file automatically from Eclipse?

From Eclipse, I found I can easily export an Ant build file for my project. It provides references to 3rd party libraries and some base targets. I'm using it from my global build file. The only thing that bothers me about this, is that if something is modified in the project structure (like adding a new 3rd party library), we have to think (yes that can be hard sometimes!) about regenerating that build.xml file. I'm wondering if anyone here knows a way to have it updated automatically. By "automatically" I mean that it would not be necessary to explicitly ask Eclipse to regenerate it every time it's needed. I don't know what could be the trigger though...

Any thoughts or knowledge on this?

Thanks!

MJ


Source: (StackOverflow)

JUnit: how to avoid "no runnable methods" in test utils classes

I have switched to JUnit4.4 from JUnit3.8. I run my tests using ant, all my tests run successfully but test utility classes fail with "No runnable methods" error. The pattern I am using is to include all classes with name *Test* under test folder.

I understand that the runner can't find any method annotated with @Test attribute. But they don't contain such annotation because these classes are not tests. Surprisingly when running these tests in eclipse, it doesn't complain about these classes.

In JUnit3.8 it wasn't a problem at all since these utility classes didn't extend TestCase so the runner didn't try to execute them.

I know I can exclude these specific classes in the junit target in ant script. But I don't want to change the build file upon every new utility class I add. I can also rename the classes (but giving good names to classes was always my weakest talent :-) )

Is there any elegant solution for this problem?


Source: (StackOverflow)

javac1.8 class not found

I have installed two jdks - jdk 1.5 and jdk 1.8. I have following Ant build.xml config file :

<target name="compileCustomSrc">
    <javac srcdir="src" destdir="build/classes" source="1.5" target="1.5" >
        <classpath>
            <fileset dir="C:/lib/">
                <include name="*.jar" />
            </fileset>
        </classpath>
    </javac>
</target>

Before installing jdk1.8, Ant invoked from Eclipse compiled all sources successful. But now, I have following error message:

Class not found: javac1.8

My JAVA_HOME and JRE_HOME:

JAVA_HOME = C:\Program Files (x86)\Java\jdk1.5.0_16
JRE_HOME = C:\Program Files (x86)\Java\jre1.5.0_16

and set in Eclipse JRE to 1.5. Does Java 1.8 set some configs during installation?


Source: (StackOverflow)

Unable to locate tools.jar [duplicate]

Possible Duplicate:
Unable to locate tools.jar

I'm trying to use ant to compile using this command :

 ant compile

I don't know if the problem comes from my windows 64bit, or by something else. Because I have java Installed in the 64 & 32 prog files.

Java 64 & 32

I downloaded apache-ant-1.8.2-bin and putted it in C:\Program Files\apache-ant-1.8.2

I tried to put ant everywhere, I switched also the ENV PATH between java 64 and 32 but everytime I get this error message :

Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar

I searched for tools.jar in the ant lib folder, in the java 64 and 32, but no trace of it in the system.

What do you think ?


Source: (StackOverflow)

Ant is using wrong java version

I'm using Ant 1.7.0 and installed java 1.6 which is in JAVA_HOME.

I want to build a project using java 1.5, so I've exported JAVA_HOME to be my java 1.5 directory.

java -version

says "1.5". When I run Ant it uses java 1.6.


Source: (StackOverflow)

Can someone explain the ivy.xml dependency's conf attribute?

I can't find any thorough explanation of the Ivy dependency tag's conf attribute:

<dependency org="hibernate" name="hibernate" rev="3.1.3" conf="runtime, standalone -> runtime(*)"/>

See that conf attribute? I can't find any explanation (that I can understand) about the right hand side of the -> symbol. PLEASE keep in mind I don't know the first thing about Maven so please explain this attribute with that consideration.

Yes, I've already looked at this: http://ant.apache.org/ivy/history/latest-milestone/ivyfile/dependency.html

Thanks,
Dan


Source: (StackOverflow)

Clean way to combine multiple jars? Preferably using Ant

I have runtime dependencies on some external jars that I would like to "rejar" into a single jar. These external dependencies are stored in an external_jars directory, and I'd like to be able to not have to list them all (i.e., not to need to change my build scripts if my dependencies change). Any thoughts?

Google gave me a good answer on how to do this - if you don't mind listing out each jar as a dependency:

http://markmail.org/message/zijbwm46maxzzoo5

Roughly, I want something along the lines of the following, which would combine all jars in the lib directory into out.jar (with some sane overwrite rules).

jar -combine -out out.jar -in lib/*.jar

Source: (StackOverflow)

No key.store and key.alias properties found in build.properties

I am using ant-release to do a 1-step build of my Android app.

My build.properties looks like this:

application.package=xxxxx
key.store=sonr
key.alias=sonr labs
key.store.password=xxxx
key.alias.password=xxxx

When I run ant-release everything is fine except for application signing. I get the error:

-release-prompt-for-password:

-release-nosign:
     [echo] No key.store and key.alias properties found in build.properties.
     [echo] Please sign /Users/syalam/Documents/git/joeborn-sonr/sonr/bin/SONR-release-unsigned.apk manually
     [echo] and run zipalign from the Android SDK tools.
[propertyfile] Updating property file: /Users/syalam/Documents/git/joeborn-sonr/sonr/bin/build.prop
[propertyfile] Updating property file: /Users/syalam/Documents/git/joeborn-sonr/sonr/bin/build.prop
[propertyfile] Updating property file: /Users/syalam/Documents/git/joeborn-sonr/sonr/bin/build.prop
[propertyfile] Updating property file: /Users/syalam/Documents/git/joeborn-sonr/sonr/bin/build.prop

How can I resolve this?

PS. I followed this tutorial for getting my build process down http://www.androidengineer.com/2010/06/using-ant-to-automate-building-android.html


Source: (StackOverflow)

How can I import one Gradle script into another?

I have a complex gradle script that wraps up a load of functionality around building and deploying a number of netbeans projects to a number of environments.

The script works very well, but in essence it is all configured through half a dozen maps holding project and environment information.

I want to abstract the tasks away into another file, so that I can simply define my maps in a simple build file, and import the tasks from the other file. In this way, I can use the same core tasks for a number of projects and configure those projects with a simple set of maps.

Can anyone tell me how I can import one gradle file into another, in a similar manner to Ant's task? I've trawled Gradle's docs to no avail so far.

Additional Info

After Tom's response below, I thought I'd try and clarify exactly what I mean.

Basically I have a gradle script which runs a number of subprojects. However, the subprojects are all Netbeans projects, and come with their own ant build scripts, so I have tasks in gradle to call each of these.

My problem is that I have some configuration at the top of the file, such as:

projects = [
    [name:"MySubproject1", shortname: "sub1", env:"mainEnv", cvs_module="mod1"],
    [name:"MySubproject2", shortname: "sub2", env:"altEnv", cvs_module="mod2"]
]

I then generate tasks such as:

projects.each({
    task "checkout_$it.shortname" << {
         // Code to for example check module out from cvs using config from 'it'.
    }
})

I have many of these sort of task generation snippets, and all of them are generic - they entirely depend on the config in the projects list.

So what I want is a way to put this in a separate script and import it in the following sort of way:

projects = [
    [name:"MySubproject1", shortname: "sub1", env:"mainEnv", cvs_module="mod1"],
    [name:"MySubproject2", shortname: "sub2", env:"altEnv", cvs_module="mod2"]
]

import("tasks.gradle") // This will import and run the script so that all tasks are generated for the projects given above.

So in this example, tasks.gradle will have all the generic task generation code in, and will get run for the projects defined in the main build.gradle file. In this way, tasks.gradle is a file that can be used by all large projects that consist of a number of sub-projects with Netbeans ant build files.


Source: (StackOverflow)

Replacing characters in Ant property

Is there a simple way of taking the value of a property and then copy it to another property with certain characters replaced?

Say propA=This is a value. I want to replace all the spaces in it into underscores, resulting in propB=This_is_a_value.


Source: (StackOverflow)