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

com.github.stephanenicolas.ormgap.CreateOrmLiteConfigAction Maven / Gradle / Ivy

Go to download

A Gradle plugin for Android to generate an ORMLite configuration file and boost DAOs creations.

There is a newer version: 3.0.5
Show newest version
package com.github.stephanenicolas.ormgap;

import java.io.File;
import java.io.IOException;
import org.gradle.api.logging.Logger;

/**
 * Create the ORM Lite config file.
 * Allows to fully test the task.
 *
 * @author SNI.
 */
public class CreateOrmLiteConfigAction {
    private final File configFile;
    private File searchDir;
    private String classpath;
    private Logger logger;

    public CreateOrmLiteConfigAction(File configFile,
                                     File searchDir,
                                     String classpath,
                                     Logger logger) {
        this.configFile = configFile;
        this.searchDir = searchDir;
        this.classpath = classpath;
        this.logger = logger;
    }

    public void execute() throws IOException, InterruptedException {
        ProcessBuilder builder
            = new ProcessBuilder("java",
                                 "-cp",
                                 classpath,
                                 "com.github.stephanenicolas.ormgap.OrmLiteConfigUtil",
                                 configFile.getAbsolutePath(),
                                 searchDir.getAbsolutePath());

        logger.debug("Generating ORMLite Config file using command line: " + builder.command());
        builder
            .inheritIO()
            .directory(searchDir);
        final int result = builder.start().waitFor();
        if (result != 0) {
            throw new RuntimeException("OrmLiteConfigUtil finished with code: " + result);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy