Switch between jar and project dependency for eclipse?

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

Switch between jar and project dependency for eclipse?

Dave King
We have a number of common jars that are used across products.  We
currently build and post those projects to our nexus repo and the
other builds see them as external dependencies.  These projects are in
separate Git repositories.

This has become an issue for the developers of those projects who are
used to having one eclipse project where they can debug and edit.

Any ideas on how we could provide a property or properties that would
tell the eclipse task to generate project dependencies instead of jar
dependencies?

- Peace
Dave

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Switch between jar and project dependency for eclipse?

Peter Niederwieser
Dave King wrote
Any ideas on how we could provide a property or properties that would
tell the eclipse task to generate project dependencies instead of jar
dependencies?
You could try to achieve this by manipulating EclipseProject.referencedProjects and EclipseClasspath.minusConfigurations. For WTP projects you'd also have to reconfigure the EclipseWtp task (which, by the way, has been split into two for the upcoming 1.0-milestone-1). Other options:

1. Use "git submodule" to create an aggregate Git project and aggregate Gradle build. This is what the Qi4j project does (see https://github.com/Qi4j/qi4j-sdk).
2. Post-process the Eclipse files generated by Gradle according to your needs. The user guide explains how to do this.

--
Peter Niederwieser 
Developer, Gradle
http://www.gradle.org
Trainer & Consultant, Gradle Inc.
http://www.gradle.biz
Creator, Spock Framework
http://spockframework.org
Reply | Threaded
Open this post in threaded view
|

Re: Switch between jar and project dependency for eclipse?

Dave King
Thanks Peter.  The hooks from the guide turned out to be the ticket.
Haven't done the full thing yet but seems very promising.

- Peace
Dave


On Tue, Feb 22, 2011 at 11:31 AM, Peter Niederwieser <[hidden email]> wrote:

>
>
> Dave King wrote:
>>
>> Any ideas on how we could provide a property or properties that would
>> tell the eclipse task to generate project dependencies instead of jar
>> dependencies?
>>
>
> You could try to achieve this by manipulating
> EclipseProject.referencedProjects and EclipseClasspath.minusConfigurations.
> For WTP projects you'd also have to reconfigure the EclipseWtp task (which,
> by the way, has been split into two for the upcoming 1.0-milestone-1). Other
> options:
>
> 1. Use "git submodule" to create an aggregate Git project and aggregate
> Gradle build. This is what the Qi4j project does (see
> https://github.com/Qi4j/qi4j-sdk).
> 2. Post-process the Eclipse files generated by Gradle according to your
> needs. The user guide explains how to do this.
>
> --
> Peter Niederwieser
> Developer, Gradle
> http://www.gradle.org
> Trainer & Consultant, Gradle Inc.
> http://www.gradle.biz
> Creator, Spock Framework
> http://spockframework.org
>
> --
> View this message in context: http://gradle.1045684.n5.nabble.com/Switch-between-jar-and-project-dependency-for-eclipse-tp3395869p3395954.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
>
>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Switch between jar and project dependency for eclipse?

fbrubbo
Hi David,

Was you able to create a task (or anything else) which is capable to specify dependencies between eclipse projects instead of going to the repository?

What I've done up until now is this.

configurations.all {
    resolutionStrategy.eachDependency { details ->
        def groupName = details.requested.group
        def libName = details.requested.name;
        // here we check if the requested dependency is developed by ourselves
        if ( groupName== 'br.com.<OUR_COMPANY>') {
            // If so, we check in the current workspace if there is an project with the appropriated name
            project.file("../").list().each {projectName ->
                if( projectName.equalsIgnoreCase(libName) ){
                    // If so, we change the dependency from jar to local eclipse project
                    project.eclipse.classpath.file {
                        withXml { xml ->
                            def node = xml.asNode()
                           
                                println "The project " + projectName + " was found into the current workspace. Using it instead of the equivalent lib"
                                node.appendNode( 'classpathentry', [ kind: 'src', path: "/${projectName}", exported: 'true', combineaccessrules:'false'])
                               
                                def libNode =  node.find {it.@path.contains(libName)}
                                if(libNode != null) {
                                    node.remove(libNode)
                                }                                                                
                            }
                     }
                    // Then we do not resolve the jar dependency
                    details.useTarget ''
                }
            }
        }
    }
}

This seems to work for 'java' projects with eclipse classpath container 'org.springsource.ide.eclipse.gradle.dsld.classpathcontainer' disabled (On the other hand, this container adds back the jar dependecy). But for war projects, we could not avoid resolving jar dependencies because whenever we would like to build the war it must be inside WEB-INF/lib dir.

Moreover, it seems we have to update the file 'org.eclipse.wst.common.component' in a similar way we did with .classpath, but we didn't found how to do it with current api.


any example/idea will be appreciated
Thanks
Fernando Rubbo