let me clean it up. You should be able to copy paste this directly to your system and try it. For some reason, the class isn't found. I tried this with the Base64 example Roger posted and was able to get a Base64 class lookup (Class.forName) to work properly. So it seems there is something odd about the Xerces class....
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath( group:"xerces", name:'xercesImpl', version:'2.9.1')
}
}
task hello {
doLast {
println 'Hello world!'
Class testClass =
Class.forName("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl")
assert testClass: "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
not found"
println "found"
}
}
On Fri, May 13, 2011 at 9:01 PM, phil swenson <[email protected]>wrote:
> I had tried what you suggested too... always get a classnotfound error when
> I execute the task.
>
> apply plugin: 'groovy'
>
>
> buildscript {
> dependencies {
> classpath( 'org.apache.xerces:xercesImpl:2.9.1')
>
> }
> }
>
> dependencies {
> groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.7.10'
> runtime: 'org.apache.xerces:xercesImpl:2.9.1'
> compile: 'org.apache.xerces:xercesImpl:2.9.1'
>
> }
>
> task hello {
> doLast {
> println 'Hello world!'
> Class testClass =
> Class.forName("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl")
> assert testClass:
> "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found"
> }
> }
>
>
>
>
>
>
>
> On Fri, May 13, 2011 at 4:35 PM, Roger Studner <[email protected]> wrote:
>
>> From the docs:
>>
>> http://www.gradle.org/current/docs/userguide/organizing_build_logic.html#sec:external_dependencies
>> Example 41.5
>>
>> import org.apache.commons.codec.binary.Base64
>>
>> buildscript {
>> repositories {
>> mavenCentral()
>> }
>> dependencies {
>> classpath group: 'commons-codec', name: 'commons-codec', version:
>> '1.2'
>> }
>> }
>>
>> task encode << {
>> def byte[] encodedString = new Base64().encode('hello
>> world\n'.getBytes())
>> println new String(encodedString)
>> }
>>
>> Your are saying that the "source code you want to compile" needs
>> xercesimpl.
>>
>> But the above, is how you configure your BUILD SCRIPT to have the
>> capability to use xerces.
>>
>> make sense?
>>
>> Best,
>> Roger
>>
>>
>> ------------------------------
>>
>> phil swenson <[email protected]>
>> May 13, 2011 6:25 PM
>>
>> Here is my build.gradle
>>
>> apply plugin: 'groovy'
>>
>> dependencies {
>> groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.7.10'
>> runtime: 'org.apache.xerces:xercesImpl:2.9.1'
>>
>> }
>>
>> task hello {
>> doLast {
>> println 'Hello world!'
>> Class testClass =
>> Class.forName("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl")
>> assert testClass:
>> "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found"
>> println
>> }
>> }
>>
>> when I run "gradle hello" I get:
>>
>> :hello
>> Hello world!
>>
>> FAILURE: Build failed with an exception.
>>
>> * Where:
>> Build file '/Users/phil/dev/sag/scratchproj/build.gradle' line: 13
>>
>> * What went wrong:
>> Execution failed for task ':hello'.
>> Cause: java.lang.ClassNotFoundException:
>> org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
>>
>> NO idea why......
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>> http://xircles.codehaus.org/manage_email
>>
>>
>>
>
<<compose-unknown-contact.jpg>>
