简体   繁体   English

在Java多模块项目中添加包含jar的文件夹

[英]Adding folder containing jars in java multimodule project

I am a newbie in Gradle and I have the following java project structure: 我是Gradle的新手,并且具有以下Java项目结构:

rootProject
|--- projectA
|-------src/main/java
|-------build.gradle
|--- Lib
|-------lib/*.jar
|--- build.gradle
|--- settings.gradle

I am trying to build projectA. 我正在尝试构建projectA。 Project A dependencies are in Lib/lib folder as jars. 项目A依赖项在jar / lib文件夹中为jar。 I know that it is better to download these jars from maven central but now I have to maintain this structure. 我知道最好从Maven Central下载这些jar,但是现在我必须保持这种结构。 So I am not aware how to add all the jars that are in Lib folder in projectA/build.gradle . 所以我不知道如何添加projectA / build.gradle的Lib文件夹中的所有jar。 Can anyone help? 有人可以帮忙吗?

My build.gradle file in projectA is the following 我在projectA中的build.gradle文件如下

apply plugin : "java"
task listJars<< {
    configurations.compile.each { File file -> println file.name }
}
dependencies{
    compile fileTree(dir:'Lib/lib',include:'*.jar')
} 

You can add them as dependencies in a file object as such 您可以将它们作为依赖项添加到文件对象中,例如

dependencies {
   runtime files('libs/a.jar', 'libs/b.jar')
   runtime fileTree(dir: 'libs', include: '*.jar') 
}

This was pulled form documentation here 这是这里的表格文档

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

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