howto change transitive dependency into project dependency

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

howto change transitive dependency into project dependency

owahlen
I am working in an environment with several dependent gradle projects each of which result in artifacts in a Maven repo. If developers want to test code changes in a sub-project they have to create snapshot releases, deploy them locally and then compile the parent project.

This is very tedious and also does not allow to do cross-project code refactorings in the IDE.

My idea is to make the top-level project configurable: Dependencies can either be resolved from artifactory or be gradle sub-projects (i.e. a gradle multi-project environment). I already managed to make the relevant changes to settings.gradle and also configure the direct dependencies.

Unfortunately I am currently unable to transform the transitive Maven dependencies into project dependencies.

In other words I am trying to do something like this:

allprojects { Project subproject ->
    subproject.configurations.all { Configuration configuration ->
        configuration.resolutionStrategy { ResolutionStrategy strategy ->
            strategy.eachDependency { DependencyResolveDetails details ->
                if (details.requested.name == 'myartifact') {
                    details.useTarget project(':myproject')
                }
            }
        }
    }
}


Unfortunately the useTarget method does not accept a project dependency. So this does not work.
Any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: howto change transitive dependency into project dependency

Jason Hatton
Hey owahlen,

This list is almost dead.  The official list is now at http://forums.gradle.org/gradle.  

About your question I wasn't clear on how the setup your describing is different from standard dependency configuration.  I get the sense what your are trying to do is cherry pick whether a dependency is available through a respository or a developer can pull that code base from down version control and make it a subproject in Gradle and the get all the Gradle goodness for testing.  Is that right? 

Jas


On Tue, Oct 8, 2013 at 7:40 AM, owahlen <[hidden email]> wrote:
I am working in an environment with several dependent gradle projects each of
which result in artifacts in a Maven repo. If developers want to test code
changes in a sub-project they have to create snapshot releases, deploy them
locally and then compile the parent project.

This is very tedious and also does not allow to do cross-project code
refactorings in the IDE.

My idea is to make the top-level project configurable: Dependencies can
either be resolved from artifactory or be gradle sub-projects (i.e. a gradle
multi-project environment). I already managed to make the relevant changes
to settings.gradle and also configure the direct dependencies.

Unfortunately I am currently unable to transform the transitive Maven
dependencies into project dependencies.

In other words I am trying to do something like this:

/allprojects { Project subproject ->
    subproject.configurations.all { Configuration configuration ->
        configuration.resolutionStrategy { ResolutionStrategy strategy ->
            strategy.eachDependency { DependencyResolveDetails details ->
                if (details.requested.name == 'myartifact') {
                    *details.useTarget project(':myproject')*
                }
            }
        }
    }
}/

Unfortunately the /useTarget/ method does not accept a project dependency.
So this does not work.
Any ideas?



--
View this message in context: http://gradle.1045684.n5.nabble.com/howto-change-transitive-dependency-into-project-dependency-tp5711930.html
Sent from the gradle-user mailing list archive at Nabble.com.

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

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: howto change transitive dependency into project dependency

owahlen
Hello Jas,
Based on your suggestion I have moved the thread here:
http://forums.gradle.org/gradle/topics/howto_change_transitive_dependency_into_project_dependency?rfm=1

The point is that "sub-project" and its transitive dependency "sub-sub-project" are both located in a Maven repo.
Now a developer has "project" (which has a dependency on "sub-project") and "sub-sub-project" checked out on his local disc.

When he builds "project" gradle shall not resolve "sub-sub-project" from the maven repo but instead resolve it to the "sub-sub-project" on the local disk (i.e. a project dependency).

If you now run "gradle eclipse" you will have a multi-project structure that allows you to efficiently refactor in both "project" and "sub-sub-project".
Reply | Threaded
Open this post in threaded view
|

Re: howto change transitive dependency into project dependency

Jason Hatton
I tried to answer on the other forum.  Hopefully more people can answer.  It is an interesting idea.  I have wanted to do something like this too.


On Wed, Oct 9, 2013 at 2:39 AM, owahlen <[hidden email]> wrote:
Hello Jas,
Based on your suggestion I have moved the thread here:
http://forums.gradle.org/gradle/topics/howto_change_transitive_dependency_into_project_dependency?rfm=1

The point is that "sub-project" and its transitive dependency
"sub-sub-project" are both located in a Maven repo.
Now a developer has "project" (which has a dependency on "sub-project") and
"sub-sub-project" checked out on his local disc.

When he builds "project" gradle shall not resolve "sub-sub-project" from the
maven repo but instead resolve it to the "sub-sub-project" on the local disk
(i.e. a project dependency).

If you now run "gradle eclipse" you will have a multi-project structure that
allows you to efficiently refactor in both "project" and "sub-sub-project".




--
View this message in context: http://gradle.1045684.n5.nabble.com/howto-change-transitive-dependency-into-project-dependency-tp5711930p5711937.html
Sent from the gradle-user mailing list archive at Nabble.com.

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

    http://xircles.codehaus.org/manage_email