| 
									
										
										
										
											2022-01-25 21:52:47 -08:00
										 |  |  | plugins { | 
					
						
							|  |  |  |     id("com.palantir.git-version") apply false | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-01-02 22:48:38 +05:30
										 |  |  | apply plugin: 'java' | 
					
						
							|  |  |  | apply plugin: 'com.github.johnrengelman.shadow' | 
					
						
							| 
									
										
										
										
											2022-01-04 01:41:09 -08:00
										 |  |  | apply plugin: 'jacoco' | 
					
						
							| 
									
										
										
										
											2022-01-20 00:48:09 -08:00
										 |  |  | apply plugin: 'signing' | 
					
						
							|  |  |  | apply plugin: 'io.codearte.nexus-staging' | 
					
						
							|  |  |  | apply plugin: 'maven-publish' | 
					
						
							|  |  |  | import org.apache.tools.ant.filters.ReplaceTokens | 
					
						
							| 
									
										
										
										
											2022-01-02 22:48:38 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-11 14:55:21 -08:00
										 |  |  | jar.enabled = false // Since we only want to build shadow jars, disabling the regular jar creation
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-02 22:48:38 +05:30
										 |  |  | dependencies { | 
					
						
							|  |  |  |     | 
					
						
							| 
									
										
										
										
											2022-01-11 14:55:21 -08:00
										 |  |  |     implementation project(':metadata-models') | 
					
						
							|  |  |  |     shadow externalDependency.httpAsyncClient // we want our clients to provide this
 | 
					
						
							|  |  |  |     implementation externalDependency.jacksonDataBind  | 
					
						
							| 
									
										
										
										
											2022-01-02 22:48:38 +05:30
										 |  |  |     compileOnly externalDependency.lombok | 
					
						
							|  |  |  |     annotationProcessor externalDependency.lombok | 
					
						
							| 
									
										
										
										
											2022-01-11 14:55:21 -08:00
										 |  |  |     testCompile externalDependency.httpAsyncClient // needed as shadow excludes it
 | 
					
						
							| 
									
										
										
										
											2022-01-02 22:48:38 +05:30
										 |  |  |     testCompile externalDependency.mockito | 
					
						
							|  |  |  |     testCompile externalDependency.mockServer | 
					
						
							|  |  |  |     testCompile externalDependency.mockServerClient | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-04 01:41:09 -08:00
										 |  |  | jacocoTestReport { | 
					
						
							|  |  |  |     dependsOn test // tests are required to run before generating the report
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-20 00:48:09 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-25 21:52:47 -08:00
										 |  |  | def detailedVersionString = "0.0.0-unknown-SNAPSHOT" | 
					
						
							|  |  |  | def snapshotVersion = false | 
					
						
							|  |  |  | if (project.hasProperty("releaseVersion")) { | 
					
						
							|  |  |  |   version = releaseVersion | 
					
						
							|  |  |  |   detailedVersionString = releaseVersion | 
					
						
							|  |  |  | } else { | 
					
						
							|  |  |  |   try { | 
					
						
							|  |  |  |       // apply this plugin in a try-catch block so that we can handle cases without .git directory
 | 
					
						
							|  |  |  |       apply plugin: "com.palantir.git-version" | 
					
						
							|  |  |  |       println("In else section") | 
					
						
							|  |  |  |       def details = versionDetails() | 
					
						
							|  |  |  |       detailedVersionString = gitVersion() | 
					
						
							|  |  |  |       version = details.lastTag | 
					
						
							|  |  |  |       version = version.startsWith("v")? version.substring(1): version | 
					
						
							|  |  |  |       def suffix = details.isCleanTag? "": "-SNAPSHOT" | 
					
						
							|  |  |  |       snapshotVersion = ! details.isCleanTag | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     catch (Exception e) { | 
					
						
							|  |  |  |           e.printStackTrace() | 
					
						
							|  |  |  |           // last fall back
 | 
					
						
							|  |  |  |           version = detailedVersionString | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |     // trim version if it is of size 4 to size 3
 | 
					
						
							|  |  |  |     def versionParts = version.tokenize(".") | 
					
						
							|  |  |  |     if (versionParts.size() > 3) { | 
					
						
							|  |  |  |       // at-least 4 part version
 | 
					
						
							|  |  |  |       // we check if the 4th part is a .0 in which case we want to create a release
 | 
					
						
							|  |  |  |       if (versionParts[3] != '0') { | 
					
						
							|  |  |  |         snapshotVersion = true | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       versionParts = versionParts[0..2] | 
					
						
							|  |  |  |       version = versionParts[0..2].join('.') | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-01-20 00:48:09 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-25 21:52:47 -08:00
										 |  |  |     if (snapshotVersion) { | 
					
						
							|  |  |  |         if (versionParts[versionParts.size()-1].isInteger()) { | 
					
						
							|  |  |  |           version = versionParts[0..versionParts.size()-2].join('.') + '.' + (versionParts[versionParts.size()-1].toInteger()+1).toString() + "-SNAPSHOT" | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           // we are unable to part the last token as an integer, so we just append SNAPSHOT to this version
 | 
					
						
							|  |  |  |           version = versionParts[0..versionParts.size()-1].join('.') + '-SNAPSHOT' | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |     processResources { | 
					
						
							|  |  |  |       filter(ReplaceTokens, tokens:[fullVersion: detailedVersionString]) | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-01-20 00:48:09 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-02 22:48:38 +05:30
										 |  |  | test { | 
					
						
							|  |  |  |   useJUnit() | 
					
						
							| 
									
										
										
										
											2022-01-04 01:41:09 -08:00
										 |  |  |   finalizedBy jacocoTestReport | 
					
						
							| 
									
										
										
										
											2022-01-02 22:48:38 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-11 14:55:21 -08:00
										 |  |  | task checkShadowJar(type: Exec) {  | 
					
						
							|  |  |  |    commandLine 'sh', '-c', 'scripts/check_jar.sh' | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-02 22:48:38 +05:30
										 |  |  | shadowJar { | 
					
						
							|  |  |  |   zip64=true | 
					
						
							| 
									
										
										
										
											2022-01-11 14:55:21 -08:00
										 |  |  |   archiveClassifier = '' | 
					
						
							|  |  |  |   dependencies { | 
					
						
							|  |  |  |     exclude(dependency('org.apache.httpcomponents:httpasyncclient')) | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   mergeServiceFiles() | 
					
						
							|  |  |  |   // we relocate namespaces manually, because we want to know exactly which libs we are exposing and why
 | 
					
						
							|  |  |  |   // we can move to automatic relocation using ConfigureShadowRelocation after we get to a good place on these first
 | 
					
						
							|  |  |  |   relocate 'com.fasterxml.jackson', 'datahub.shaded.jackson' | 
					
						
							|  |  |  |   relocate 'net.jcip.annotations', 'datahub.shaded.annotations' | 
					
						
							|  |  |  |   relocate 'javassist', 'datahub.shaded.javassist' | 
					
						
							|  |  |  |   relocate 'edu.umd.cs.findbugs', 'datahub.shaded.findbugs' | 
					
						
							|  |  |  |   relocate 'org.antlr', 'datahub.shaded.org.antlr' | 
					
						
							|  |  |  |   relocate 'antlr', 'datahub.shaded.antlr' | 
					
						
							|  |  |  |   relocate 'com.google.common', 'datahub.shaded.com.google.common' | 
					
						
							|  |  |  |   relocate 'org.apache.commons', 'datahub.shaded.org.apache.commons' | 
					
						
							|  |  |  |   relocate 'org.reflections', 'datahub.shaded.org.reflections' | 
					
						
							|  |  |  |   relocate 'st4hidden', 'datahub.shaded.st4hidden' | 
					
						
							|  |  |  |   relocate 'org.stringtemplate', 'datahub.shaded.org.stringtemplate' | 
					
						
							|  |  |  |   relocate 'org.abego.treelayout', 'datahub.shaded.treelayout' | 
					
						
							|  |  |  |   relocate 'org.slf4j', 'datahub.shaded.slf4j' | 
					
						
							|  |  |  |   relocate 'javax.annotation', 'datahub.shaded.javax.annotation' | 
					
						
							|  |  |  |   finalizedBy checkShadowJar | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | checkShadowJar { | 
					
						
							|  |  |  |    dependsOn shadowJar | 
					
						
							| 
									
										
										
										
											2022-01-02 22:48:38 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | assemble { | 
					
						
							|  |  |  |     dependsOn shadowJar | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-01-20 00:48:09 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | task sourcesJar(type: Jar) { | 
					
						
							|  |  |  |      archiveClassifier = 'sources' | 
					
						
							|  |  |  |      from sourceSets.main.allSource | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task javadocJar(type: Jar) { | 
					
						
							|  |  |  |     archiveClassifier = 'javadoc'   | 
					
						
							|  |  |  |     from javadoc | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | publishing { | 
					
						
							|  |  |  |   publications { | 
					
						
							|  |  |  |     shadow(MavenPublication) { | 
					
						
							|  |  |  |       publication -> project.shadow.component(publication) | 
					
						
							|  |  |  |       pom { | 
					
						
							|  |  |  |         name = 'Datahub Client' | 
					
						
							|  |  |  |         group = 'io.acryl' | 
					
						
							|  |  |  |         artifactId = 'datahub-client' | 
					
						
							|  |  |  |         description = 'DataHub Java client for metadata integration' | 
					
						
							|  |  |  |         url = 'https://datahubproject.io' | 
					
						
							|  |  |  |         artifacts = [ shadowJar, javadocJar, sourcesJar ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         scm { | 
					
						
							|  |  |  |           connection = 'scm:git:git://github.com/linkedin/datahub.git' | 
					
						
							|  |  |  |           developerConnection = 'scm:git:ssh://github.com:linkedin/datahub.git' | 
					
						
							|  |  |  |           url = 'https://github.com/linkedin/datahub.git' | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         licenses { | 
					
						
							|  |  |  |           license { | 
					
						
							|  |  |  |             name = 'The Apache License, Version 2.0' | 
					
						
							|  |  |  |             url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         developers { | 
					
						
							|  |  |  |           developer { | 
					
						
							|  |  |  |             id = 'datahub' | 
					
						
							|  |  |  |             name = 'Datahub' | 
					
						
							|  |  |  |             email = 'datahub@acryl.io' | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   repositories { | 
					
						
							|  |  |  |     maven { | 
					
						
							|  |  |  |       def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" | 
					
						
							|  |  |  |       def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" | 
					
						
							|  |  |  |       def ossrhUsername = System.getenv('RELEASE_USERNAME') | 
					
						
							|  |  |  |       def ossrhPassword = System.getenv('RELEASE_PASSWORD') | 
					
						
							|  |  |  |       credentials { | 
					
						
							|  |  |  |         username ossrhUsername | 
					
						
							|  |  |  |         password ossrhPassword | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | signing { | 
					
						
							|  |  |  |     def signingKey = findProperty("signingKey") | 
					
						
							|  |  |  |     def signingPassword = System.getenv("SIGNING_PASSWORD") | 
					
						
							|  |  |  |     useInMemoryPgpKeys(signingKey, signingPassword) | 
					
						
							|  |  |  |     sign publishing.publications.shadow | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | nexusStaging { | 
					
						
							|  |  |  |     serverUrl = "https://s01.oss.sonatype.org/service/local/" //required only for projects registered in Sonatype after 2021-02-24
 | 
					
						
							|  |  |  |     username = System.getenv("NEXUS_USERNAME") | 
					
						
							|  |  |  |     password = System.getenv("NEXUS_PASSWORD") | 
					
						
							|  |  |  | } |