Resolving gradle errors - documentation


(kkidwell) #1

I’m very new to gradle and am having difficulty google’ing much information on gradle (aside from their own documentation). As such I’m receiving errors that I’m not finding information how to correct. To exemplify, I receive an error “package org.apache.commons.httpclient does not exist”. Actually it does exist but evidently not where gradle expects to find it. Can anyone lend a suggestion to where I would find info on this type of errors (and others)?


(René Groeschke) #2

Hi Kidd, In what context do you get this error message above? While executing a specific task or while starting up gradle? where do you the package org.apache.commons.httpclient? in your build script itself or in the project you try to build? maybe you can post (at least some snippets) of your gradle file?

regards, René


(kkidwell) #3

I’m including the basics of a gradle.build file I have inherited.

apply plugin: ‘java’ apply plugin: ‘maven’

apply plugin: ‘code-quality’ // http://www.gradle.org/code_quality_plugin.html apply plugin: ‘eclipse’ // http://www.gradle.org/eclipse_plugin.html http://stackoverflow.com/questions/4747328/using-gradle-to-generate-eclipse-projects-for-ejb-module http://www.revenuepwrapi.com

repositories {

mavenCentral()

flatDir name: ‘local’, dirs: ‘repo’ }

configurations {

compile }

dependencies {

compile “org.eclipse.persistence:javax.persistence:2.0.3”

compile ‘javax:javaee-api:6.0’

compile ‘org.glassfish.ejb:ejb-all:3.1.1’

compile ‘commons-beanutils:commons-beanutils:1.8.+’

compile ‘org.apache.httpcomponents:httpclient:4.1.2’

compile ‘org.apache.axis:axis:1.4’

compile ‘org.apache.activemq:activemq-core:5.4.0’

compile ‘joda-time:joda-time:1.6.2’

testCompile ‘junit:junit:4.8.+’ }

/* //glassfish = ‘/usr/local/glassfish3’ glassfish = ‘C:/glassfish3’ buildpath = [ “${glassfish}/glassfish/modules/”, “${glassfish}/glassfish/modules/endorsed” ]

mainSrc = sourceSets.main buildpath.collect {

println “including ${it} on build path.”

collection = files { file("${glassfish}/glassfish/modules/").listFiles() }

mainSrc.compileClasspath = mainSrc.compileClasspath + collection } */

From the command line I run “gradle build”

An example of my error is:

C:<path>\src\main\java\com\profitstreams\sparkbase\HttpPostW orkaround.java:6: package org.apache.commons.httpclient does not exist import org.apache.commons.httpclient.Header;

It’s actually the .java file that is looking for this lib.

Does this help - and btw, thanks for your quick response.

kgkidd


(René Groeschke) #4

Hi, In your case, the compileJava tasks will fail with an exception. normally gradle tells you something like “Cause: Compile failed; see the compiler error output for details.”

As you noticed your sources can’t be compiled because the package org.apache.commons.httpclient is not part of your compile classpath. You added ‘org.apache.httpcomponents:httpclient:4.1.2’ to your compile dependencies. This jar does not include the package you need. Maybe you’re sources are based on a predecessor version of apache httpclient. They did some repackaging/renaming/etc when updating apache httpclient from 3.1 to 4.x. The artifact “commons-httpclient:commons-httpclient:3.1” includes the package you’re looking for.

regards, René