我有一个父模块Gradle项目,其中包含子项目。其中一个子项目是Web应用程序。当我发布到maven repo时,尽管本地创建了jar和war,它仍然只作为jar文件发布
父文件Gradle设置:
configurations {
integTestCompile.extendsFrom testCompile
integTestRuntime.extendsFrom testRuntime
}
allprojects {
ext {
springVersion = "4.0.4.RELEASE"
}
tasks.withType(JavaCompile) {
sourceCompatibility = "1.6"
targetCompatibility = "1.6"
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
repositories {
maven {
url "http://.../mirror/"
}
}
publishing {
publications {
maven(MavenPublication) {
groupId 'com.blah'
version '1.2'
from components.java
}
}
repositories {
maven {
credentials {
username ""
password ""
}
if(project.version.endsWith('-SNAPSHOT')) {
url "http://.../snapshots/"
} else {
url "http:/.../internal/"
}
}
}
}
dependencies {
testCompile 'junit:junit:4.8.2'
}
}
Web应用程序gradle
apply plugin: 'war'
configurations {
providedRuntime
}
war {
baseName = 'portal-web'
}
dependencies {
compile(project(":portal-web-breadcrumb"))
compile(project(":portal-entity"))
compile(group: 'commons-beanutils', name: 'commons-beanutils', version: '20030211.134440')
compile(group: 'commons-digester', name: 'commons-digester', version: '2.1')
compile(group: 'org.apache.tiles', name: 'tiles-api', version: '3.0.1')
compile(group: 'org.apache.tiles', name: 'tiles-core', version: '3.0.1')
compile(group: 'org.apache.tiles', name: 'tiles-jsp', version: '3.0.1')
compile(group: 'org.slf4j', name: 'slf4j-api', version: '1.7.5')
compile(group: 'org.slf4j', name: 'log4j-over-slf4j', version: '1.7.5')
compile(group: 'javax.servlet', name: 'jstl', version: '1.2')
compile(group: 'taglibs', name: 'standard', version: '1.1.2')
compile(group: 'org.springframework', name: 'spring-core', version: "$springVersion")
compile(group: 'org.springframework', name: 'spring-web', version: "$springVersion")
compile(group: 'org.springframework', name: 'spring-webmvc', version: "$springVersion")
compile(group: 'log4j', name: 'log4j', version: '1.2.15') {
exclude group: 'javax.mail', module: 'mail'
exclude group: 'javax.jms', module: 'jms'
exclude group: 'com.sun.jdmk', module: 'jmxtools'
exclude group: 'com.sun.jmx', module: 'jmxri'
}
providedCompile('javax.servlet:javax.servlet-api:3.1.0')
providedCompile(group: 'javax.servlet', name: 'jsp-api', version: '2.0')
providedCompile(group: 'javax', name: 'javaee-api', version: '6.0')
}
由于
答案 0 :(得分:15)
要发布战争,请使用MavenPublication
配置from components.web
。
答案 1 :(得分:6)
在您的发布下添加:
publications {
mavenWeb(MavenPublication) {
from components.web
}
}