Hi

I wrote a quick task to test getting the version, group and name from
a dependency, but am getting a failure using this within the
samples/userguide/multiproject/dependencies/java example.
Interestingly it prints out the only dependency artifact (shared 1.0
org.gradle.sample) for the project dependency, but is then failing as
if there is a second item that is null in the default configuration.

Bug? Or am I doing something wrong?

    task play << { task ->
        task.project.configurations.default.files { artifact -> print
"$artifact.name ${artifact.version} ${artifact.group}" }
    }

crotwell$ gradle -s play
:api:play
shared 1.0 org.gradle.sample

FAILURE: Build failed with an exception.

* Where:
Empty build file

* What went wrong:
Execution failed for task ':api:play'.
Cause: Could not resolve all dependencies for configuration 'default'.
Cause: java.lang.NullPointerException (no error message)

* Try:
Run with -S option to get the full (very verbose) stacktrace.

* Exception is:
org.gradle.api.GradleScriptException: Empty build file
Execution failed for task ':api:play'.
        at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:233)
        at 
org.gradle.execution.DefaultTaskExecuter.executeTask(DefaultTaskExecuter.java:165)
        at 
org.gradle.execution.DefaultTaskExecuter.doExecute(DefaultTaskExecuter.java:156)
        at 
org.gradle.execution.DefaultTaskExecuter.execute(DefaultTaskExecuter.java:74)
        at 
org.gradle.execution.TaskNameResolvingBuildExecuter.execute(TaskNameResolvingBuildExecuter.java:174)
        at 
org.gradle.execution.DelegatingBuildExecuter.execute(DelegatingBuildExecuter.java:54)
        at org.gradle.GradleLauncher.doBuildStages(GradleLauncher.java:164)
        at org.gradle.GradleLauncher.doBuild(GradleLauncher.java:123)
        at org.gradle.GradleLauncher.run(GradleLauncher.java:94)
        at org.gradle.Main.execute(Main.java:100)
        at org.gradle.Main.main(Main.java:43)
        at org.gradle.BootstrapMain.main(BootstrapMain.java:53)
Caused by: org.gradle.api.artifacts.ResolveException: Could not
resolve all dependencies for configuration 'default'.
        at 
org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingIvyService.wrapException(ErrorHandlingIvyService.java:63)
        at 
org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingIvyService.access$000(ErrorHandlingIvyService.java:28)
        at 
org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingIvyService$ErrorHandlingResolvedConfiguration.getFiles(ErrorHandlingIvyService.java:92)
        at 
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:494)
        at 
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.files(DefaultConfiguration.java:162)
        at 
build_gradle_80c3e8118300ea3c911ae5a2d3874073$_run_closure1_closure4.doCall(/Users/crotwell/dev/gradle/build/distributions/exploded/samples/userguide/multiproject/dependencies/java/build.gradle:6)
        at org.gradle.api.ClosureTaskAction.execute(DefaultTask.groovy:82)
        at org.gradle.api.ClosureTaskAction.execute(DefaultTask.groovy)
        at org.gradle.api.internal.AbstractTask.doExecute(AbstractTask.java:258)
        at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:223)
        ... 11 common frames omitted
Caused by: java.lang.NullPointerException
        at $Proxy17.isSatisfiedBy(Unknown Source)
        at org.gradle.api.specs.Specs.filterIterable(Specs.java:51)
        at 
org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver$1.getFiles(SelfResolvingDependencyResolver.java:48)
        at 
org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingIvyService$ErrorHandlingResolvedConfiguration.getFiles(ErrorHandlingIvyService.java:90)
        ... 18 common frames omitted

BUILD FAILED

Total time: 3.577 secs

------------------------------------------------------------
Gradle 0.8-20090916140502-0400
------------------------------------------------------------

Gradle buildtime: Wednesday, September 16, 2009 2:05:02 PM EDT
Groovy: 1.6.4
Ant: Apache Ant version 1.7.0 compiled on December 13 2006
Ivy: 2.1.0-rc2
Java: 1.5.0_20
JVM: 1.5.0_20-141
JVM Vendor: Apple Inc.
OS Name: Mac OS X


On Thu, Jul 23, 2009 at 1:43 AM, Hans Dockter <[email protected]> wrote:
>
> On Jul 22, 2009, at 4:31 PM, Philip Crotwell wrote:
>
>>>
>>> A good solution to this problem would be to have an additional method in
>>> the
>>> configuration that returns an object which returns the artifact metadata
>>> (name, version, ...) together with the artifact file. This is something
>>> we
>>> will offer in 0.8:
>>>
>>
>> Maybe instead of the Configuration being a collection of File objects,
>> you could have it be a collection of DependencyFile that extends File
>> and implements Dependency so that existing methods still work (they
>> are still Files), but you have access to the group, name and version?
>>
>
> This is a very good idea. The problem is that we also have the type of a
> self resolving dependency, which does not have the above properties. They
> simply correspond to a set of files.
>
> An alternative approach would be to have a files method with a transformer
> closure.
>
> files { artifact -> "$artifact.name-${artifact.version}.${artifact.ext} }
>
> This method would return the files for all dependencies (self resolving and
> what we call module dependencies which are associated with external
> repositories). The files for the module dependencies are generated from the
> return value of the closure (which can be a String or a File object).
>
> - Hans
>
> --
> Hans Dockter
> Gradle Project Manager
> http://www.gradle.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to