
Gradle Platform
定义BOMH2
Platform可以定义生成BOM文件
启用插件
java
plugins {id 'java-platform'}
定义约束,可以包括外部的依赖和项目的内部依赖
java
dependencies {constraints {api project(":hithinkway-usermgmt")api project(":hithinkway-data-common")api "org.mapstruct:mapstruct:${mapstruct_version}"}}
参考:https://docs.gradle.org/current/userguide/platforms.html
api 以及 implementationH3
implementation配置只会声明当前的依赖,不会传递
如果需要传递依赖那么我们的模块相当与是个library,需要启用插件java-library 后使用api声明依赖
共享构建逻辑H2
公共的构建配置可以通过buildSrc来配置
参考:https://docs.gradle.org/current/samples/sample_convention_plugins.html
定义Precompiled script pluginH3
启用插件groovy-gradle-plugin
java
buildSrc/build.gradleplugins {id 'groovy-gradle-plugin'}
src/main/groovy 下定义precompiled script plugins,例如myproject.java-conventions.gradle
precompiled script plugins中需要用到的plugin在buildSrc/build.gradle 中定义
java
// buildSrc/build.gradlerepositories {gradlePluginPortal() // so that external plugins can be resolved in dependencies section}dependencies {implementation 'gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.0.5'testImplementation 'org.spockframework:spock-core:1.3-groovy-2.5'}
最后在模块用启用plugin
java
plugins {id 'java-library'id 'maven-publish'id 'myproject.java-conventions'}
发布H2
添加插件id 'maven-publish'
添加配置
jsx
publishing {repositories {maven {credentials(PasswordCredentials)def releasesRepoUrl = "https://nexus.dev.hithinksoft.com/repository/maven-releases/"def snapshotsRepoUrl = "https://nexus.dev.hithinksoft.com/repository/maven-snapshots/"url = project.hasProperty('release') ? releasesRepoUrl : snapshotsRepoUrl}}publications {mavenJava(MavenPublication) {from components.java}}}
Repository的Credential可以通过环境变量、gradle.properties 等方式传递
jsx
mySecureRepositoryUsername=secret-usermySecureRepositoryPassword=secret-password
上面的例子中repository的名字叫maven ,所以应该定义
jsx
mavenUsername=secret-usermavenPassword=secret-password
评论
新的评论
上一篇
Netty Modbus Proxy
Netty基础 请求响应 ChannelInboundHandlerAdapter 中调用 ChannelHandlerContext 进行write、flush动作,然后经过一些列的OutboundHandler进行处理和转换,最终由 ChannelOutboundBuf…
下一篇
基于Staticman的评论功能
概述 使用Staticman的大致工作流程是: 客户端向Staticman的实例发送HTTP请求,创建表单内容(即一系列字段) Staticman接收到请求后,根据当前的URL(URL中的参数对应仓库信息),读取对应仓库下的staticman配置文件 Staticman读取配置…
