|
| 1 | +/* |
| 2 | + * Copyright 2014 original authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
1 | 16 | package org.grails.gradle.plugin.core |
2 | 17 |
|
| 18 | +import grails.util.Environment |
3 | 19 | import groovy.transform.CompileStatic |
4 | 20 | import org.gradle.api.Project |
5 | 21 | import org.gradle.api.Task |
| 22 | +import org.gradle.api.artifacts.Configuration |
6 | 23 | import org.gradle.api.artifacts.PublishArtifact |
| 24 | +import org.gradle.api.artifacts.dsl.ArtifactHandler |
7 | 25 | import org.gradle.api.internal.tasks.DefaultTaskDependency |
8 | 26 | import org.gradle.api.tasks.Copy |
9 | 27 | import org.gradle.api.tasks.JavaExec |
| 28 | +import org.gradle.api.tasks.SourceSetContainer |
| 29 | +import org.gradle.api.tasks.TaskContainer |
10 | 30 | import org.gradle.api.tasks.TaskDependency |
11 | 31 | import org.gradle.api.tasks.bundling.Jar |
12 | 32 | import org.gradle.api.tasks.compile.GroovyCompile |
13 | 33 | import org.gradle.language.jvm.tasks.ProcessResources |
14 | 34 | import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry |
| 35 | +import org.grails.gradle.plugin.util.SourceSets |
15 | 36 |
|
16 | 37 | import javax.inject.Inject |
17 | | -/* |
18 | | - * Copyright 2014 original authors |
19 | | - * |
20 | | - * Licensed under the Apache License, Version 2.0 (the "License"); |
21 | | - * you may not use this file except in compliance with the License. |
22 | | - * You may obtain a copy of the License at |
23 | | - * |
24 | | - * http://www.apache.org/licenses/LICENSE-2.0 |
25 | | - * |
26 | | - * Unless required by applicable law or agreed to in writing, software |
27 | | - * distributed under the License is distributed on an "AS IS" BASIS, |
28 | | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
29 | | - * See the License for the specific language governing permissions and |
30 | | - * limitations under the License. |
31 | | - */ |
| 38 | + |
32 | 39 |
|
33 | 40 | /** |
34 | 41 | * A Gradle plugin for Grails plugins |
@@ -76,35 +83,42 @@ class GrailsPluginGradlePlugin extends GrailsGradlePlugin { |
76 | 83 | def allConfigurations = project.configurations |
77 | 84 |
|
78 | 85 | def explodedConfig = allConfigurations.create(configurationName) |
79 | | - explodedConfig.extendsFrom(allConfigurations.findByName('compile')) |
| 86 | + |
| 87 | + def parent = allConfigurations.findByName('runtime') |
| 88 | + if(Environment.isDevelopmentRun()) { |
| 89 | + parent.artifacts.clear() |
| 90 | + } |
| 91 | + explodedConfig.extendsFrom(parent) |
80 | 92 | // add the subproject classes as outputs |
81 | | - GroovyCompile groovyCompile = (GroovyCompile)project.tasks.findByName('compileGroovy') |
82 | | - project.artifacts.add(configurationName, new ExplodedDir( groovyCompile.destinationDir, groovyCompile) ) |
| 93 | + def allTasks = project.tasks |
| 94 | + GroovyCompile groovyCompile = (GroovyCompile) allTasks.findByName('compileGroovy') |
| 95 | + |
| 96 | + def allArtifacts = project.artifacts |
| 97 | + allArtifacts.add(configurationName, new ExplodedDir( groovyCompile.destinationDir, groovyCompile) ) |
83 | 98 |
|
84 | 99 | // add the subproject resources as outputs |
85 | | - ProcessResources processResources = (ProcessResources)project.tasks.findByName("processResources") |
86 | | - project.artifacts.add(configurationName, new ExplodedDir( processResources.destinationDir, processResources) ) |
| 100 | + ProcessResources processResources = (ProcessResources) allTasks.findByName("processResources") |
| 101 | + allArtifacts.add(configurationName, new ExplodedDir( processResources.destinationDir, processResources) ) |
87 | 102 | } |
88 | 103 |
|
89 | 104 | @Override |
90 | 105 | protected Task createBuildPropertiesTask(Project project) { |
91 | 106 | // no-op |
92 | 107 | } |
93 | 108 |
|
| 109 | + @CompileStatic |
94 | 110 | protected void configureSourcesJarTask(Project project) { |
95 | 111 | def taskContainer = project.tasks |
96 | 112 | if(taskContainer.findByName('sourcesJar') == null) { |
97 | | - taskContainer.create("sourcesJar", Jar).configure { |
98 | | - classifier = 'sources' |
99 | | - from project.sourceSets.main.allSource |
100 | | - } |
| 113 | + def jarTask = taskContainer.create("sourcesJar", Jar) |
| 114 | + jarTask.classifier = 'sources' |
| 115 | + jarTask.from SourceSets.findMainSourceSet(project).allSource |
101 | 116 | } |
102 | 117 | } |
103 | 118 |
|
104 | 119 | protected void configureAstSources(Project project) { |
105 | | - def sourceSets = project.sourceSets |
106 | | - def mainSourceSet = sourceSets.main |
107 | | - |
| 120 | + def mainSourceSet = SourceSets.findMainSourceSet(project) |
| 121 | + def sourceSets = SourceSets.findSourceSets(project) |
108 | 122 | project.sourceSets { |
109 | 123 | ast { |
110 | 124 | groovy { |
|
0 commit comments