微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java – 使用Gradle将WAR文件发布到Maven Repo

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

谢谢

解决方法:

要发布战争,请使用components.web配置MavenPublication.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