<commit_before>/*
 * Copyright 2008-2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.codehaus.griffon.gradle

import org.apache.tools.ant.filters.ReplaceTokens
import org.gradle.BuildAdapter
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.invocation.Gradle
import org.gradle.api.tasks.Copy
import org.gradle.tooling.BuildException

/**
 * @author <NAME>
 */
class GriffonPlugin implements Plugin<Project> {
    private static final boolean MACOSX = System.getProperty('os.name').contains('Mac OS')

    @Override
    void apply(Project project) {
        GriffonExtension extension = project.extensions.create('griffon', GriffonExtension, project)

        applyDefaultPlugins(project)

        applyDefaultDependencies(project)

        String sourceSetName = project.plugins.hasPlugin('groovy') ? 'groovy' : 'java'

        configureDefaultSourceSets(project, 'java')
        if (sourceSetName != 'java') configureDefaultSourceSets(project, sourceSetName)
        adjustJavadocClasspath(project, sourceSetName)
        createDefaultDirectoryStructure(project, 'java')
        if (sourceSetName != 'java') createDefaultDirectoryStructure(project, sourceSetName)

        registerBuildListener(project, extension)
    }

    private void applyDefaultDependencies(final Project project) {
        project.configurations.maybeCreate('griffon').visible = true
        GriffonPluginResolutionStrategy.applyTo(project)
    }

    private void applyDefaultPlugins(Project project) {
        project.apply(plugin: 'idea')
        project.apply(plugin: 'java')
        if (!project.hasProperty('griffonPlugin') || !project.griffonPlugin) {
            project.apply(plugin: 'application')
        }
    }

    private void adjustJavadocClasspath(Project project, String sourceSetName) {
        project.javadoc.classpath += project.configurations.compileOnly
        if (sourceSetName == 'groovy') {
            project.groovydoc.classpath += project.configurations.compileOnly
        }
    }

    private void configureDefaultSourceSets(Project project, String sourceSetName) {
        // configure default source directories
        project.sourceSets.main[sourceSetName].srcDirs += [
            'griffon-app/conf',
            'griffon-app/controllers',
            'griffon-app/models',
            'griffon-app/views',
            'griffon-app/services',
            'griffon-app/lifecycle',
            'src/main/' + sourceSetName
        ]
        // configure default resource directories
        project.sourceSets.main.resources.srcDirs += [
            'griffon-app/resources',
            'griffon-app/i18n',
            'src/main/resources'
        ]<commit_msg>CompileOnly should be automatically handled by Gradle 2.12+. Relates to #159<commit_after>/*
 * Copyright 2008-2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.codehaus.griffon.gradle

import org.apache.tools.ant.filters.ReplaceTokens
import org.gradle.BuildAdapter
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.invocation.Gradle
import org.gradle.api.tasks.Copy
import org.gradle.tooling.BuildException

/**
 * @author <NAME>
 */
class GriffonPlugin implements Plugin<Project> {
    private static final boolean MACOSX = System.getProperty('os.name').contains('Mac OS')

    @Override
    void apply(Project project) {
        GriffonExtension extension = project.extensions.create('griffon', GriffonExtension, project)

        applyDefaultPlugins(project)

        applyDefaultDependencies(project)

        String sourceSetName = project.plugins.hasPlugin('groovy') ? 'groovy' : 'java'

        configureDefaultSourceSets(project, 'java')
        if (sourceSetName != 'java') configureDefaultSourceSets(project, sourceSetName)
        createDefaultDirectoryStructure(project, 'java')
        if (sourceSetName != 'java') createDefaultDirectoryStructure(project, sourceSetName)

        registerBuildListener(project, extension)
    }

    private void applyDefaultDependencies(final Project project) {
        project.configurations.maybeCreate('griffon').visible = true
        GriffonPluginResolutionStrategy.applyTo(project)
    }

    private void applyDefaultPlugins(Project project) {
        project.apply(plugin: 'idea')
        project.apply(plugin: 'java')
        if (!project.hasProperty('griffonPlugin') || !project.griffonPlugin) {
            project.apply(plugin: 'application')
        }
    }

    private void configureDefaultSourceSets(Project project, String sourceSetName) {
        // configure default source directories
        project.sourceSets.main[sourceSetName].srcDirs += [
            'griffon-app/conf',
            'griffon-app/controllers',
            'griffon-app/models',
            'griffon-app/views',
            'griffon-app/services',
            'griffon-app/lifecycle',
            'src/main/' + sourceSetName
        ]
        // configure default resource directories
        project.sourceSets.main.resources.srcDirs += [
            'griffon-app/resources',
            'griffon-app/i18n',
            'src/main/resources'
        ]
{'fraction_non_alphanumeric': 0.09609043805934997, 'fraction_numerical': 0.0053383576699638875, 'mean_word_length': 3.212962962962963, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '23030', 'n_tokens_mistral': 1735, 'n_tokens_neox': 1661, 'n_words': 423}