-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Convert package infos stuff to a proper plugin - Add extension for specifying which source sets get generated package infos - Move extension classes into their own files - Move GeneratePackageInfosTask into com.jozufozu.gradle
- Loading branch information
Showing
10 changed files
with
106 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...in/groovy/GeneratePackageInfosTask.groovy → ...zu/gradle/GeneratePackageInfosTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
buildSrc/src/main/groovy/com/jozufozu/gradle/JarSetExtension.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.jozufozu.gradle | ||
|
||
import groovy.transform.CompileStatic | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.SourceSet | ||
import org.gradle.api.tasks.SourceSetContainer | ||
|
||
@CompileStatic | ||
class JarSetExtension { | ||
private final Project project | ||
|
||
JarSetExtension(Project project) { | ||
this.project = project | ||
} | ||
|
||
JarTaskSet createJars(String name) { | ||
return createJars(name, project.getExtensions().getByType(SourceSetContainer).named(name).get()) | ||
} | ||
|
||
JarTaskSet createJars(String name, SourceSet... sourceSetSet) { | ||
return JarTaskSet.create(project, name, sourceSetSet) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
buildSrc/src/main/groovy/com/jozufozu/gradle/PackageInfosExtension.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.jozufozu.gradle | ||
|
||
import groovy.transform.CompileStatic | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.Delete | ||
import org.gradle.api.tasks.SourceSet | ||
|
||
@CompileStatic | ||
class PackageInfosExtension { | ||
final Project project | ||
|
||
PackageInfosExtension(Project project) { | ||
this.project = project | ||
} | ||
|
||
void forSourceSets(SourceSet... sourceSets) { | ||
for (SourceSet sourceSet : sourceSets) { | ||
_forSourceSet(sourceSet) | ||
} | ||
} | ||
|
||
private void _forSourceSet(SourceSet sourceSet) { | ||
// We have to capture the source set name for the lazy string literals, | ||
// otherwise it'll just be whatever the last source set is in the list. | ||
def sourceSetName = sourceSet.name | ||
def taskName = sourceSet.getTaskName('generate', 'PackageInfos') | ||
def task = project.tasks.register(taskName, GeneratePackageInfosTask) { | ||
it.group = 'flywheel' | ||
it.description = "Generates package-info files for $sourceSetName packages." | ||
|
||
// Only apply to default source directory since we also add the generated | ||
// sources to the source set. | ||
it.sourceRoot.set(project.file("src/$sourceSetName/java")) | ||
it.outputDir.set(project.file("src/$sourceSetName/generatedPackageInfos")) | ||
} | ||
sourceSet.java.srcDir(task) | ||
|
||
project.tasks.named('ideaSyncTask').configure { | ||
it.finalizedBy(task) | ||
} | ||
|
||
def cleanTask = project.tasks.register(sourceSet.getTaskName('clean', 'PackageInfos'), Delete) { | ||
it.group = 'flywheel' | ||
it.delete(project.file("src/$sourceSetName/generatedPackageInfos")) | ||
} | ||
project.tasks.named('clean').configure { | ||
it.dependsOn(cleanTask) | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
buildSrc/src/main/groovy/com/jozufozu/gradle/PackageInfosPlugin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.jozufozu.gradle | ||
|
||
import groovy.transform.CompileStatic | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
@CompileStatic | ||
class PackageInfosPlugin implements Plugin<Project> { | ||
@Override | ||
void apply(Project target) { | ||
target.extensions.create('defaultPackageInfos', PackageInfosExtension, target) | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters