GitBucket
4.23.0
Toggle navigation
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
yn-bftl-byx
/
common
Browse code
修改地址
master
1 parent
313565a
commit
ec0d33a9a8c3ce3c31253df5dd8c81e1dc087f47
steven
authored
on 18 Dec
Patch
Showing
1 changed file
build.gradle
Ignore Space
Show notes
View
build.gradle
import java.text.SimpleDateFormat plugins { id 'org.springframework.boot' version '2.4.5' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' id 'maven' } // 是否存在参数 def isParameter = project.hasProperty('profile') group = 'com.yn' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8' def artifactId = isParameter ? "yn-byx-common-".concat("$profile") : "yn-byx-common" repositories { mavenLocal() mavenCentral() maven { url 'https://plugins.gradle.org/m2/' } maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } } dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-data-elasticsearch' // implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' implementation group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final' implementation group: 'io.springfox', name: 'springfox-swagger2', version: "2.7.0" implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0' } test { useJUnitPlatform() } jar { manifest { attributes( "Manifest-Version": 1.0, 'Pack-Person': getUserName(), 'Package-Time': getCurrentTime(), 'Git-Branch': getGitBranch(), 'Git-CommitId': gitCommitId(), 'Commit-Description': gitCommitDescription() ) } enabled = true } //打包源代码 task sourcesJar(type: Jar, dependsOn: classes) { archiveBaseName = "$artifactId" archiveClassifier = 'sources' from sourceSets.main.allSource } // 获取最新提交的记录的commitId def gitCommitId() { try { def commit = 'git rev-parse HEAD'.execute([], project.rootDir).text.trim() return commit ?: 'unknown' } catch (Exception e) { System.err.println("fail to get commit id, errMsg:" + e.getMessage()) return 'unknown' } } // 获取最新提交的记录的描述 def gitCommitDescription() { try { def commit = 'git log -1 --pretty=format:"%s"'.execute([], project.rootDir).text.trim() return commit ?: 'unknown' } catch (Exception e) { System.err.println("fail to get CommitDescription, errMsg:" + e.getMessage()) return 'unknown' } } // 获取当前分支名称 def getGitBranch() { try { def commit = 'git rev-parse --abbrev-ref HEAD'.execute([], project.rootDir).text.trim() return commit ?: 'unknown' } catch (Exception e) { System.err.println("fail to get Branch, errMsg:" + e.getMessage()) return 'unknown' } } // 获取当前用户 static def getUserName() { return 'git config user.name'.execute().text.trim() } // 获取当前时间 static def getCurrentTime() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) } artifacts { archives sourcesJar } install { repositories.mavenInstaller { pom.version = "$project.version" pom.artifactId = "$artifactId" pom.groupId = "$project.group" } } //上传到nexus uploadArchives { repositories { mavenDeployer { repository(url: "http://47.112.165.126:8889/nexus/content/repositories/snapshots") { authentication(userName: "admin", password: "admin123") } pom.version = "$project.version" pom.artifactId = "$artifactId" pom.groupId = "$project.group" } } }
import java.text.SimpleDateFormat plugins { id 'org.springframework.boot' version '2.4.5' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' id 'maven' } // 是否存在参数 def isParameter = project.hasProperty('profile') group = 'com.yn' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8' def artifactId = isParameter ? "yn-byx-common-".concat("$profile") : "yn-byx-common" repositories { mavenLocal() mavenCentral() maven { url 'https://plugins.gradle.org/m2/' } maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } } dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-data-elasticsearch' // implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' implementation group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final' implementation group: 'io.springfox', name: 'springfox-swagger2', version: "2.7.0" implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0' } test { useJUnitPlatform() } jar { manifest { attributes( "Manifest-Version": 1.0, 'Pack-Person': getUserName(), 'Package-Time': getCurrentTime(), 'Git-Branch': getGitBranch(), 'Git-CommitId': gitCommitId(), 'Commit-Description': gitCommitDescription() ) } enabled = true } //打包源代码 task sourcesJar(type: Jar, dependsOn: classes) { archiveBaseName = "$artifactId" archiveClassifier = 'sources' from sourceSets.main.allSource } // 获取最新提交的记录的commitId def gitCommitId() { try { def commit = 'git rev-parse HEAD'.execute([], project.rootDir).text.trim() return commit ?: 'unknown' } catch (Exception e) { System.err.println("fail to get commit id, errMsg:" + e.getMessage()) return 'unknown' } } // 获取最新提交的记录的描述 def gitCommitDescription() { try { def commit = 'git log -1 --pretty=format:"%s"'.execute([], project.rootDir).text.trim() return commit ?: 'unknown' } catch (Exception e) { System.err.println("fail to get CommitDescription, errMsg:" + e.getMessage()) return 'unknown' } } // 获取当前分支名称 def getGitBranch() { try { def commit = 'git rev-parse --abbrev-ref HEAD'.execute([], project.rootDir).text.trim() return commit ?: 'unknown' } catch (Exception e) { System.err.println("fail to get Branch, errMsg:" + e.getMessage()) return 'unknown' } } // 获取当前用户 static def getUserName() { return 'git config user.name'.execute().text.trim() } // 获取当前时间 static def getCurrentTime() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) } artifacts { archives sourcesJar } install { repositories.mavenInstaller { pom.version = "$project.version" pom.artifactId = "$artifactId" pom.groupId = "$project.group" } } //上传到nexus uploadArchives { repositories { mavenDeployer { repository(url: "http://120.76.99.226:8889/nexus/content/repositories/snapshots") { authentication(userName: "admin", password: "admin123") } pom.version = "$project.version" pom.artifactId = "$artifactId" pom.groupId = "$project.group" } } }
Show line notes below