gradle 上传jar包_只上载Gradle中的war / jar文件(限制zip / tar生成和上传)

bd96500e110b49cbb3cd949968f18be7.png

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以使用以下步骤将 Jar上传到 JFrog Artifactory: 1. 在 build.gradle 文件添加以下代码,以配置 JFrog 插件: ``` buildscript { repositories { maven { url "${artifactory_contextUrl}/plugins-release" credentials { username = "${artifactory_user}" password = "${artifactory_password}" } name = "maven-username-plugins" } } dependencies { classpath "org.jfrog.buildinfo:build-info-extractor-gradle:<latest-version>" classpath "org.jfrog.buildinfo:build-info-extractor-gradle:<latest-version>" } } apply plugin: 'com.jfrog.artifactory' apply plugin: 'maven-publish' artifactory { contextUrl = "${artifactory_contextUrl}" publish { repository { repoKey = '<your-repo-name>' username = "${artifactory_user}" password = "${artifactory_password}" maven = true } defaults { publications ('<your-publication-name>') } } } ``` 2. 在 gradle.properties 文件添加以下代码,以配置 Artifactory 的用户名和密码: ``` artifactory_contextUrl=<your-artifactory-url> artifactory_user=<your-artifactory-username> artifactory_password=<your-artifactory-password> ``` 3. 将 Jar 包添加到发布配置,在 build.gradle 文件添加以下代码: ``` publishing { publications { maven(MavenPublication) { groupId = '<your-group-id>' artifactId = '<your-artifact-id>' version = '<your-version>' artifact(file('<path-to-your-jar>')) } } } ``` 4. 运行以下命令将 Jar上传Artifactory: ``` ./gradlew artifactoryPublish ``` 这将把你的 Jar 包发布到 Artifactory 的指定仓库
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值