-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7dd1f6c
commit 2d4a5d8
Showing
2 changed files
with
43 additions
and
21 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
40 changes: 40 additions & 0 deletions
40
lombok-plugin/src/main/java/io/freefair/gradle/plugins/lombok/internal/ConfigUtil.java
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,40 @@ | ||
package io.freefair.gradle.plugins.lombok.internal; | ||
|
||
import io.freefair.gradle.plugins.lombok.tasks.LombokConfig; | ||
import lombok.experimental.UtilityClass; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.tasks.TaskProvider; | ||
|
||
import java.io.File; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import static org.codehaus.groovy.runtime.StringGroovyMethods.capitalize; | ||
|
||
@UtilityClass | ||
public class ConfigUtil { | ||
|
||
public Map<File, TaskProvider<LombokConfig>> getLombokConfigTasks(Project project, String sourceSetName, Set<File> srcDirs) { | ||
Map<File, TaskProvider<LombokConfig>> result = new HashMap<>(); | ||
|
||
int i = 1; | ||
for (File srcDir : srcDirs) { | ||
|
||
int finalI = i; | ||
String taskName = "generate" + capitalize(sourceSetName) + "EffectiveLombokConfig" + i; | ||
TaskProvider<LombokConfig> genConfigTask = project.getTasks().register(taskName, LombokConfig.class, lombokConfigTask -> { | ||
lombokConfigTask.setGroup("lombok"); | ||
lombokConfigTask.setDescription("Generate effective Lombok configuration for '" + srcDir + "' of source-set '" + sourceSetName + "'."); | ||
lombokConfigTask.getPaths().from(srcDir); | ||
lombokConfigTask.getOutputFile().set(project.getLayout().getBuildDirectory().file("lombok/effective-config/" + sourceSetName + "/lombok-" + finalI + ".config")); | ||
}); | ||
|
||
result.put(srcDir, genConfigTask); | ||
|
||
i++; | ||
} | ||
|
||
return result; | ||
} | ||
} |