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

com.sysgears.grain.gradle.GrainPlugin.groovy Maven / Gradle / Ivy

Go to download

Gradle plugin for Grain general purpose static site generator which provides all the modern features and tools for generating any kind of HTML content.

There is a newer version: 0.2.1
Show newest version
package com.sysgears.grain.gradle

import com.sysgears.grain.gradle.handlers.ConfigurationHandler
import com.sysgears.grain.gradle.handlers.DependencyHandler
import com.sysgears.grain.gradle.handlers.GrainTaskHandler
import com.sysgears.grain.gradle.helpers.GrainEnvironment
import org.gradle.api.Plugin
import org.gradle.api.Project

/**
 * Grain Gradle plugin implementation.
 */
class GrainPlugin implements Plugin {

    void apply(Project project) {

        def configuration = project.extensions.create('grain', GrainPluginExtension)

        configuration.onSetProjectDir {
            new GrainTaskHandler(project).with {
                grainGenerate description: 'Runs Grain generate command.', command: 'generate'
                grainPreview description: 'Runs Grain preview command.', command: 'preview'
                grainDeploy description: 'Runs Grain deploy command.', command: 'deploy'
                grainClean description: 'Runs Grain clean command.', command: 'clean'
            }

            def grainVersion = GrainEnvironment.lookUpProperty(project, 'grain.version', '')

            if (grainVersion) {
                new DependencyHandler(project).with {
                    grain "com.sysgears.grain:grain:$grainVersion"
                }

                new ConfigurationHandler(project, 'grain').with {
                    exclude group: 'rhino'
                    exclude group: 'commons-logging'
                }
            } else {
                project.logger.error("Error: Unable to find Grain project in the [$configuration.projectDir] directory.")
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy