-
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/Fix]: Interface injections, and minor bugfixes (#249)
- Loading branch information
1 parent
89bae0f
commit 173aeb9
Showing
84 changed files
with
1,764 additions
and
737 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
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
13 changes: 0 additions & 13 deletions
13
common/src/main/java/net/neoforged/gradle/common/extensions/IExtensionCreator.java
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
56 changes: 56 additions & 0 deletions
56
...on/src/main/java/net/neoforged/gradle/common/extensions/InterfaceInjectionsExtension.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,56 @@ | ||
package net.neoforged.gradle.common.extensions; | ||
|
||
import net.neoforged.gradle.common.interfaceinjection.InterfaceInjectionPublishing; | ||
import net.neoforged.gradle.dsl.common.extensions.InterfaceInjections; | ||
import org.gradle.api.Action; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.artifacts.ConfigurablePublishArtifact; | ||
import org.gradle.api.artifacts.Dependency; | ||
import org.gradle.api.artifacts.dsl.ArtifactHandler; | ||
import org.gradle.api.artifacts.dsl.DependencyHandler; | ||
|
||
import javax.inject.Inject; | ||
|
||
public abstract class InterfaceInjectionsExtension implements InterfaceInjections { | ||
private transient final DependencyHandler projectDependencies; | ||
private transient final ArtifactHandler projectArtifacts; | ||
|
||
private final Project project; | ||
|
||
@SuppressWarnings("UnstableApiUsage") | ||
@Inject | ||
public InterfaceInjectionsExtension(Project project) { | ||
this.project = project; | ||
|
||
this.projectDependencies = project.getDependencies(); | ||
this.projectArtifacts = project.getArtifacts(); | ||
|
||
// We have to add these after project evaluation because of dependency replacement making configurations non-lazy; adding them earlier would prevent further addition of dependencies | ||
project.afterEvaluate(p -> { | ||
p.getConfigurations().maybeCreate(InterfaceInjectionPublishing.INTERFACE_INJECTION_CONFIGURATION).fromDependencyCollector(getConsume()); | ||
p.getConfigurations().maybeCreate(InterfaceInjectionPublishing.INTERFACE_INJECTION_API_CONFIGURATION).fromDependencyCollector(getConsumeApi()); | ||
}); | ||
} | ||
|
||
@Override | ||
public Project getProject() { | ||
return project; | ||
} | ||
|
||
@Override | ||
public void expose(Object path, Action<ConfigurablePublishArtifact> action) { | ||
getFiles().from(path); | ||
projectArtifacts.add(InterfaceInjectionPublishing.INTERFACE_INJECTION_ELEMENTS_CONFIGURATION, path, action); | ||
} | ||
|
||
@Override | ||
public void expose(Object path) { | ||
expose(path, artifacts -> { | ||
}); | ||
} | ||
|
||
@Override | ||
public void expose(Dependency dependency) { | ||
projectDependencies.add(InterfaceInjectionPublishing.INTERFACE_INJECTION_API_CONFIGURATION, dependency); | ||
} | ||
} |
Oops, something went wrong.