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

io.opencaesar.owl.fuseki.StopFusekiTask Maven / Gradle / Ivy

The newest version!
package io.opencaesar.owl.fuseki;

import java.util.ArrayList;

import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputDirectory;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.TaskAction;

/**
 * Gradle task for stopping an Apache Fuseki server by killing the process based on the fuseki pid file.
 */
public abstract class StopFusekiTask extends DefaultTask {

	/**
	 * Creates a new StopFusekiTask object.
	 */
	public StopFusekiTask() {
	}
	
    /**
     * The required gradle task output folder property.
     * 
     * @return DirectoryProperty
     */
    @InputDirectory
    public abstract DirectoryProperty getOutputFolderPath();

    /**
     * The optional gradle task debug property (default is false).
     * 
     * @return Boolean Property
     */
    @Optional
    @Input
    public abstract Property getDebug();

    /**
     * The gradle task action logic.
     */
    @SuppressWarnings({ "deprecation" })
    @TaskAction
    public void run() {
        final ArrayList args = new ArrayList<>();
        args.add("-c");
        args.add(FusekiApp.Command.stop.toString());
        if (getOutputFolderPath().isPresent()) {
            args.add("-o");
            args.add(getOutputFolderPath().get().getAsFile().getAbsolutePath());
        }
        if (getDebug().isPresent() && getDebug().get()) {
            args.add("-d");
        }
        try {
        	FusekiApp.main(args.toArray(new String[0]));
        } catch (Exception e) {
			throw new GradleException(e.getLocalizedMessage(), e);
        }
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy