簡體   English   中英

使用Gradle將WAR文件發布到Maven Repo

[英]Publish WAR file to Maven Repo using Gradle

我有一個父模塊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')
}

謝謝

要發布戰爭, MavenPublication使用from components.web配置MavenPublication

在您的發布下添加:

publications {
    mavenWeb(MavenPublication) {
        from components.web
    }
} 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM