Gradle + bintray: Specifying Dependencies dependencies correctly

Gradle + bintray: Specifying Dependencies of dependencies correctly

我有以下场景:

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

我设置了一个 maven 存储库,上传了工件和 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', because that is used to download a single artifact. From the 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'
}