首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >链接的源文件夹

链接的源文件夹
EN

Stack Overflow用户
提问于 2014-05-08 01:28:00
回答 1查看 1.8K关注 0票数 1

我使用的是Gradle eclipse插件,我正在尝试连接两个项目。其中一个项目是一个库,并且从来没有导出,因为我只是链接到实际项目中的库源。另一个项目应该有一个指向库源的虚拟链接,并将链接目录作为源目录添加到类路径中。我怎样才能用build.gradle做到这一点?具有添加所需项目(项目属性-> java Build Path ->项目)或虚拟源文件夹(项目属性-> Java Build Path -> Source -> Link Source...)的功能,但似乎不能将这些功能用于Gradle Java、Gradle eclipse或Gradle eclipse-wtp插件。

EN

回答 1

Stack Overflow用户

发布于 2015-07-10 02:48:59

我知道这是一个老帖子,但更详细地回答它可能会对将来像我一样的人有帮助,否则他们会花很多钱(浪费?)花时间用谷歌搜索得出答案。

我猜Peter在他的最后一条评论中暗示的是:

如果已声明了linkedResource,则可以使用classpath声明将其添加到.classpath文件中,如下所示:

代码语言:javascript
复制
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])
            }
        }
    }
}

在我的例子中,我链接到网络上另一台机器上的文件,所以要链接的文件夹路径类似于"/Volumes/pf/Documents/workspace/...“。

build.gradle中完成上述操作后,如果您正在使用STS/Eclipse中的Gradle工具,请打开Gradle task视图,选择项目,刷新任务列表,最后运行"eclipseClasspath“。

作者:我从这篇文章(Eclipse plugin: add new element to a classpathentry)中拼凑了上面的内容。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23524350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档