-
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.
Add system for publishing and consuming ATs (#146)
Co-authored-by: Marc Hermans <[email protected]>
- Loading branch information
1 parent
a54164e
commit 8faf299
Showing
3 changed files
with
117 additions
and
5 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
37 changes: 37 additions & 0 deletions
37
common/src/main/java/net/neoforged/gradle/common/extensions/AccessTransformersExtension.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 |
---|---|---|
@@ -1,15 +1,52 @@ | ||
package net.neoforged.gradle.common.extensions; | ||
|
||
import net.neoforged.gradle.common.CommonProjectPlugin; | ||
import net.neoforged.gradle.common.extensions.base.BaseFilesWithEntriesExtension; | ||
import net.neoforged.gradle.dsl.common.extensions.AccessTransformers; | ||
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 AccessTransformersExtension extends BaseFilesWithEntriesExtension<AccessTransformers> implements AccessTransformers { | ||
private transient final DependencyHandler projectDependencies; | ||
private transient final ArtifactHandler projectArtifacts; | ||
|
||
@Inject | ||
public AccessTransformersExtension(Project project) { | ||
super(project); | ||
|
||
this.projectDependencies = project.getDependencies(); | ||
this.projectArtifacts = project.getArtifacts(); | ||
} | ||
|
||
@Override | ||
public Dependency consume(Object notation) { | ||
return this.projectDependencies.add(CommonProjectPlugin.ACCESS_TRANSFORMER_CONFIGURATION, notation); | ||
} | ||
|
||
@Override | ||
public Dependency consumeApi(Object notation) { | ||
return this.projectDependencies.add(CommonProjectPlugin.ACCESS_TRANSFORMER_API_CONFIGURATION, notation); | ||
} | ||
|
||
@Override | ||
public void expose(Object path, Action<ConfigurablePublishArtifact> action) { | ||
file(path); | ||
projectArtifacts.add(CommonProjectPlugin.ACCESS_TRANSFORMER_ELEMENTS_CONFIGURATION, path, action); | ||
} | ||
|
||
@Override | ||
public void expose(Object path) { | ||
expose(path, artifacts -> {}); | ||
} | ||
|
||
@Override | ||
public void expose(Dependency dependency) { | ||
projectDependencies.add(CommonProjectPlugin.ACCESS_TRANSFORMER_API_CONFIGURATION, dependency); | ||
} | ||
} |
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