On 05/09/2013, at 7:54 AM, Alex Ruiz <[email protected]> wrote:
> Greetings,
>
> We are making changes in the Android Gradle plug-in to allow project import
> continue even if dependencies are not being resolved. From a stack trace we
> found that the method:
>
> org.gradle.api.artifacts.Configuration.getResolvedConfiguation()
>
> throws an exception if a dependency cannot be resolved. So, I try to put that
> line of code in a try/catch block, in its own method, like this (this is
> inside a Groovy class, BTW):
>
> static Set<ResolvedArtifact> getResolvedArtifacts(Configuration
> configuration) {
> try {
> return
> configuration.getResolvedConfiguration().getResolvedArtifacts();
> } catch (Throwable t) {
> return new HashSet<ResolvedArtifact>();
> }
> }
This doesn't answer your question, but instead of catching the exception you
might instead use `LenientConfiguration`. This allows you to query the
artefacts that could be resolved, even when some could not. For example:
return configuration.resolvedConfiguration.lenientConfiguration.getArtifacts({
true } as Spec)
This is generally a better idea that catching the failure.
I have no idea why the exception is not being caught. Do you have a stack trace?
--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com
Join us at the Gradle eXchange 2013, Oct 28th in London, UK:
http://skillsmatter.com/event/java-jee/gradle-exchange-2013