Maven:如何从单个工件中获取所有JAR?

时间:2017-11-22 05:00:24

标签: java maven jar

我想要包含工件中的所有以下依赖项,但它仅下载itext-xtra-5.1.1.jar

工件ID

  • iText的-XTRA-5.1.1-javadoc.jar
  • iText的-XTRA-5.1.1-sources.jar
  • iText的-XTRA-5.1.1.jar
<!-- https://mvnrepository.com/artifact/com.itextpdf/itext-xtra -->
<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itext-xtra</artifactId>
    <version>5.1.2</version>
</dependency>

请告诉我如何下载所有JAR?

2 个答案:

答案 0 :(得分:0)

打开# make a var for files in current folder arr=(./*) CSVRETURN="" # simple loop to iterate files for ((i=0; i<${#arr[@]}; i++)); do #do something to each element of array CSVRETURN="$CSVRETURN","${arr[$i]}" done echo $CSVRETURN 。如果不存在则创建

<user_profile>/.m2/settings.xml

从命令行

执行此操作
<settings>

    <profiles>
        <profile>
            <id>downloadJavadoc_source_profile</id>
            <properties>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </properties>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>downloadJavadoc_source_profile</activeProfile>
    </activeProfiles>
</settings>

答案 1 :(得分:0)

使用<classifier>添加相关的sourcejavadoc依赖项,即:

<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itext-xtra</artifactId>
    <version>5.1.1</version>
</dependency>
<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itext-xtra</artifactId>
    <version>5.1.1</version>
    <classifier>javadoc</classifier>
</dependency>
<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itext-xtra</artifactId>
    <version>5.1.1</version>
    <classifier>sources</classifier>
</dependency>

将所有3个jar 作为依赖项下载

  • iText的-XTRA-5.1.1-javadoc.jar
  • iText的-XTRA-5.1.1-sources.jar
  • iText的-XTRA-5.1.1.jar

我还建议使用属性设置版本以避免重复,例如:

 <version>${itext-xtra.version}</version>