Search in sources :

Example 1 with ForkedGrailsRuntime

use of org.grails.maven.plugin.tools.ForkedGrailsRuntime in project grails-maven by grails.

the class AbstractGrailsMojo method runGrails.

/**
 * Executes the requested Grails target.  The "targetName" must match a known
 * Grails script provided by grails-scripts.
 *
 * @param targetName The name of the Grails target to execute.
 * @param args       String of arguments to be passed to the executed Grails target.
 * @throws MojoExecutionException if an error occurs while attempting to execute the target.
 */
protected void runGrails(final String targetName, String args) throws MojoExecutionException {
    configureMavenProxy();
    handleVersionSync();
    if (fork) {
        ForkedGrailsRuntime fgr = new ForkedGrailsRuntime(createExecutionContext(targetName, args));
        if (activateAgent) {
            File springLoadedJar = resolveArtifact("org.springframework:springloaded:" + SPRING_LOADED_VERSION);
            if (springLoadedJar != null) {
                fgr.setReloadingAgent(springLoadedJar);
            } else {
                getLog().warn("Grails Reloading: org.springframework:springloaded:" + SPRING_LOADED_VERSION + " not found");
                getLog().error("Grails Reloading: not enabled");
            }
        }
        fgr.setDebug(forkDebug);
        fgr.setMaxMemory(forkMaxMemory);
        fgr.setMaxPerm(forkPermGen);
        fgr.setMinMemory(forkMinMemory);
        try {
            fgr.run();
        } catch (Exception e) {
            throw new RuntimeException("Error forking vm: ", e);
        }
    } else {
        DefaultGrailsRuntime dgr = new DefaultGrailsRuntime(createExecutionContext(targetName, args));
        dgr.run();
    }
}
Also used : DefaultGrailsRuntime(org.grails.maven.plugin.tools.DefaultGrailsRuntime) File(java.io.File) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ForkedGrailsRuntime(org.grails.maven.plugin.tools.ForkedGrailsRuntime)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)1 DefaultGrailsRuntime (org.grails.maven.plugin.tools.DefaultGrailsRuntime)1 ForkedGrailsRuntime (org.grails.maven.plugin.tools.ForkedGrailsRuntime)1