migrating ant from 1.7 to 1.8.2 issue - ant

I have migrated Ant1.7 to 1.8.2. Getting follwing warning in my eclipse as:
The following error occurred while executing this line:
jar:file:/C:/software/apache-ant-1.8.2/lib/
ant.jar!/org/apache/tools/ant/antlib.xml:37:
Problem: failed to create task or type
componentdef
Cause: The name is undefined. Action: Check the spelling. Action:
Check that any custom tasks/
types have been declared. Action: Check that any /
declarations have
taken place.
from my build.xml importing another build xml file as:
<import file="../../../BUILD/ESW/ESWBUILD/build-utils.xml"/>
Analysis:
1)if i point to 1.7, error doesnt occur.
2) Open build.xml, modify something and save, after saving error is gone.
How can I solve above issue?

It sounds like you might have multiple versions of Ant in your classpath, and the older one is picked up first, but then it also tries to load the descriptor for 1.8.1, which will result in this sort of error. I would check the following:
Check your CLASSPATH and ensure that it is set to the newer version of ant, and does not include the older version of ant
Run ant -version and ensure it is using ant 1.8.1
Check the version of ant that eclipse is using and ensure it is using the correct path as well
If this is a grails application, and you are using an older version of grails, you may need to update it - see this question. It's possible other frameworks might have similar problems, but I'd need to know more about your application to say for certain.
If none of this solves your problem, you could try temporarily removing ant 1.7. If some component then complains that it cant find that version, then you will have to update that component to use 1.8.1 instead.

I ran into the same issue and there is a ant packaged with one of the vendor jars that I included. Removed the vendor jar and it fixed it

Related

sonar multi-module scan with java libraries

