Gradle unable to find aspectjtools.jar from ant build.xml


(Subodh Brahmi) #1

I am in the middle of migrating ivy/ant based project to gradle. However, trying to run a compile ant task from gradle it throws:

[ERROR] [org.gradle.BuildExceptionReporter] > Reference /Users//testProject/dependencies/aspectjtools.jar not found.

when the aspectjtools.jar is there at the path mentioned.

Here is my build.xml:

<target name="compile" depends="init">
	 <!--<taskdef classpathref="build.classpath" resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties" /> -->
	<!-- Temporary to fix aspectjTaskdefs.properties. It could not be found error-->
	<taskdef classpathref="${basedir}/dependencies/aspectjtools.jar" resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties" />
	<echo level="info">--- compile (start) ---</echo>
	<iajc source="${source}" target="${target}" showweaveinfo="true" verbose="true" destdir="${bin.dir}" debug="false">
		<inpath location="${src.dir}">
		</inpath>
		<sourceroots>
			<pathelement location="${src.dir}" />
		</sourceroots>
		<classpath refid="build.classpath">
		</classpath>
	</iajc>
	<echo level="info">--- compile (finished) ---</echo>
</target>

where ${basedir}/dependencies/ resolves to /Users//testProject/dependencies

and here is build.gradle

buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url “$nexusUrl/content/groups/public/” }
maven { url “https://plugins.gradle.org/m2/” }

}

dependencies {
    classpath group: 'com.smokejumperit.gradle.license', name: 'Gradle-License-Report', version: '0.0.2'
    classpath 'com.bmuschko:gradle-clover-plugin:2.0.1'
}

}
plugins {
id “org.sonarqube” version “1.2”
}

group ‘com.testProject’

apply plugin: 'java’
apply plugin: 'idea’
apply plugin: ‘eclipse’

// Apply the java plugin to add support for Java

apply plugin: 'distribution’
apply plugin: ‘maven’

sourceCompatibility = 1.8
targetCompatibility = 1.8

// In this section you declare where to find the dependencies of your project
repositories {
// Use ‘jcenter’ for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
mavenLocal()
mavenCentral()
maven { url “$nexusUrl/content/groups/public/” }
}

configurations {
antconf
}

// ant.path(id: ‘classpath’, location: ‘./lib’)

// In this section you declare the dependencies for your production and test code
dependencies {

antconf 'ant-contrib:ant-contrib:1.0b3'

// The production code uses the SLF4J logging API at compile time
compile 'org.slf4j:slf4j-api:1.7.18'

compile 'org.hamcrest:hamcrest-core:1.3'
compile 'org.hamcrest:hamcrest-library:1.3'
compile 'javax.media:jai-core:1.1.3'
compile 'com.sun.media:jai-codec:1.1.3'
compile 'com.sun.jersey:jersey-client:1.11'
compile 'com.sun.jersey:jersey-core:1.11'
compile 'com.sun.jersey.contribs:jersey-apache-client:1.17.1'
compile 'org.javassist:javassist:3.18.2-GA'
compile 'org.reflections:reflections:0.9.9'
compile 'sshtools:j2ssh-core:0.2.9'
compile 'org.aspectj:aspectjrt:1.8.9'
compile 'org.aspectj:aspectjweaver:1.8.9'
compile 'org.aspectj:aspectjtools:1.8.9'
compile 'net.sourceforge.jexcelapi:jxl:2.6.12'
compile 'commons-codec:commons-codec:1.8'
compile 'commons-configuration:commons-configuration:1.7'
compile 'commons-lang:commons-lang:2.6'
compile 'commons-io:commons-io:2.5'
compile 'com.google.code.gson:gson:2.1'
compile 'org.testng:testng:6.9.10'
compile 'com.google.inject:guice:3.0'
compile 'io.github.lukehutch:fast-classpath-scanner:2.0.6'
compile 'velocity:velocity-dep:1.4'
compile 'org.seleniumhq.selenium:selenium-remote-driver:2.53.0'
compile 'org.seleniumhq.selenium:selenium-java:2.53.0'
compile 'org.codehaus.groovy:groovy-all:2.1.9'
testCompile 'info.cukes:cucumber-java:1.2.4'
compile 'org.json:json:20160810'
compile 'javax.mail:mail:1.4.7'
compile 'org.xmlmatchers:xml-matchers:0.10'

// Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
// 'test.useTestNG()' to your build script.
testCompile 'junit:junit:4.12'

}

ClassLoader antClassLoader = org.apache.tools.ant.Project.class.classLoader
configurations.antconf.each { File f ->
antClassLoader.addURL(f.toURI().toURL())
}

ant.importBuild ‘build.xml’

//println compile.asPath

task showTestTaskClasspath << {
test.classpath.each { println it }
}

task printClasspath {
doLast {
configurations.testRuntime.each { println it }
}
}

Any help would be much appreciated.


(Subodh Brahmi) #2

I would appreciate if anyone could help with this.

Thank you!


(Mark Vieira) #3

I think the issue here is that classpathref should actually be classpath since what you are supplying is a classpath and not a reference to another predefined resource.