mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-11-03 20:27:50 +00:00 
			
		
		
		
	Co-authored-by: Hendrik Richert <hendrik.richert@swisscom.com> Co-authored-by: david-leifker <114954101+david-leifker@users.noreply.github.com>
		
			
				
	
	
		
			86 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Groovy
		
	
	
	
	
	
			
		
		
	
	
			86 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Groovy
		
	
	
	
	
	
import org.yaml.snakeyaml.Yaml
 | 
						|
 | 
						|
buildscript {
 | 
						|
    repositories{
 | 
						|
        if (project.hasProperty('apacheMavenRepositoryUrl')) {
 | 
						|
            maven { url project.getProperty('apacheMavenRepositoryUrl') }
 | 
						|
        } else {
 | 
						|
            mavenCentral()
 | 
						|
        }
 | 
						|
    }
 | 
						|
    dependencies {
 | 
						|
        classpath("org.yaml:snakeyaml:1.33")
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
plugins {
 | 
						|
    id 'base'
 | 
						|
}
 | 
						|
apply plugin: 'pegasus'
 | 
						|
 | 
						|
 | 
						|
if (project.hasProperty('projVersion')) {
 | 
						|
  project.version = project.projVersion
 | 
						|
} else {
 | 
						|
  project.version = '0.0.0-dev'
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
dependencies {
 | 
						|
  implementation spec.product.pegasus.data
 | 
						|
  // Uncomment these if you want to depend on models defined in core datahub
 | 
						|
  //implementation project(':li-utils')
 | 
						|
  //dataModel project(':li-utils')
 | 
						|
  //implementation project(':metadata-models')
 | 
						|
  //dataModel project(':metadata-models')
 | 
						|
 | 
						|
}
 | 
						|
//def deployBaseDir = findProperty('pluginModelsDir') ?: file(project.gradle.gradleUserHomeDir.parent + "/.datahub/plugins/models")
 | 
						|
def deployBaseDir = file(layout.buildDirectory.dir("plugins/models"))
 | 
						|
 | 
						|
mainAvroSchemaJar.dependsOn generateAvroSchema
 | 
						|
 | 
						|
pegasus.main.generationModes = [PegasusGenerationMode.PEGASUS, PegasusGenerationMode.AVRO]
 | 
						|
 | 
						|
 | 
						|
task modelArtifact(type: Zip) {
 | 
						|
 | 
						|
    from(layout.buildDirectory.dir("libs")) {
 | 
						|
        include "*-data-template-*.jar"
 | 
						|
        exclude "*-test-data-template-*.jar"
 | 
						|
        into "libs"
 | 
						|
    }
 | 
						|
    from(layout.projectDirectory.dir("registry")) {
 | 
						|
        include "*.yml", "*.yaml"
 | 
						|
    }
 | 
						|
    
 | 
						|
    destinationDirectory = layout.buildDirectory.dir("dist")
 | 
						|
}
 | 
						|
 | 
						|
modelArtifact.dependsOn build
 | 
						|
task modelDeploy(type: Copy) {
 | 
						|
    def registryDir = layout.projectDirectory.dir("registry")
 | 
						|
    def cfg = new Yaml().load(new File("$registryDir/entity-registry.yaml").newInputStream())
 | 
						|
    def outputBaseName = cfg.id ? cfg.id : project.name
 | 
						|
    def zipFile = file("build/dist/${project.name}-${version}.zip")
 | 
						|
    logger.info("Zip file is $zipFile")
 | 
						|
    def outputDir = "$deployBaseDir/${outputBaseName}/$version"
 | 
						|
    from zipTree(zipFile)
 | 
						|
    into outputDir
 | 
						|
}
 | 
						|
 | 
						|
modelDeploy.dependsOn modelArtifact
 | 
						|
 | 
						|
configurations {
 | 
						|
    builtModels {
 | 
						|
        canBeConsumed = true
 | 
						|
        canBeResolved = false
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
//artifacts {
 | 
						|
//   builtModels(modelArtifact)
 | 
						|
//}
 | 
						|
 | 
						|
 |