Embedding gradle - retrieving project info

(mmatloka) #1

I’m starting work on ShrinkWrap Resolver Gradle integration (http://forums.gradle.org/gradle/topics/dependency_resolution_with_gradle_for_arquillian_tests https://issues.jboss.org/browse/SHRINKRES-116).

However I have a few questions - manual in chapter embedding gradle mainly focues on building process. 1. I think I have to use gradle core package available on maven repo in order to fully embedded gradle? 2. How to get Project interface instance basing on build.gradle file, so that then I can get info about projects dependencies etc?


The supported mechanism for embedding Gradle is the Tooling API, which is briefly described in the User Guide. The Tooling API is quite sophisticated in that it is both forward and backward compatible with different Gradle versions: so you can embed the Tooling API v1.4, and you’ll still be able to access information about a build that uses features introduced in Gradle v1.6.

Because of this, the model presented by the Tooling API is an abstraction over the core Gradle Project model. So far, this abstraction has been targeted as IDE integrators, but it should also be useful for other embedding use cases.

So the answer to “how can I get a Project interface instance” using the Tooling API is that you can’t. But getting information about the project dependencies is possible using either the IDEA or Eclipse project model. In the future we’d like to add this capability to the generic “GradleModel”, but that hasn’t happened yet. Check out the Tooling API samples for how this can be done.

I don’t really understand what you’re trying to achieve, so I’m not sure that the Tooling API will have the capabilities you’re looking for. But take a look and let us know if there’s something missing.

(René Groeschke) #3

Hello Michał, Are there any news about the ShrinkWrap gradle resolver? I saw a rough implementation at github, but not merged into the ShrinkWrap master. furthermore I was not able to build the project to test it on my own. I’m happy to support you if you need help. I would really love to see a ShrinkWrap gradle resolver. That’s a big step in smooth arquillian integration. ATM I need to manually create a pom out of the gradle dependencies and use the mavenresolver instead or add the libs completely manually

cheers, René

(mmatloka) #4

Hi René,

I haven’t touched this implementation since pushing that prototype to SWR branch. Before integration in master we need some additional testing on real Gradle projects (I currently dont use gradle at work). I lack a gradle knowledge in some areas, e.g. how to correctly determine the jar/war output file name in order to retrieve this build result.

What were your problems with building the project?


(mmatloka) #5

ping :slight_smile:

(mmatloka) #6

Help needed :slight_smile: http://forums.gradle.org/gradle/topics/gradle_tooling_api_build_during_arquillian_deployment_creation_classnotfoundexception_saxparserfactory

(Vikas Bali) #7

I saw the subtask is marked as resolved… Do we have sample code which explain how this would work now ?

(mmatloka) #8

Hi, The version was not yet release to the nexus, but here is the example usage https://github.com/mmatloka/arquillian-gradle-sample (still using locally built snapshot, I will upgrade it when SWR will be released), and here the main implementation classs: https://github.com/shrinkwrap/resolver/blob/master/impl-gradle-embedded-archive/src/main/java/org/jboss/shrinkwrap/impl/gradle/archive/importer/embedded/EmbeddedGradleImporterImpl.java

(mmatloka) #9

I have pushed updated sample https://github.com/mmatloka/arquillian-gradle-sample/ to use the SWR 2.2.0-alpha-1