Trying to resolve dependency in compileJava task in WAR


(Suneetha Yanala) #1

Hi,

I am using expernal dependecies to use a custom gradle plugin and I have project dependencies too. i have my local repository in flatDir. Both dependecies are stored in local repository. After i execute the plugin task, when I am making a war the project dependcies are not picking up from my local repository. Its trying to resolve dependecies from Maven which I didnt mention in my code. my script is freeze and not building the war.

The Error is

:OnBoardingWeb:clean UP-TO-DATE > Building > :OnBoardingWeb:compileJava > Resolving dependencies ':OnBoardingWeb

Its freezing here. My script is -----------------

buildscript {

repositories {

flatDir(dirs: ‘c:/sun/local-repo’) }

dependencies {

classpath ‘com.eriwen:gradle-js-plugin:1.5.1’

classpath fileTree(dir: ‘c:/sun/local-repo’, include: ‘compiler.jar’)

} }

apply plugin: ‘war’ // Invoke the plugin apply plugin: ‘js’

war {

archiveName = ‘OnBoardingWeb.war’

def projDir = “$projectDir/src”

}

repositories {

flatDir(dirs: ‘c:/sun/local-repo’) }

sourceSets {

main {

java {

srcDir ‘src’

}

}

test {

java {

srcDir ‘test’

}

}

}

dependencies {

compile group: ‘castor’, name: ‘castor-1.3.2-commons’, ext: ‘jar’

compile group: ‘castor’, name: ‘castor-1.3.2-core’, ext: ‘jar’

compile group: ‘castor’, name: ‘castor-1.3.2-xml’, ext: ‘jar’

compile group: ‘com.ibm.jaxws.thinclient_6.1.0’, name: ‘com.ibm.jaxws.thinclient_6.1.0’, ext: ‘jar’

compile group: ‘commons’, name: ‘commons-lang’, version: ‘2.6’, ext: ‘jar’

compile group: ‘commons’, name: ‘commons-logging’, version: ‘1.1.1’, ext: ‘jar’

compile group: ‘jackson’, name: ‘jackson-all’, version: ‘1.9.6’, ext: ‘jar’

compile group: ‘log4j’, name: ‘log4j’, version: ‘1.2.15’, ext: ‘jar’

compile name : ‘OLBBCommon’ , ext: ‘jar’

compile name : ‘OLBBException’ , ext: ‘jar’

compile name : ‘OLBBLogging’ , ext: ‘jar’

compile group: ‘spring’, name: ‘spring-aop’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-aspects’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-beans’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-build-src’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-context’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-context-support’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-core’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-expression’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-instrument’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-instrument-tomcat’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-jdbc’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-jms’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-orm’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-oxm’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-struts’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-test’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-tx’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-web’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-webmvc’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

compile group: ‘spring’, name: ‘spring-webmvc-portlet’, version: ‘3.2.2.RELEASE’, ext: ‘jar’

}


(Peter Niederwieser) #2

Gradle will not contact a repository unless it’s declared somewhere. Try to run with ‘–debug’ to see where it hangs.

PS: Please use HTML code tags for all code snippets.


(spencer_allain) #3

JsPlugin.groovy is adding mavenCentral() to your project repositories to search.

void configureDependencies(final Project project) {
        project.configurations {
            rhino
        }
        project.repositories {
            mavenCentral()
        }
        project.dependencies {
            rhino 'org.mozilla:rhino:1.7R3'
        }
        // TODO: have 'check' depend on jshint
    }

This is probably there because it makes it easier to apply the plugin and have it download the required dependencies, but it also means that it could be disallowed for use in environments that require only certain repositories be accessed.

-Spencer


(Suneetha Yanala) #4

As my usage with Jsplugin is working fine and minifying my Js files and its not lookinginto maven. And I am making war its going to MavenRepo. Can I overwrite these dependencies in my build script. So that it can look only in my repositories.

Its finding Js plugin in my flatDir

