[英]Maven dependencies not published with Gradle
I have the following build.gradle
: 我有以下
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
}
}
}
Unfortunately, when I run goal publishToMavenLocal
, I get the following pom file ...\\.m2\\repository\\org\\inthemoon\\spring\\springfx\\1.1-SNAPSHOT\\springfx-1.1-SNAPSHOT.pom
: 不幸的是,当我运行目标
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>
ie no dependencies. 即没有依赖性。
How to fix? 怎么修?
The fact that your pom.xml
has the content: <packaging>pom</packaging>
indicates that no jar have been linked to the publication. 您的
pom.xml
包含以下内容: <packaging>pom</packaging>
表示没有jar链接到发布。
This is done by adding: 这可以通过添加以下内容来完成:
publishing {
publications {
nebula(MavenPublication) { // Note that 'nebula' here is the name of your publication
from components.java
// Other configuration instructions
}
}
}
Note that the plugins maven
and maven-publish
provide similar capabilities. 请注意,插件
maven
和maven-publish
提供了类似的功能。 maven
is now considered deprecated in favour of maven-publish
. 现在认为
maven
已过时,建议使用maven-publish
。 And so in your build script you can remove the application of the maven
plugin. 因此,在您的构建脚本中,您可以删除
maven
插件的应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.