I can’t seem to find classes in a jar that I specify in the buildscript dependencies.
I have to build some java classes to use in build tasks so I need to use the buildscripts/buildSrc convention.
As a quick test, if I don’t use buildscripts and move my code from ./buildSrc/src to ./src, this build.gradle builds ok:
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
compile files('/opt/foo/format.jar')
// these classes are found
}
However if I move the same source from ./src to buildSrc/src such that the groovy plugin tries to build it before running any tasks, it fails to find the classes in the above /opt/foo/format.jar
import com.foo.format.*
// not sure if this is even needed, same behavior with & without
apply plugin: 'groovy'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath files ('/opt/foo/format.jar')
// these classes are not found
}
}
%> gradle tasks :buildSrc:compileJava /home/bedge/foo/btest/buildSrc/src/main/java/com/foo/tools/tParser.java:26: error: package com.foo.format.folio does not exist import com.foo.format.folio.DefaultValidationEventHandler;
I did see a similar post, but it did not help with my situation as it stated this should just work. Maybe something has changed in the last year? (http://forums.gradle.org/gradle/topics/how_to_avoid_dependency_on_buildsrc_in_production_environment_and_specify_jar_file_with_compiled_files_on_the_buildscript_classpath)