简体   繁体   English

Gradle-以jar形式共享项目依赖项

[英]Gradle - Shared project dependencies as jar

I have a project, that is a service (SOA). 我有一个项目,那就是服务(SOA)。 This project has some classes, like DTOs and Wrappers that I would like to share with the Client-Project (UI). 这个项目有一些类,例如DTO和Wrappers,我想与Client-Project(UI)分享。

So I want to build a JAR to share with the project. 因此,我想构建一个与项目共享的JAR。 I'ved tried this: 我试过这个:

// authorization-api.jar
task apiJar(type: Jar) {  
    from(sourceSets.main.output) {  
        include "com/company/sig/authorization/dto**"
    }  
}

Two problems: first I want to rename the jar (must be simple, need to search). 两个问题:首先,我想重命名jar(必须很简单,需要搜索)。 Second, the JAR was generated empty (with the folders (com/company/sig...) but with no classes :( Guessing the "sourceSets.main.output". 其次,JAR生成为空(带有文件夹(com / company / sig ...),但没有类:(猜测“ sourceSets.main.output”。

The following code should help You: 以下代码应为您提供帮助:

task apiJar(type: Jar) {  
    from(sourceSets.main.output) {  
        include "com/company/sig/authorization/dto/**"
    }  
    archiveName = 'api.jar'
}

As You can see, You're quite close :) 如您所见,您非常接近:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM