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

哈立德·阿卜杜勒·萨拉姆

我有一个包含子项目的Parent Module Gradle项目。这些子项目之一是Web应用程序。当我发布到Maven仓库时,尽管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')
}

谢谢

彼得·尼德维瑟

对于发布一战,配置MavenPublicationfrom components.web

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何通过Gradle任务使用Jenkins将WAR文件发布到Maven(Nexus)存储库

Azure Pipeline - 使用 YAML 将文件从一个 Repo 复制到另一个 Repo

使用 Maven 删除部署到 Artifactory Repo 的工件

什么是Maven Clean Repo Building?

裤子构建文件与 maven repo 集成

使用`publishToMavenLocal`构建一个可以发布到maven本地repo的可执行jar——spring boot项目

从Markdown文件到Repo根的相对链接

厨师:将食谱创建到 repo 中

从Github Repo克隆单个文件

Mercurial (hg):将多个 repo 转换为单个 repo

如何在Android中使用maven repo?

git clone repo A到新的repo B,同时仍从repo A获取更新

使用yum删除yum repo

将repo下载为zip文件

从git repo将文件拉入Web目录

使用ubuntu将本地文件夹同步到github repo

使用Ansible导入/添加yum .repo文件

如何使用Git Repo文件子集?

Mule将Maven依赖项复制到env.M2_REPO文件夹中

我只想使用 groovy 将 git diff 命令显示的 git repo 中已更改的文件复制到与 git repo 中结构相同的文件夹中

如何设置创作环境以将站点发布到远程git repo?

发布后如何签署 deb/apt repo?

maven:UnknownHostException:repo.maven.apache.org

将本地 repo 从 master 更改为 main 以将文件推送到 github 上的 master repo

如何将发布存档转换为git repo

现在可以从maven repo下载jar

Maven 无法找到本地 repo 工件

我称Maven Repo和Artifactory

为什么Maven从Spring Repo下载jar?