• 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
  • 相关阅读:
    20170602
    使用布局规划页面
    商品的删除
    修改页面的 修改图片
    商品修改
    引入行高亮显示
    添加一个时间插件: 1.把插件放到 public目录 下 datetimepicker
    排序,搜索 代码
    搜索
    翻页代码,商品列表页;
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/8397635.html
Copyright © 2020-2023  润新知