gradle 项目构建以及发布maven 私服&& docker 私服构建发布

1. 项目结构


 
2. 代码说明
a. Dockerfile docker 构建的

FROM openjdk:8-jre-alpine
WORKDIR /appdemo/
COPY  build/distributions/ratpackdemo.zip /appdemo
RUN  unzip /appdemo/ratpackdemo.zip
EXPOSE 5050
ENTRYPOINT [ "./ratpackdemo/bin/ratpackdemo"]

b. build.gradle

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath "io.ratpack:ratpack-gradle:1.5.1"
    classpath('se.transmode.gradle:gradle-docker:1.2')
  }
}
project.group="com.dalong"
version="1.0-SNAPSHOT"
apply plugin: "io.ratpack.ratpack-java"
apply plugin: "idea"
apply plugin: "docker"
apply plugin: "maven"
repositories {
  jcenter()
}
uploadArchives {
    repositories.mavenDeployer {
        repository(url: "http://nexushost:8081/nexus/content/repositories/snapshots") {
            authentication(userName: "username", password: "userpassword")
            project.group="com.dalong"
            version="1.0-SNAPSHOT"
            pom.groupId = "com.dalong"
            pom.artifactId = "mydemo-ratpack"
        }
    }
}
distZip {
    archiveName = 'ratpackdemo-1-1.zip'
}
dependencies {
  runtime "org.slf4j:slf4j-simple:1.7.25"
}
task buildDocker(type:Docker,dependsOn: build){
  push = false
	applicationName = distZip.archiveName
	project.group="dockerimagehost/mydemo"
	dockerfile = file("${projectDir}/src/main/docker/Dockerfile")
  doFirst {
		copy {
			from distZip
			into stageDir
		}
 }
}
mainClassName = "dalong.Application"

c. 项目代码
省略比较简单,可以参考下面的参考地址
https://github.com/rongfengliang/ratpackdemo
3. 构建
./gradlew buildDocker  uploadArchives
4. 可能碰到的问题
注意以下代码
uploadArchives {
    repositories.mavenDeployer {
        repository(url: "http://nexushost:8081/nexus/content/repositories/snapshots") {
            authentication(userName: "username", password: "userpassword")
            project.group="com.dalong"
            version="1.0-SNAPSHOT"
            pom.groupId = "com.dalong"
            pom.artifactId = "mydemo-ratpack"
        }
    }
}
中version 对于对应maven仓库应该包含对应的 release 后者  SNAPSHOT 不然会存在发布提示400 的错误
5. 参考资料
https://github.com/rongfengliang/ratpackdemo
https://github.com/Transmode/gradle-docker
 
 
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值