Procházet zdrojové kódy

发布2.3.4-SNAPSHOT.

nieqiurong před 6 roky
rodič
revize
96fbf38fb8

+ 3 - 0
.gitignore

@@ -21,3 +21,6 @@ html
 .DS_Store
 
 /repo/
+/gradle/
+/gradlew
+/gradlew.bat

+ 70 - 50
build.gradle

@@ -49,7 +49,7 @@ ext {
 
 allprojects{
     group = 'com.baomidou'
-    version = '2.3.3'
+    version = '2.3.4-SNAPSHOT'
 }
 
 
@@ -57,33 +57,34 @@ description = "Mybatis 增强工具包 - 只做增强不做改变,简化CRUD
 
 buildscript {
     repositories {
-        maven { url "https://repo.spring.io/plugins-release" }
+        maven { url "https://plugins.gradle.org/m2/" }
     }
     dependencies {
-        classpath("org.springframework.build.gradle:propdeps-plugin:0.0.7")
+        classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
     }
 }
 
-configure(subprojects) {
-    apply plugin: 'propdeps'
-    apply plugin: 'propdeps-idea'
-    apply plugin: 'propdeps-eclipse'
-}
-
 subprojects{
 
     apply plugin: 'java'
     apply plugin: 'signing'
-    apply plugin: 'maven-deploy'
+    apply plugin: 'maven-publish'
+    apply plugin: 'nebula.optional-base'
+    apply plugin: 'nebula.provided-base'
 
     sourceCompatibility = "${javaVersion}"
     targetCompatibility = "${javaVersion}"
 
-    //noinspection GroovyAssignabilityCheck
     tasks.withType(JavaCompile) {
         options.encoding = 'UTF-8'
     }
 
+    jar {
+        manifest {
+            attributes 'Implementation-Version': version
+        }
+    }
+
     repositories {
         mavenLocal()
         maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
@@ -118,62 +119,81 @@ subprojects{
         archives javadocJar
     }
 
-    // gradle clean build uploadArchives -Dun=用户名 -Dps=密码 -x test
-    uploadArchives {
+    tasks.whenTaskAdded { task ->
+        if (task.name.contains('signMavenJavaPublication')) {
+            task.enabled = new File(project.property('signing.secretKeyRingFile') as String).isFile()
+        }
+    }
+
+    /*
+     * 1.修改 gradle.properties 中 signing.secretKeyRingFile的路径
+     * 2.执行 gradle clean build publish -Dun=用户名 -Dps=密码 -x test
+     * ---------------------------wrapper------------------------------------------
+     * win: gradlew.bat clean build publish -Dun=用户名 -Dps=密码 -x test
+     * mac: gradlew clean build publish -Dun=用户名 -Dps=密码 -x test
+     */
+    publishing {
+
         repositories {
-            mavenDeployer {
-                def isLocal = Boolean.valueOf(project.properties.get("local"))
-                if(isLocal){
-                    repository(url: uri('../repo'))
-                }else {
-                    signing {
-                        sign configurations.archives
-                    }
-                    beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
-                    def userName = System.getProperty("un")
-                    def passWord = System.getProperty("ps")
-                    pom.version = "$project.version"
-                    pom.artifactId = "$project.name"
-                    pom.groupId = "$project.group"
-                    repository(url: pom.version.endsWith('SNAPSHOT') ? 'https://oss.sonatype.org/content/repositories/snapshots/'
-                        :'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
-                        //noinspection GroovyAssignabilityCheck
-                        authentication(userName: userName, password: passWord)
-                    }
+            maven {
+                def userName = System.getProperty("un")
+                def passWord = System.getProperty("ps")
+                def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
+                def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
+                url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
+
+                credentials {
+                    username userName
+                    password passWord
                 }
-                pom.project {
-                    //noinspection GroovyAssignabilityCheck
-                    name 'mybatis-plus'
-                    packaging 'jar'
-                    description 'An enhanced toolkit of Mybatis to simplify development.'
-                    url 'https://github.com/baomidou/mybatis-plus'
+            }
+        }
+
+        publications {
+
+            mavenJava(MavenPublication) {
+                from components.java
 
+                artifact sourcesJar
+                artifact javadocJar
+
+                pom {
+                    name = 'mybatis-plus'
+                    packaging 'jar'
+                    description = 'An enhanced toolkit of Mybatis to simplify development.'
+                    url = 'https://github.com/baomidou/mybatis-plus'
+                    licenses {
+                        license {
+                            name = 'The Apache License, Version 2.0'
+                            url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+                        }
+                    }
                     scm {
-                        connection 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
-                        developerConnection 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
-                        url 'https://github.com/baomidou/mybatis-plus'
+                        connection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
+                        developerConnection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
+                        url = 'https://github.com/baomidou/mybatis-plus'
                     }
 
                     licenses {
                         license {
-                            //noinspection GroovyAssignabilityCheck
-                            name 'The Apache License, Version 2.0'
-                            url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+                            name = 'The Apache License, Version 2.0'
+                            url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                         }
                     }
 
                     developers {
                         developer {
-                            id 'baomidou'
-                            //noinspection GroovyAssignabilityCheck
-                            name 'hubin'
-                            email 'jobob@qq.com'
+                            id = 'baomidou'
+                            name = 'hubin'
+                            email = 'jobob@qq.com'
                         }
                     }
                 }
             }
         }
-    }
 
-    compileJava.dependsOn(processResources)
+        signing {
+            sign publishing.publications.mavenJava
+        }
+    }
 }

+ 0 - 13
buildSrc/build.gradle

@@ -1,13 +0,0 @@
-apply plugin: "groovy"
-
-/*
-    https://github.com/gradle/gradle/issues/867
-    https://github.com/spring-gradle-plugins/propdeps-plugin/commit/bd14013e6f0adba7908778349bb0a08b50212658
- */
-uploadArchives.enabled = false
-
-dependencies {
-    compile gradleApi()
-    compile localGroovy()
-}
-

+ 0 - 41
buildSrc/src/main/groovy/com/baomidou/gradle/MavenDeployPlugin.groovy

@@ -1,41 +0,0 @@
-package com.baomidou.gradle
-
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-import org.gradle.api.artifacts.maven.Conf2ScopeMappingContainer
-import org.gradle.api.artifacts.maven.MavenPom
-import org.gradle.api.artifacts.maven.PomFilterContainer
-import org.gradle.api.plugins.MavenPlugin
-import org.gradle.api.tasks.Upload
-
-class MavenDeployPlugin implements Plugin<Project> {
-
-    @Override
-    void apply(Project project) {
-        project.plugins.apply(MavenPlugin)
-        Conf2ScopeMappingContainer scopeMappings = project.conf2ScopeMappings
-        scopeMappings.addMapping(MavenPlugin.COMPILE_PRIORITY + 1,
-            project.configurations.getByName("provided"), Conf2ScopeMappingContainer.PROVIDED)
-        // Add a temporary new optional scope
-        scopeMappings.addMapping(org.gradle.api.plugins.MavenPlugin.COMPILE_PRIORITY + 2,
-            project.configurations.getByName("optional"), "optional")
-        // Add a hook to replace the optional scope
-        project.afterEvaluate {
-            project.tasks.withType(Upload).each { applyToUploadTask(project, it) }
-        }
-    }
-
-    private void applyToUploadTask(Project project, Upload upload) {
-        upload.repositories.withType(PomFilterContainer).each{ applyToPom(project, it) }
-    }
-
-    private void applyToPom(Project project, PomFilterContainer pomContainer) {
-        pomContainer.pom.whenConfigured { MavenPom pom ->
-            pom.dependencies.findAll{ it.scope == "optional" }.each {
-                it.scope = "compile"
-                it.optional = true
-            }
-        }
-    }
-
-}

+ 0 - 1
buildSrc/src/main/resources/META-INF/gradle-plugins/maven-deploy.properties

@@ -1 +0,0 @@
-implementation-class=com.baomidou.gradle.MavenDeployPlugin

+ 0 - 1
gradle.properties

@@ -1,4 +1,3 @@
 signing.keyId=1FD337F9
 signing.password=243194995
 signing.secretKeyRingFile=/Users/hubin/dev/signing.gpg
-local=true

+ 1 - 1
mybatis-plus-boot-starter/build.gradle

@@ -2,5 +2,5 @@ dependencies {
     compile project(":mybatis-plus")
     compile rootProject.ext.dependencies["springboot-autoconfigure"]
     compile rootProject.ext.dependencies["springboot-starter-jdbc"]
-    optional rootProject.ext.dependencies["springboot-configuration-processor"]
+    compile rootProject.ext.dependencies["springboot-configuration-processor"], optional
 }

+ 28 - 28
mybatis-plus-core/build.gradle

@@ -1,30 +1,30 @@
 dependencies {
-	compile project(":mybatis-plus-support")
-	compile rootProject.ext.dependencies["jsqlparser"]
-	compile rootProject.ext.dependencies["mybatis-spring"]
-	compile rootProject.ext.dependencies["mybatis"]
-	optional rootProject.ext.dependencies["spring-context-support"]
-	optional rootProject.ext.dependencies["spring-jdbc"]
-	testCompile rootProject.ext.dependencies["servlet-api"]
-	testCompile rootProject.ext.dependencies["mybatis-ehcache"]
-	testCompile rootProject.ext.dependencies["logback-classic"]
-	testCompile rootProject.ext.dependencies["junit"]
-	testCompile (rootProject.ext.dependencies["commons-dbcp2"]){
-		exclude module: "commons-logging"
-	}
-	testCompile rootProject.ext.dependencies["sqlserver"]
-	testCompile rootProject.ext.dependencies["postgresql"]
-	testCompile rootProject.ext.dependencies["oracle"]
-	testCompile rootProject.ext.dependencies["h2"]
-	testCompile rootProject.ext.dependencies["mysql"]
-	testCompile rootProject.ext.dependencies["slf4j-api"]
-	testCompile rootProject.ext.dependencies["spring-test"]
-	testCompile rootProject.ext.dependencies["spring-webmvc"]
-	testCompile rootProject.ext.dependencies["sqlserver"]
-	testCompile rootProject.ext.dependencies["aspectjweaver"]
-	testCompile rootProject.ext.dependencies["lombok"]
-	testCompile rootProject.ext.dependencies["hikaricp"]
-	testCompile rootProject.ext.dependencies["druid"]
-	testCompile rootProject.ext.dependencies["fastjson"]
-	testCompile rootProject.ext.dependencies["tomcatjdbc"]
+    compile project(":mybatis-plus-support")
+    compile rootProject.ext.dependencies["jsqlparser"]
+    compile rootProject.ext.dependencies["mybatis-spring"]
+    compile rootProject.ext.dependencies["mybatis"]
+    compile rootProject.ext.dependencies["spring-context-support"], optional
+    compile rootProject.ext.dependencies["spring-jdbc"], optional
+    testCompile rootProject.ext.dependencies["servlet-api"]
+    testCompile rootProject.ext.dependencies["mybatis-ehcache"]
+    testCompile rootProject.ext.dependencies["logback-classic"]
+    testCompile rootProject.ext.dependencies["junit"]
+    testCompile(rootProject.ext.dependencies["commons-dbcp2"]) {
+        exclude module: "commons-logging"
+    }
+    testCompile rootProject.ext.dependencies["sqlserver"]
+    testCompile rootProject.ext.dependencies["postgresql"]
+    testCompile rootProject.ext.dependencies["oracle"]
+    testCompile rootProject.ext.dependencies["h2"]
+    testCompile rootProject.ext.dependencies["mysql"]
+    testCompile rootProject.ext.dependencies["slf4j-api"]
+    testCompile rootProject.ext.dependencies["spring-test"]
+    testCompile rootProject.ext.dependencies["spring-webmvc"]
+    testCompile rootProject.ext.dependencies["sqlserver"]
+    testCompile rootProject.ext.dependencies["aspectjweaver"]
+    testCompile rootProject.ext.dependencies["lombok"]
+    testCompile rootProject.ext.dependencies["hikaricp"]
+    testCompile rootProject.ext.dependencies["druid"]
+    testCompile rootProject.ext.dependencies["fastjson"]
+    testCompile rootProject.ext.dependencies["tomcatjdbc"]
 }

+ 10 - 10
mybatis-plus-generate/build.gradle

@@ -1,12 +1,12 @@
 dependencies {
-	compile project(":mybatis-plus-support")
-	optional rootProject.ext.dependencies["velocity"]
-    optional rootProject.ext.dependencies["freemarker"]
-	testCompile rootProject.ext.dependencies["sqlserver"]
-	testCompile rootProject.ext.dependencies["postgresql"]
-	testCompile rootProject.ext.dependencies["oracle"]
-	testCompile rootProject.ext.dependencies["h2"]
-	testCompile rootProject.ext.dependencies["mysql"]
-	testCompile rootProject.ext.dependencies["logback-classic"]
-	testCompile rootProject.ext.dependencies["junit"]
+    compile project(":mybatis-plus-support")
+    compile rootProject.ext.dependencies["velocity"], optional
+    compile rootProject.ext.dependencies["freemarker"], optional
+    testCompile rootProject.ext.dependencies["sqlserver"]
+    testCompile rootProject.ext.dependencies["postgresql"]
+    testCompile rootProject.ext.dependencies["oracle"]
+    testCompile rootProject.ext.dependencies["h2"]
+    testCompile rootProject.ext.dependencies["mysql"]
+    testCompile rootProject.ext.dependencies["logback-classic"]
+    testCompile rootProject.ext.dependencies["junit"]
 }

+ 4 - 4
mybatis-plus-support/build.gradle

@@ -1,6 +1,6 @@
 dependencies {
-	optional rootProject.ext.dependencies["mybatis-spring"]
-	optional rootProject.ext.dependencies["mybatis"]
-	optional rootProject.ext.dependencies["spring-context-support"]
-	optional rootProject.ext.dependencies["spring-jdbc"]
+    compile rootProject.ext.dependencies["mybatis-spring"], optional
+    compile rootProject.ext.dependencies["mybatis"], optional
+    compile rootProject.ext.dependencies["spring-context-support"], optional
+    compile rootProject.ext.dependencies["spring-jdbc"], optional
 }

+ 0 - 1
settings.gradle

@@ -4,5 +4,4 @@ include 'mybatis-plus-support'
 include 'mybatis-plus-core'
 include 'mybatis-plus-generate'
 include 'mybatis-plus-boot-starter'
-include 'buildSrc'