只上载Gradle中的war / jar文件(限制zip / tar生成和上传) [英] Upload only war/jar files in gradle(restrict zip/tar generation and upload)
问题描述
gradle build
命令构建,并使用 gradle upload
命令上传工件。我的问题是tar,zip文件也是通过这个命令生成并上传的。我不想要它。只有我想上传的东西是'jar'和'war'文件。 我也有一个相关的问题,我昨天发布了这里。
更多详情(我排除了一些不需要的代码)
以root身份建立档案 allprojects {
apply plugin:'maven'
group = 'groupid'
version ='1.0-SNAPSHOT'
}
子项目{
apply plugin:'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7
存储库{
maven {
凭证{
用户名$ nexusUser
密码$ nexusPass
url$ nexusUrl
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url :$ nexusSnapshotUrl){
认证(用户名:$ nexusUser,密码:$ nexusPass)
}
}
}
}
}
ext.comlib = [ // groovy映射文字
junit3:junit:junit:3.8,
junit4:junit:junit:4.9,
spring_core:org.springframework:spring-core:3.1 ,
hibernate_validator:org.hibernate:hibernate-validator:5.1.3.Final,
spring_core:org.springframework.security:spring-security-core:4.0.2.RELEASE,
spring_security_web:org.springframework.security:spring-security-web:4.0.2.RELEASE,
spring_security_config:org.springframework.security:spring-security-config:4.0.2.RELEASE ,
spring_boot_starter_test:org.springframework.boot:spring-boot-starter-test:1.2.5.RELEASE,
spring_boot_starter_actuator:org.springframework.boot:spring-boot-starter-actuator: 1.2.5.RELEASE,
spring_boot_plugin_gradle:org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE,
asciidoctor_gradle_plugin:org.asciidoctor:asciidoctor-gradle-plugin:1.5.1,
asciidoctor_pdf_plugin:org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.9/ *,
sl4j_api: org.slf4j:slf4j-api:1.7.12,
sl4j_log4j:org.slf4j:slf4j-log4j12:1.7.12,
logback_classic:ch.qos.logback:logback-classic :1.1.3,
logback_core:ch.qos.logback:logback-core:1.1.3* /
]
在子模块中构建文件
$ b
apply插件:'spring-boot'
group ='com.group.id'
应用于:../build.gradle
apply plugin:'org.asciidoctor.gradle.asciidoctor '
apply plugin:'war'
description ='module name'
dependencies {
compilesomeothermodule:commonapi:1.0.0-SNAPSHOT
编译io.springfox:springfox-swagger2:2.0.1
编译项目(':dependsproject1:dep endingproject2')
编译comlib.spring_boot_starter_actuator
编译comlib.spring_core
编译comlib.spring_security_web
编译comlib.spring_security_config
testCompile(comlib.spring_boot_starter_test){
exclude(module:'commons-logging')
}
testCompile comlib.junit4
providesCompile comlib_app.spring_boot_plugin_tomcat
testCompileio.springfox:springfox-staticdocs:2.0.3
testcompileorg.springframework:spring-test:4.1.7.RELEASE
}
$ b $ ext {
swaggerOutputDir = file(src / docs / asciidoc / generated )
asciiDocOutputDir = file($ {buildDir} / asciidoc)
}
test {
systemProperty'org.springframework.restdocs.outputDir',asciiDocOutputDir
systemProperty'io.springfox.staticdocs.outputDir',swaggerOutputDir
}
// spring引导插件
buildscript {
repositories {
maven {
凭证{
用户名$ nexusUser
密码$ nexusPass
}
url$ nexusCentral
}
maven {
凭证{
用户名$ nexusUser
密码$ nexusPass
}
url$ nexusThirdParty
依赖性{
classpath(comlib.spring_boot_plugin_gradle)
}
}
在我的gradle文件中包含以下代码片段: $ b
[distZip,distTar] .each {任务 - > configurations.archives.artifacts.removeAll
{it.class.simpleName ==ArchivePublishArtifact&& it.archiveTask ==任务}
task.enabled = false
}
有关详情,请参阅此链接。它的问题与春季开机插件。
My build script is like as follows. I use gradle build
command to build and gradle upload
command to upload the artifact. My problem is a tar,zip file is also generated with this command and get uploaded. I dont want it. Only things I would like to get uploaded is 'jar' and 'war' files.
I have also a related question posted by me yesterday here.
More details(I have excluded some unwanted code)
build file in root
allprojects {
apply plugin: 'maven'
group = 'groupid'
version = '1.0-SNAPSHOT'
}
subprojects {
apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
maven {
credentials {
username "$nexusUser"
password "$nexusPass"
}
url "$nexusUrl"
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "$nexusSnapshotUrl") {
authentication(userName: "$nexusUser", password: "$nexusPass")
}
}
}
}
}
ext.comlib = [ // Groovy map literal
junit3: "junit:junit:3.8",
junit4: "junit:junit:4.9",
spring_core: "org.springframework:spring-core:3.1",
hibernate_validator : "org.hibernate:hibernate-validator:5.1.3.Final",
spring_core : "org.springframework.security:spring-security-core:4.0.2.RELEASE",
spring_security_web: "org.springframework.security:spring-security-web:4.0.2.RELEASE",
spring_security_config: "org.springframework.security:spring-security-config:4.0.2.RELEASE",
spring_boot_starter_test: "org.springframework.boot:spring-boot-starter-test:1.2.5.RELEASE",
spring_boot_starter_actuator: "org.springframework.boot:spring-boot-starter-actuator:1.2.5.RELEASE",
spring_boot_plugin_gradle: "org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE",
asciidoctor_gradle_plugin: "org.asciidoctor:asciidoctor-gradle-plugin:1.5.1",
asciidoctor_pdf_plugin: "org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.9"/*,
sl4j_api: "org.slf4j:slf4j-api:1.7.12",
sl4j_log4j: "org.slf4j:slf4j-log4j12:1.7.12",
logback_classic: "ch.qos.logback:logback-classic:1.1.3",
logback_core: "ch.qos.logback:logback-core:1.1.3"*/
]
build file in sub module
apply plugin: 'spring-boot'
group = 'com.group.id'
apply from: "../build.gradle"
apply plugin: 'org.asciidoctor.gradle.asciidoctor'
apply plugin: 'war'
description = 'module name'
dependencies {
compile "someothermodule:commonapi:1.0.0-SNAPSHOT"
compile "io.springfox:springfox-swagger2:2.0.1"
compile project(':dependingproject1:dependingproject2')
compile comlib.spring_boot_starter_actuator
compile comlib.spring_core
compile comlib.spring_security_web
compile comlib.spring_security_config
testCompile(comlib.spring_boot_starter_test) {
exclude(module: 'commons-logging')
}
testCompile comlib.junit4
providedCompile comlib_app.spring_boot_plugin_tomcat
testCompile "io.springfox:springfox-staticdocs:2.0.3"
testCompile "org.springframework:spring-test:4.1.7.RELEASE"
}
ext {
swaggerOutputDir = file("src/docs/asciidoc/generated")
asciiDocOutputDir = file("${buildDir}/asciidoc")
}
test {
systemProperty 'org.springframework.restdocs.outputDir', asciiDocOutputDir
systemProperty 'io.springfox.staticdocs.outputDir', swaggerOutputDir
}
//spring boot plugin
buildscript {
repositories {
maven {
credentials {
username "$nexusUser"
password "$nexusPass"
}
url "$nexusCentral"
}
maven {
credentials {
username "$nexusUser"
password "$nexusPass"
}
url "$nexusThirdParty"
}
}
dependencies {
classpath(comlib.spring_boot_plugin_gradle)
}
}
Included the following code snippet in my gradle file
[distZip, distTar].each { task -> configurations.archives.artifacts.removeAll
{ it.class.simpleName == "ArchivePublishArtifact" && it.archiveTask == task }
task.enabled = false
}
For more details refer this link. Its issue with spring boot plugin.
这篇关于只上载Gradle中的war / jar文件(限制zip / tar生成和上传)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!