All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.edmunds.tools.databricks.maven.UpsertClusterMojoNoProject Maven / Gradle / Ivy

There is a newer version: 1.13.1
Show newest version
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;
        };
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy