0

我有以下内容build.gradle

group 'org.inthemoon.spring'
version '1.1-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: "maven-publish"

sourceCompatibility = 1.8

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {

    compile group: 'org.inthemoon.spring', name: 'childcontext', version: '1.0-SNAPSHOT'

    // https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'

    compile 'org.springframework:spring-context:4.3.4.RELEASE'

    testCompile group: 'junit', name: 'junit', version: '4.12'
}


tasks.create('sourceJar', Jar) {
    dependsOn tasks.classes
    from sourceSets.main.allSource
    classifier 'sources'
    extension 'jar'
    group 'build'
}


publishing {
    publications {
        nebula(MavenPublication) {
            artifact tasks.sourceJar
        }
    }
}

不幸的是,当我运行目标时publishToMavenLocal,我得到以下 pom 文件...\.m2\repository\org\inthemoon\spring\springfx\1.1-SNAPSHOT\springfx-1.1-SNAPSHOT.pom

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.inthemoon.spring</groupId>
  <artifactId>springfx</artifactId>
  <version>1.1-SNAPSHOT</version>
  <packaging>pom</packaging>
</project>

即没有依赖关系。

怎么修?

4

1 回答 1

0

pom.xml您拥有内容的事实:<packaging>pom</packaging>表明没有 jar 链接到该出版物。

这是通过添加:

publishing {
  publications {
    nebula(MavenPublication) { // Note that 'nebula' here is the name of your publication
      from components.java
      // Other configuration instructions
    }
  }
}

注意插件mavenmaven-publish提供类似的功能。maven现在被认为已弃用,取而代之的是maven-publish. 因此,在您的构建脚本中,您可以删除maven插件的应用程序。

于 2018-09-10T08:39:09.997 回答