7:38:34.588 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] flatDir: no ivy file found for com.eriwen#gradle-js-plugin;1.5.1: using default data 17:38:34.588 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] checking com.eriwen#gradle-js-plugin;1.5.1[default] from flatDir against [none] 17:38:34.588 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] module revision kept as first found: com.eriwen#gradle-js-plugin;1.5.1[default] from flatDir 17:38:34.588 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.IvyDependencyResolverAdapter] Performed resolved of module ‘com.eriwen:gradle-js-plugin:1.5.1’ in repository ‘flatDir’: found 17:38:34.588 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain] Using module ‘com.eriwen:gradle-js-plugin:1.5.1’ from repository ‘flatDir’ 17:38:34.588 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting configuration com.eriwen:gradle-js-plugin:1.5.1(default). 17:38:34.604 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching PR:OnBoardingWeb:unspecified(classpath) to its parents. 17:38:34.604 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching com.eriwen:gradle-js-plugin:1.5.1(default) to its parents. 17:38:34.620 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper]

trying C:\sun\local-repo/gradle-js-plugin-1.5.1.jar 17:38:34.620 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper]

tried C:\sun\local-repo/gradle-js-plugin-1.5.1.jar 17:38:34.620 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] [NOT REQUIRED] com.eriwen#gradle-js-plugin;1.5.1!gradle-js-plugin.jar

The trying to go Maven for my project dependecies

17:38:37.198 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting dependency PR:OnBoardingWeb:unspecified(compile) -> castor:castor-1.3.2-commons:(dependency: castor#castor-1.3.2-commons; {compile=[default]}) 17:38:37.198 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Selecting new module version castor:castor-1.3.2-commons: 17:38:37.198 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain] Attempting to resolve module ‘castor:castor-1.3.2-commons:’ using repositories [MavenRepo, flatDir] 17:38:37.198 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Opening cache dynamic-revisions.bin (C:\Documents and Settings\syanala.gradle\caches\artifacts-26\dynamic-revisions.bin) 17:38:37.198 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Opening cache module-metadata.bin (C:\Documents and Settings\syanala.gradle\caches\artifacts-26\module-metadata.bin) 17:38:37.198 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Loading http://repo1.maven.org/maven2/castor/castor-1.3.2-commons//castor-1.3.2-commons-.pom 17:38:37.213 [DEBUG] [org.gradle.api.internal.externalresource.transfer.DefaultCacheAwareExternalResourceAccessor] Constructing external resource: http://repo1.maven.org/maven2/castor/castor-1.3.2-commons//castor-1.3.2-commons-.pom 17:38:37.213 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Opening cache artifact-at-url.bin (C:\Documents and Settings\syanala.gradle\caches\artifacts-26\artifact-at-url.bin) 17:38:37.213 [DEBUG] [org.gradle.api.internal.externalresource.transport.http.HttpResourceAccessor] Constructing external resource: http://repo1.maven.org/maven2/castor/castor-1.3.2-commons//castor-1.3.2-commons-.pom 17:38:37.213 [DEBUG] [org.gradle.api.internal.externalresource.transport.http.HttpClientHelper] Performing HTTP GET: http://repo1.maven.org/maven2/castor/castor-1.3.2-commons//castor-1.3.2-commons-.pom 17:38:37.354 [DEBUG] [org.apache.http.impl.conn.PoolingClientConnectionManager] Connection request: [route: {}->http://repo1.maven.org][total kept alive: 0; route allocated: 0 of 5; total allocated: 0 of 10] 17:38:37.354 [DEBUG] [org.apache.http.impl.conn.PoolingClientConnectionManager] Connection leased: [id: 0][route: {}->http://repo1.maven.org][total kept alive: 0; route allocated: 1 of 5; total allocated: 1 of 10] 17:38:37.401 [DEBUG] [org.apache.http.impl.conn.DefaultClientConnectionOperator] Connecting to repo1.maven.org:80 17:38:58.338 [DEBUG] [org.apache.http.impl.conn.DefaultClientConnectionOperator] Connect to repo1.maven.org:80 timed out. Connection will be retried using another IP address


(spencer_allain) #5

Yes, you can remove repositories.

A reference example of how to examine and adjust repositories across projects can be found in Chapter 60.5 of the latest user guide: http://www.gradle.org/docs/current/userguide/userguide_single.html#usePluginsInInitScripts

You do not have to do it as an init script plugin of course.

-Spencer