I'm running sonar scan with following versions:
ant v3.0.5
sonar v4.5.4
sonar-ant-task v2.3
My ant project contains 100+ submodules; about half of them have external libs, and half don't
In my ant build file, following sonar properties are set:
sonar.projectKey = com.foo:bar
sonar.projectName = foobar
sonar.projectVersion = ${build.version.major}.${build.version.minor}.${build.version.subminor}
sonar.sourceEncoding=UTF-8
sonar.language = java
sonar.sources = src
sonar.java.binaries = build/classes
sonar.java.libraries = build/dependency/*.jar
Initial problem with above is that for the modules that don't have external libs, it fails since there's no jar inside /build/dependency after compilation.
According to this archive link: http://sonarqube-archive.15.x6.nabble.com/Analysis-aborts-because-of-quot-No-files-nor-directories-matching-lib-jar-quot-td5035215.html
I should be able to change the libraries property to
sonar.java.libraries = build/dependency/*
But this did not work for the combination of app versions i listed above. Using only "*" results in class not found error so i don't even think it correctly grabs the dependency jar files.
Could anyone advise if i'm using incorrect combination of the versions, or if this have regressed?
My current workaround:
Keep the "*.jar" as default project property, and add individual module's libraries property to the empty folder for those that do not have dependency jar. e.g.
module1.sonar.projectName=module1
module1.sonar.projectBaseDir=modules/module1
module1.sonar.java.libraries=build/dependency
module2.sonar.projectName=module2
module2.sonar.projectBaseDir=modules/module2
module2.sonar.java.libraries=build/dependency
... x 50 more of these
Is there more elegant solution?
thanks,
Scott
sonar.java.libraries property is handled by the SonarQube Java plugin. Please provide its version and if it is not the latest try to update.
You're on the right track. The analysis of Java multi-module projects is only easy for Maven users. :-(

class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec was not found

I have somewhat common problem with ant not being able to find the class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec. However, the common solutions don't work for me:
ensuring that the jsch.jar and ant-jsch.jar exists in the classpath
ensuring that there are not multiple different versions of the mentioned jars
ensuring that ant -diagnostics is infact seeing the jars
I have no idea what I should try out next. The output I get is the good 'ol:
build.xml: Problem: failed to create task or type sshexec
Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec was not found.
This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in
-/usr/share/ant/lib
-/opt/home/myname/.ant/lib
-a directory added on the command line with the -lib argument
Do not panic, this is a common problem.
The commonest cause is a missing JAR.
My setup:
ant version: Apache Ant(TM) version 1.9.2 compiled on January 22 2014
ant-jsch version: 1.9.2
jsch version: 0.1.52
Ant diagnostics log can be found here: http://pastebin.com/q5AURxuk
As seen from the diagnostics log, the jars are there but ant reports:
sshexec : Not Available (the implementation class is not present)
I also extracted the jar file and ensured that the class is there.
Any ideas?
I've been hit by nearly the same problem, especially ant -diagnostics shows that sshexec task is "Not available".
On my system the solution was to install package "ant-optional" additionally (as I've already posted here: ANT can't find specific libraries)
Maybe this helps.
Regards
Came across a problem very similar to yours, problem with SCP rather than SSH but otherwise the same. Tou don't say if you compiled Ant yourself ot used a binary distribution, but or us it turned out to be a problem with the ant-jsch.jar not compiling properly. There was no suggestion of a problem on compile, but the jar was much smaller than expected, only 6k. We fixed the issue by using the ant-jsch.jar from the binary distribution, which is 48k. This was with ant-1.9.4 and ant-1.9.5, Java 1.8.0_45.

Jenkins Cannot find executable for ANT

I'm using the automatic installation option for Ant but still jenkins complains that it cannot find the executable. Am I missing something? I have given the path to the ant version we use. It has successfully downloaded and unpacked it on the server but it still complains it can't find the executable.
Did you install Ant? Is it in Jenkin's PATH? If not, Jenkins cannot use the default version of Ant.
However, if you go into the Jenkins configuration page, you can install various versions of Ant. For example, you may want to install the latest version of Ant, and Ant 1.5 for that one project that cannot use any version of Ant beyond 1.5:
When you define your project, you can select the version of Ant you want to use. When you select that you want to Invoke Ant as a build step, you are given a drop down menu of what version of Ant you want to use. The first is the Default which is the Ant version found in your PATH. However, if you've gone into Jenkins configuration and downloaded other versions of Ant, you can use one of those instead.
I think is more easy to you install ant manually , or you need check the jenkins log file for detailed errors
Found what I missed. I had to add the name of the directory it unpacks the ant file to in the
"Subdirectory of extracted archive" field. Forgot to mention we are using a fairly old version of ant. (1.7.0).

Grails ant tasks don't work - Unable to start Grails: java.lang.reflect.InvocationTargetException

I'm having issues getting something which seems very basic running with Grails. I want to call grails commands from an Ant script - Grails provides a Grails task to achieve this. I have defined the Grails taskdef and classpaths as per the docs however, no matter what command I call I get the same error...
grails-compile:
[grails] Resolving dependencies...
[grails] Dependencies resolved in 1192ms.
BUILD FAILED
/java/grailstest/build.xml:22: Unable to start Grails: java.lang.reflect.InvocationTargetException
Even when I create a new Grails app using 'grails create-app' and then run the integrate ant command 'grails integrate-with --ant' to generate a default build.xml, I get the same error when running any of the tasks in the generated build.xml.
I've tested this with Grails 1.3.1, 1.3.4 and 1.3.5 and am getting the same error.
Has anyone else encountered this problem? There must be something stupid I'm doing wrong or this would never have made it out the door of the Grails factory... ;)
I forgot to mention that I am using Ant version 1.8.1. I have just discovered that switching back to Ant 1.7.1 'solves' this problem but this is not really ideal as I need 1.8.1 for other build tasks. I'll submit a bug on the Grails issue tracker as it seems a lot of people are having the same problem.
I've just found the same issue. It seems that Ant 1.8 is not supported yet (but Ant 1.7 is), see GRAILS-6897. Some users have complained that the documentation does not state it strictly.

ant-metricstask.jar

Warning : since version 1.3.6 the anttask.jar as been renamed ant-metricstask.jar
As of version 1.3.2 the metrics plugin contains some ant tasks that can be used for headless operations as part of a nightly build for example. This section describes how to do this.
Where can i get it? I can not find it anywhere.
Are you looking for ant-metricstask.jar?
It's available in the eclipse plugin downloadable at
http://sourceforge.net/projects/metrics/files/
Point eclipse directly at the URL or download the updatesite_1.3.6.zip and you can get the jar inside.

Resources