everyone
here is the build script
apply{
plugin 'java'
}
sourceCompatibility=1.5
List spring = ["org.springframework:spring-webmvc:$springVersion@jar",
"org.springframework:spring-orm:$springVersion@jar",
"org.springframework:spring-context-support:$springVersion@jar"]
List spring_js = [ "org.springframework.webflow:spring-js:2.0.7.RELEASE@jar",
"org.apache.ibatis:com.springsource.com.ibatis:2.3.4.726@jar",
"com.caucho:com.springsource.com.caucho:3.2.1@jar",
"org.apache.axis:com.springsource.org.apache.axis:1.4.0@jar",
"javax.wsdl:com.springsource.javax.wsdl:1.6.1@jar"]
configurations {
compile {
description = 'compile classpath'
transitive = true
}
runtime {
extendsFrom compile
}
}
def localMavenRepo = 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
repositories{
mavenCentral()
maven{
url localMavenRepo
}
}
dependencies{
compile spring, spring_js, 'commons-fileupload:commons-fileupload:1.2.1','org.apache.struts:com.springsource.org.apache.struts:1.2.9',
'javax.xml.rpc:com.springsource.javax.xml.rpc:1.1.0','org.apache.commons:com.springsource.org.apache.commons.dbcp:1.2.2.osgi',
'commons-io:commons-io:1.3.2','hsqldb:hsqldb:1.8.0.7','org.apache.tiles:tiles-jsp:2.2.0','org.tuckey:urlrewritefilter:3.1.0',
'org.apache.tiles:tiles-core:2.2.0'
runtime 'javax.servlet:jstl:1.2','org.aspectj:aspectjweaver:1.6.5','javax.servlet:servlet-api:2.5','javax.servlet.jsp:jsp-api:2.1'
testCompile 'junit:junit:4.6'
}
The jars are present in local maven repo but when I run gradle –info clean build the build fails with errors such as
/home/anadi/Code/gradle-samples/java-proj/gradleSpringJpetStore/src/main/java/org/springframework/samples/jpetstore/web/spring/SignonInterceptor.java:17: cannot find symbol
symbol : class HttpServletResponse
location: class org.springframework.samples.jpetstore.web.spring.SignonInterceptor
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
^
/home/anadi/Code/gradle-samples/java-proj/gradleSpringJpetStore/src/main/java/org/springframework/samples/jpetstore/web/spring/RemoveItemFromCartController.java:9: package org.springframework.web.util does not exist
import org.springframework.web.util.WebUtils;
^
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
Total time: 4.969 secs
If I run the same build with maven it picks up all dependencies from the local repo and does a compile successfully. I also tried the –refresh-dependencies switch but no help.
As Benjamin said, you are probably missing a dependency declaration. Note that your use of
@jardisables transitive dependency resolution.@jarmeans ” I want just this Jar, not any of the dependencies declared in its POM”.The preferred way to declare the local Maven repo is
repositories { mavenLocal() }. Unless you have some other build installing into the local Maven repository and this build pulling from it, it is neither recommended nor necessary to declaremavenLocal()though. Gradle is smart enough to automatically steal Jars from the local Maven repo (to avoid downloading them) if their checksum matches.Your
configurationsblock can be removed completely. All of that is already configured by thejavaplugin.