gpt4 book ai didi

java - Gradle + bintray : Specifying Dependencies of dependencies correctly

转载 作者:行者123 更新时间:2023-12-01 11:27:45 26 4
gpt4 key购买 nike

我有以下情况:

我想在我的另一个项目中使用我的一个项目(托管在 bintray.com 上)。

我设置了一个 Maven 存储库,上传了 Artifact 和 pom 文件,然后能够使用上传到 bintray maven 存储库的 jar 文件,并使用以下 build.gradle 文件:

apply plugin: 'java'
apply plugin: 'application'

mainClassName = 'randers.test.usageTest.UsageTest'

repositories {
maven { url 'http://dl.bintray.com/randers00/NotEnoughVocab' }
jcenter()
}

dependencies {
compile(group: 'randers.notenoughvocab.core', name: 'notenoughvocab-core', version: '0.0.1', ext: 'jar')
}

jar {
manifest {
attributes "Main-Class": mainClassName
}
}

这个构建文件成功地为项目配备了我的核心库,甚至使源代码等在 IDE 中可用(我使用 IntelliJ IDEA)

问题是:核心本身使用了库,而这些库不是通过gradle获取的。

这是 bintray 上的 pom 文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>randers.notenoughvocab.core</groupId>
<artifactId>notenoughvocab-core</artifactId>
<version>0.0.1</version>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>2.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.10</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<licenses>
<license>
<name>GNU General Public License, Version 3.0</name>
<url>http://www.gnu.org/licenses/gpl.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<contributors>
<contributor>
<name>Ruben Anders</name>
<email>RAnders00@users.noreply.github.com</email>
<url>https://github.com/RAnders00</url>
</contributor>
</contributors>
</project>

我查看了 bintray 上的其他项目,它们的 pom 文件看起来很相似。

最佳答案

以传统且简单的方式声明依赖关系效果很好:

compile 'randers.notenoughvocab.core:notenoughvocab-core:0.0.1'

当您指定 ext: 'jar' 时,它不起作用,因为它用于下载单个 Artifact 。来自 user guide :

Artifact only notation

As said above, if no module descriptor file can be found, Gradle by default downloads a jar with the name of the module. But sometimes, even if the repository contains module descriptors, you want to download only the artifact jar, without the dependencies. [14] And sometimes you want to download a zip from a repository, that does not have module descriptors. Gradle provides an artifact only notation for those use cases - simply prefix the extension that you want to be downloaded with '@' sign:

Example 50.5. Artifact only notation

build.gradle

dependencies {
runtime "org.groovy:groovy:2.2.0@jar"
runtime group: 'org.groovy', name: 'groovy', version: '2.2.0', ext: 'jar'
}

关于java - Gradle + bintray : Specifying Dependencies of dependencies correctly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30682558/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com