com.edmunds.tools.databricks.maven.UpsertClusterMojoNoProject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of databricks-maven-plugin Show documentation
Show all versions of databricks-maven-plugin Show documentation
A databricks maven plugin to automate databricks deployments as part of a build
package com.edmunds.tools.databricks.maven;
import com.edmunds.tools.databricks.maven.model.EnvironmentDTO;
import com.edmunds.tools.databricks.maven.util.EnvironmentDTOSupplier;
import java.io.File;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
/**
* Cluster mojo, to perform databricks cluster upsert (create or update through recreation).
* NoProject mojo has been extracted into a separate class
* so we have both mojos for non-project execution and for multi-module projects.
*/
@Mojo(name = "upsert-cluster-np", requiresProject = false)
public class UpsertClusterMojoNoProject extends UpsertClusterMojo {
/**
* The serialized environment dto is required to be passed in a NoProject scenario.
*/
@Parameter(name = "environmentDTOFile", property = "environmentDTOFile", required = true)
private File environmentDTOFile;
@Override
protected EnvironmentDTOSupplier getEnvironmentDTOSupplier() {
return () -> {
EnvironmentDTO serializedEnvironment = EnvironmentDTO.loadEnvironmentDTOFromFile(environmentDTOFile);
//We now set properties that are based on runtime and not buildtime. Ideally this would be enforced.
//I consider this code ugly
if (environment != null) {
serializedEnvironment.setEnvironment(environment);
}
return serializedEnvironment;
};
}
}