-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Introduce the possibility to manual group sourcesets togeth…
…er (#200)
- Loading branch information
1 parent
602139f
commit 281a603
Showing
16 changed files
with
1,220 additions
and
59 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
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
86 changes: 86 additions & 0 deletions
86
common/src/main/java/net/neoforged/gradle/common/runs/run/RunSourceSetsImpl.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,86 @@ | ||
package net.neoforged.gradle.common.runs.run; | ||
|
||
import com.google.common.collect.HashMultimap; | ||
import com.google.common.collect.Multimap; | ||
import net.neoforged.gradle.common.util.SourceSetUtils; | ||
import net.neoforged.gradle.dsl.common.runs.run.RunSourceSets; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.provider.Provider; | ||
import org.gradle.api.tasks.SourceSet; | ||
|
||
import javax.inject.Inject; | ||
|
||
public abstract class RunSourceSetsImpl implements RunSourceSets { | ||
|
||
private final Project project; | ||
private final Provider<Multimap<String, SourceSet>> provider; | ||
private final Multimap<String, SourceSet> sourceSets; | ||
|
||
@Inject | ||
public RunSourceSetsImpl(Project project) { | ||
this.project = project; | ||
this.sourceSets = HashMultimap.create(); | ||
this.provider = project.provider(() -> sourceSets); | ||
} | ||
|
||
|
||
@Override | ||
public void add(SourceSet sourceSet) { | ||
this.sourceSets.put(SourceSetUtils.getModIdentifier(sourceSet, null), sourceSet); | ||
} | ||
|
||
@Override | ||
public void add(Iterable<? extends SourceSet> sourceSets) { | ||
for (SourceSet sourceSet : sourceSets) { | ||
add(sourceSet); | ||
} | ||
} | ||
|
||
@Override | ||
public void add(SourceSet... sourceSets) { | ||
for (SourceSet sourceSet : sourceSets) { | ||
add(sourceSet); | ||
} | ||
} | ||
|
||
@Override | ||
public void local(SourceSet sourceSet) { | ||
this.sourceSets.put(SourceSetUtils.getModIdentifier(sourceSet, project), sourceSet); | ||
} | ||
|
||
@Override | ||
public void local(Iterable<? extends SourceSet> sourceSets) { | ||
for (SourceSet sourceSet : sourceSets) { | ||
local(sourceSet); | ||
} | ||
} | ||
|
||
@Override | ||
public void local(SourceSet... sourceSets) { | ||
for (SourceSet sourceSet : sourceSets) { | ||
local(sourceSet); | ||
} | ||
} | ||
|
||
@Override | ||
public void add(String groupId, SourceSet sourceSet) { | ||
this.sourceSets.put(groupId, sourceSet); | ||
} | ||
|
||
@Override | ||
public void add(String groupId, Iterable<? extends SourceSet> sourceSets) { | ||
this.sourceSets.putAll(groupId, sourceSets); | ||
} | ||
|
||
@Override | ||
public void add(String groupId, SourceSet... sourceSets) { | ||
for (SourceSet sourceSet : sourceSets) { | ||
add(groupId, sourceSet); | ||
} | ||
} | ||
|
||
@Override | ||
public Provider<Multimap<String, SourceSet>> all() { | ||
return this.provider; | ||
} | ||
} |
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
Oops, something went wrong.