//---------------------- 公共部分 ----------------------// //系统启动初始化:自动下载插件 def repoConfig = { all { ArtifactRepository repo -> if (repo instanceof MavenArtifactRepository) { def url = repo.url.toString() if (url.contains('repo1.maven.org/maven2') || url.contains('repo.maven.org/maven2') || url.contains('repo.maven.apache.org/maven2') || url.contains('jcenter.bintray.com') || url.contains('maven.google.com') || url.contains('plugins.gradle.org/m2') || url.contains('repo.spring.io/libs-milestone') || url.contains('repo.spring.io/plugins-release') || url.contains('repo.grails.org/grails/core') || url.contains('repository.apache.org/snapshots') ) { println "gradle init: [buildscript.repositories] (${repo.name}: ${repo.url}) removed" remove repo } } } // Maven 镜像聚合了:central、jcenter、google、gradle-plugin maven { url 'https://maven.aliyun.com/repository/central' } maven { url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } maven { url 'https://maven.aliyun.com/repository/public/' } } allprojects { buildscript { repositories repoConfig } repositories repoConfig } repositories { maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } } //---------------------- JAVA 编译插件 ----------------------// apply plugin: 'java-library' apply plugin: 'maven-publish' //发布到本地 //JAVA 文件编码 compileJava.options.encoding = 'UTF-8' tasks.withType(JavaCompile) { options.debug = true //输出行号 options.debugOptions.debugLevel = "source,lines,vars" //输出行号 options.encoding = "UTF-8" } //JAVA兼容性设置 sourceCompatibility = '1.8' targetCompatibility = '1.8' //---------------------- 变量定义 --------------------- def ccProjectName='ccframe' def ccPubVersion='2.0-SNAPSHOT' //正式TAG版本请修改此版本号 def ccReleaseTime=new Date().format("yyyy-MM-dd_HH-mm-ss", TimeZone.getTimeZone("Asia/Shanghai")) def ccBuildNumber=System.getenv().BUILD_NUMBER == null ? 'debug' : System.getenv().BUILD_NUMBER?.toInteger() def ccSvnVersion=System.getenv().SVN_REVISION == null ? 'debug' : System.getenv().SVN_REVISION?.toInteger() //---------------------- JAR 打包插件 ----------------------// apply plugin: 'application' mainClassName = 'org.ccframe.app.App' jar { manifestContentCharset 'utf-8' metadataCharset 'utf-8' manifest { attributes 'Main-Class': 'org.ccframe.app.App' } } task clearJar(type: Delete) { delete "$buildDir\\libs\\lib" } task copyJar(type: Copy, dependsOn: 'clearJar') { //提取所有的jar from configurations.compileClasspath{ exclude 'lombok*' exclude 'jsp-api*' } into "$buildDir\\libs\\lib" } /* bootJar {//配合jar服务器启动.bat脚本 // 例外所有的jar excludes = ["*.jar"] // lib目录的清除和复制任务 dependsOn clearJar dependsOn copyJar // 指定依赖包的路径 manifest { attributes "Manifest-Version": 1.0, 'Class-Path': configurations.compileClasspath.files.collect { "lib/$it.name" }.join(' ') } } //还有个https://github.com/spring-projects-experimental/spring-boot-thin-launcher有空试试 */ /* ----------------- buildship 整合 --------------- */ apply plugin: 'java' apply plugin: 'eclipse' eclipse { classpath { downloadSources = true defaultOutputDir = file('/war/WEB-INF/classes') file { whenMerged { //兼容eclipse2020设置:test输出目录要与main的不一样 entries.each { if(it.path.startsWith('src/main')){ println it it.output = null } } } } } } //----------------------- 编译JAR依赖配置 ------------------------// configurations.all { transitive = false //默认不自动关联依赖,以免打包过大 resolutionStrategy.cacheChangingModulesFor 0, 'seconds' //立即检查而不是要过24h,因为有snapshot exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' // 关联发布时,强制移除冲突的jar exclude group: 'ch.qos.logback' // 关联发布时,强制移除冲突的jar exclude group: 'pull-parser' } dependencies { //参与编译与发布. implementation 'org.springframework.boot:spring-boot:2.3.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter:2.3.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-web:2.3.2.RELEASE' implementation 'org.springframework.boot:spring-boot-autoconfigure:2.3.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.3.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-freemarker:2.3.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-log4j2:2.3.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-tomcat:2.3.2.RELEASE' implementation ('org.springframework.boot:spring-boot-starter-data-elasticsearch:2.3.2.RELEASE') { exclude group: 'org.springframework.data', module: 'spring-data-elasticsearch' } implementation 'org.springframework.boot:spring-boot-starter-security:2.3.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-quartz:2.3.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-actuator:2.3.2.RELEASE' // implementation 'org.springframework.boot:spring-boot-starter-data-redis-reactive:2.3.2.RELEASE' implementation 'org.apache.tomcat.embed:tomcat-embed-core:9.0.37' implementation 'org.apache.tomcat.embed:tomcat-embed-websocket:9.0.37' implementation 'javax.servlet:javax.servlet-api:4.0.1' implementation 'commons-fileupload:commons-fileupload:1.3.3' implementation 'commons-io:commons-io:2.5' implementation 'commons-jxpath:commons-jxpath:1.3' implementation 'commons-lang:commons-lang:2.6' implementation 'org.apache.commons:commons-lang3:3.11' implementation 'commons-collections:commons-collections:3.2.2' implementation 'org.apache.commons:commons-collections4:4.4' implementation 'commons-codec:commons-codec:1.15' implementation 'org.springframework:spring-core:5.2.8.RELEASE' implementation 'org.springframework:spring-beans:5.2.8.RELEASE' implementation 'org.springframework:spring-web:5.2.8.RELEASE' implementation 'org.springframework:spring-webmvc:5.2.8.RELEASE' implementation 'org.springframework:spring-context:5.2.8.RELEASE' implementation 'org.springframework:spring-context-support:5.2.8.RELEASE' implementation 'org.springframework:spring-tx:5.2.8.RELEASE' implementation 'org.springframework:spring-orm:5.2.8.RELEASE' implementation 'org.springframework:spring-aop:5.2.8.RELEASE' implementation 'org.springframework:spring-jdbc:5.2.8.RELEASE' implementation 'org.springframework:spring-expression:5.2.8.RELEASE' implementation 'org.apache.poi:poi:3.14' //3.16要commons-collection4,700多k,暂不更新 implementation 'org.apache.poi:poi-ooxml:3.14' implementation 'org.apache.poi:poi-ooxml-schemas:3.14' implementation 'org.apache.poi:poi-scratchpad:3.14' implementation 'org.apache.xmlbeans:xmlbeans:3.1.0' implementation 'stax:stax-api:1.0.1' //权限认证 implementation 'org.springframework.security:spring-security-config:5.3.3.RELEASE' implementation 'org.springframework.security:spring-security-core:5.3.3.RELEASE' implementation 'org.springframework.security:spring-security-web:5.3.3.RELEASE' // implementation 'org.springframework.security:spring-security-jwt:1.1.1.RELEASE' implementation 'org.springframework.data:spring-data-commons:2.2.13.RELEASE' implementation 'org.springframework.data:spring-data-jpa:2.2.13.RELEASE' implementation 'org.springframework.data:spring-data-elasticsearch:3.2.13.RELEASE' //锁定版本 https://mvnrepository.com/artifact/org.springframework.data/spring-data-releasetrain/Moore-SR13 // implementation 'org.springframework.data:spring-data-redis:2.2.13.RELEASE' //lettuce驱动需要 // implementation 'org.springframework.data:spring-data-keyvalue:2.2.13.RELEASE' //lettuce驱动需要 implementation 'org.apache.lucene:lucene-analyzers-common:7.7.3' implementation 'org.apache.lucene:lucene-core:7.7.3' implementation 'org.apache.lucene:lucene-highlighter:7.7.3' implementation 'org.apache.lucene:lucene-join:7.7.3' implementation 'org.apache.lucene:lucene-memory:7.7.3' implementation 'org.apache.lucene:lucene-queries:7.7.3' implementation 'org.apache.lucene:lucene-queryparser:7.7.3' implementation 'org.apache.lucene:lucene-spatial:7.7.3' implementation 'org.apache.lucene:lucene-suggest:7.7.3' implementation 'org.apache.lucene:lucene-sandbox:7.7.3' implementation 'org.apache.lucene:lucene-misc:7.7.3' implementation 'org.apache.lucene:lucene-grouping:7.7.3' implementation 'joda-time:joda-time:2.9.9' implementation 'org.elasticsearch:elasticsearch-core:6.8.19' implementation 'org.elasticsearch:elasticsearch:6.8.19' implementation 'org.elasticsearch:elasticsearch-x-content:6.8.19' implementation 'org.elasticsearch.plugin:transport-netty4-client:6.8.19' implementation 'org.elasticsearch.plugin:rank-eval-client:6.8.19' implementation 'org.apache.commons:commons-pool2:2.8.0' implementation 'org.apache.httpcomponents:httpclient:4.5.12' implementation 'org.apache.httpcomponents:httpcore:4.4.13' implementation 'org.apache.httpcomponents:httpcore-nio:4.4.13' implementation 'org.apache.httpcomponents:httpasyncclient:4.1.4' //ES本地服务额外需要 implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-smile:2.11.0' implementation 'org.apache.logging.log4j:log4j-core:2.14.1' implementation 'org.elasticsearch:elasticsearch-cli:6.8.19' implementation 'com.tdunning:t-digest:3.2' implementation 'org.elasticsearch:jna:5.5.0' //implementation files('/lib/plugin-classloader-6.8.19.jar') //implementation 'org.codelibs.elasticsearch.lib:plugin-classloader:6.8.19' implementation 'org.codelibs.elasticsearch.lib:plugin-classloader:6.8.12' implementation 'org.hibernate:hibernate-core:5.4.19.Final' implementation 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final' implementation 'org.hibernate.common:hibernate-commons-annotations:5.1.0.Final' implementation 'net.bytebuddy:byte-buddy-dep:1.10.14' implementation 'org.ow2.asm:asm:8.0.1' implementation 'org.ow2.asm:asm-commons:8.0.1' implementation 'org.jboss:jandex:2.1.3.Final' implementation 'jakarta.persistence:jakarta.persistence-api:2.2.3' implementation 'org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE' implementation 'org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE' // implementation 'io.lettuce:lettuce-core:5.3.1.RELEASE' // implementation 'io.netty:netty-all:4.1.50.Final' // implementation 'io.projectreactor:reactor-core:3.3.6.RELEASE' // implementation 'org.reactivestreams:reactive-streams:1.0.3' implementation 'redis.clients:jedis:2.9.3' //j2cache限制不要升级 implementation 'io.netty:netty-all:4.1.50.Final' // implementation 'io.springfox:springfox-swagger-ui:2.9.2' //改用knife4j ui implementation 'io.springfox:springfox-swagger-common:2.9.2' implementation 'io.springfox:springfox-swagger2:2.9.2' implementation 'io.springfox:springfox-spring-web:2.9.2' implementation 'io.swagger:swagger-models:1.5.21' implementation 'io.swagger:swagger-annotations:1.5.21' implementation 'io.springfox:springfox-core:2.9.2' implementation 'io.springfox:springfox-spi:2.9.2' implementation 'io.springfox:springfox-schema:2.9.2' implementation 'org.mapstruct:mapstruct:1.2.0.Final' implementation 'io.github.wilson-he:swagger2-spring-boot-starter:1.1.2' implementation 'com.google.guava:failureaccess:1.0.1' implementation ('com.github.xiaoymin:knife4j-spring-boot-autoconfigure:2.0.9') { exclude group: 'com.github.xiaoymin', module: 'knife4j-spring' } implementation 'com.github.xiaoymin:knife4j-spring-ui:2.0.9' implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.14.1' implementation 'org.slf4j:slf4j-api:1.7.30' implementation 'commons-logging:commons-logging:1.2' implementation 'org.apache.logging.log4j:log4j-api:2.14.1' // implementation 'org.apache.logging.log4j:log4j-core:2.14.1' implementation 'org.yaml:snakeyaml:1.26' implementation 'com.fasterxml.jackson.core:jackson-annotations:2.11.0' implementation 'com.fasterxml.jackson.core:jackson-core:2.11.0' implementation 'com.fasterxml.jackson.core:jackson-databind:2.11.0' implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11.0' implementation 'org.freemarker:freemarker:2.3.30' implementation 'com.alibaba:druid:1.1.23' implementation 'com.mysql:mysql-connector-j:8.0.33' implementation 'org.redisson:redisson:3.15.6' //redis分布式扩展支持 implementation 'org.jboss.marshalling:jboss-marshalling:2.0.9.Final' implementation 'org.jboss.marshalling:jboss-marshalling-river:2.0.9.Final' //hanlp词法分析器 http://hanlp.linrunsoft.com/index.html implementation 'com.hankcs:hanlp:portable-1.7.1' implementation 'com.google.guava:guava:29.0-jre' implementation 'com.carrotsearch:hppc:0.8.2' implementation 'org.slf4j:jul-to-slf4j:1.7.30' implementation 'org.springframework:spring-jcl:5.2.8.RELEASE' implementation 'com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.0' implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.0' implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.0' implementation 'net.oschina.j2cache:j2cache-spring-boot2-starter:2.8.0-release' implementation 'net.oschina.j2cache:j2cache-core:2.8.2-release' implementation 'net.oschina.j2cache:j2cache-springcache:2.8.0-release' implementation 'de.ruedigermoeller:fst:2.57' implementation 'org.objenesis:objenesis:3.1' implementation 'com.github.ben-manes.caffeine:caffeine:2.8.4' implementation 'com.alibaba:fastjson:1.2.62' implementation 'com.fasterxml:classmate:1.5.1' implementation 'org.javassist:javassist:3.27.0-GA' implementation 'org.jboss.logging:jboss-logging:3.4.1.Final' implementation 'org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1.1' implementation 'org.dom4j:dom4j:2.1.3' implementation 'jakarta.annotation:jakarta.annotation-api:1.3.5' implementation 'net.coobird:thumbnailator:0.4.8' implementation 'org.dbunit:dbunit:2.5.4' //不要升级 implementation 'org.apache.ant:ant:1.9.9' implementation 'antlr:antlr:2.7.7' implementation 'io.jsonwebtoken:jjwt:0.9.1' //token方案 //集群定时任务 implementation 'org.quartz-scheduler:quartz:2.3.2' implementation 'org.quartz-scheduler:quartz-jobs:2.3.2' implementation 'com.github.binarywang:weixin-java-miniapp:3.8.0' //微信小程序二维码支持 implementation 'org.elasticsearch.client:elasticsearch-rest-high-level-client:6.8.19' implementation 'org.elasticsearch.client:elasticsearch-rest-client:6.8.19' implementation 'org.elasticsearch.plugin:lang-mustache-client:6.8.19' implementation 'uk.org.lidalia:sysout-over-slf4j:1.0.2' //system out err stacktrace转slf4j,便于统一日志 //implementation 'net.logstash.logback:logstash-logback-encoder:6.4' //implementation 'org.sejda.imageio:webp-imageio:0.1.6' //webp的imageIO,用于小图 implementation 'io.minio:minio:8.4.1' //minio分布式文件 implementation 'com.squareup.okhttp3:okhttp:4.9.0' //minio用的http client implementation 'com.squareup.okio:okio:2.8.0' //minio用的http client implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.4.10' implementation 'org.apache.shardingsphere:sharding-jdbc-spring-boot-starter:4.1.1' //分库分表的支持 implementation 'org.apache.shardingsphere:shardingsphere-common:4.1.1' implementation 'org.apache.shardingsphere:sharding-spring-boot-util:4.1.1' implementation 'org.apache.shardingsphere:sharding-transaction-spring:4.1.1' implementation 'org.apache.shardingsphere:sharding-jdbc-core:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-pluggable:4.1.1' implementation 'org.apache.shardingsphere:sharding-transaction-core:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-sql-parser-sql92:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-sql-parser-engine:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-route:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-executor:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-spi:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-sql-parser-binder:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-rewrite-engine:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-merge:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-pluggable:4.1.1' implementation 'org.apache.shardingsphere:master-slave-core-route:4.1.1' implementation 'org.apache.shardingsphere:sharding-core-common:4.1.1' implementation 'org.apache.shardingsphere:sharding-core-route:4.1.1' implementation 'org.apache.shardingsphere:sharding-core-api:4.1.1' implementation 'org.apache.shardingsphere:sharding-core-rewrite:4.1.1' implementation 'org.apache.shardingsphere:encrypt-core-rewrite:4.1.1' implementation 'org.apache.shardingsphere:encrypt-core-merge:4.1.1' implementation 'org.apache.shardingsphere:sharding-core-execute:4.1.1' implementation 'org.apache.shardingsphere:sharding-core-merge:4.1.1' implementation 'org.apache.shardingsphere:encrypt-core-common:4.1.1' implementation 'org.apache.shardingsphere:encrypt-core-api:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-sql-parser-spi:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-sql-parser-mysql:4.1.1' implementation 'org.apache.shardingsphere:shardingsphere-sql-parser-statement:4.1.1' implementation 'org.codehaus.groovy:groovy:2.4.5' implementation 'org.antlr:antlr4-runtime:4.7.2' //二维码servlet使用 implementation 'com.google.zxing:core:3.4.1' implementation 'com.google.zxing:javase:3.4.1' //监控 implementation 'org.springframework.boot:spring-boot-actuator-autoconfigure:2.3.2.RELEASE' implementation 'org.latencyutils:LatencyUtils:2.0.3' implementation 'io.micrometer:micrometer-core:1.5.3' implementation 'org.springframework.boot:spring-boot-actuator:2.3.2.RELEASE' //其它编译但是不需要发布的 compileOnly 'javax.servlet.jsp:jsp-api:2.2' compileOnly 'org.projectlombok:lombok:1.18.30' annotationProcessor 'org.projectlombok:lombok:1.18.30' testAnnotationProcessor 'org.projectlombok:lombok:1.18.30' //参与测试不进行发布 testImplementation 'org.projectlombok:lombok:1.18.30' testImplementation 'junit:junit:4.8' //4.11的版本需要额外包 } publishing { //publishToMavenLocal可以发布到本地 publications { maven(MavenPublication) { groupId = 'org.ccframe' artifactId = 'ccframe-server' version = '1.0-SNAPSHOT' from components.java } } }