Linked source folders

I'm using the Gradle eclipse plugin and I'm trying to connect two project. One of these project is a library and gets never exported since I just link to the library source in real projects. The other project should have a virtual link to the library source and add the linked directory as source directory to classpath. How can I do this with build.gradle? The has a feature for adding required projects (Project Properties -> Java Build Path -> Projects) or virtual source folders (Project Properties -> Java Build Path -> Source -> Link Source...), but it doesn't seem possible to use these features with Gradle java, Gradle eclipse or Gradle eclipse-wtp plugins.

Answers


I know this is an old thread, but having it answered in greater detail may help someone in the future who like me would otherwise spend a good bit of (wasted?) time googling to arrive at the answer.

What I'm guessing Peter was alluding to in his last comment was this:

If you have declared the linkedResource, you can then add it to the .classpath file using the classpath declaration as shown in the following:

eclipse {
    project {
        linkedResource name: 'java', type: '2', location: '[path-to-folder-to-be-linked]/src/main/java'
        linkedResource name: 'java-resources', type: '2', location: '[path-to-folder-to-be-linked]/src/main/resources'
        linkedResource name: 'test', type: '2', location: '[path-to-folder-to-be-linked]/src/test/java'
        linkedResource name: 'test-resources', type: '2', location: '[path-to-folder-to-be-linked]/src/test/resources'
    }
    classpath {
        file {
            withXml {
                def node = it.asNode()
                node.appendNode('classpathentry', [kind: 'src', path: 'java', exported: true])
                node.appendNode('classpathentry', [kind: 'src', path: 'java-resources', exported: true])
                node.appendNode('classpathentry', [kind: 'src', path: 'test', exported: true])
                node.appendNode('classpathentry', [kind: 'src', path: 'test-resources', exported: true])
            }
        }
    }
}

In my case, I am linking to files on another machine on my network, so the [path-to-folder-to-be-linked] is something like "/Volumes/pf/Documents/workspace/...".

Once you have the above in build.gradle and if you are using the Gradle tooling in STS/Eclipse, open the Gradle Tasks view, select the project, refresh task list, and finally run "eclipseClasspath".

Attribution: I cobbled the above together from this post (Eclipse plugin: add new element to a classpathentry).


Need Your Help

how to get Region using Specified string in GoogleMaps in Iphone?

iphone string search mkmapview

In my iphone application i am using MKMapView to display any region(i.e Australia) and it is working fine using coordinates(latitude and longitude).But i want to display the region based on the str...

Apache (xampp) doesn't run on Win 10 - W3SVC not running

windows apache xampp

I've read the other questions about Apache not running on Windows 10, but I've checked my list of running services, and there isn't any W3SVC, World Wide Web Publishing Services, or Skype running