You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Artifact transforms were added to gradle, and should be a clean way of applying our patches to dependencies. The current approach is fragile as it relies on internal API, and breaks transitive dependencies.
Unfortunately, there have been some issues implementing this.
Documentation
It's not clear what the possible values for built in gradle attributes are, or what to use. The examples use java and jar as values for artifactType. Where are those defined? jar is in ArtifactTypeDefinition but there's nothing for java.
Haven't been able to get transformation of sources working the same way as with jars. Using artifactType java or sources seems to result in nothing happening? The sources used when importing into IDEA don't get transformations applied.
Looks like this is the same as gradle/gradle#11519 "DefauitArtifactResolutionQuery does not care for specified Transformers and ArtifactAttributes"
Per-dependency transformation
It doesn't seem to be possible to register a transformer for a specific set of dependencies, it gets ran on all of them. This means we need to pass a huge blob of parameters in registered once, and determine what to do per dependency. Extra work for gradle here as it's running the transform (and doing cache stuff) for every dep. Somewhat breaks caching, as if the input for any dep changes the cache is stale.
Once we've done that, it's hard to figure out what dependency the input file is from as only a File is provided. Raised gradle/gradle#11831 to ask about that.
Transformer parameters can't reference task outputs or configs?
Only serializable values seem to work in the task parameters, so we have to do a horrible hack with static state and find the task again when running. This also means the dependency isn't being taken into account. Initially expected it would be, as for tasks you can do @InputFiles and a file dependency from another task's outputs will automatically depend on that task being ran first.
Is there a better workaround than this static hack? Is pretty awful, so don't want to turn on using transformers at all as the generated dependency doesn't depend on that. Generated dep approach also has working dependency on the subproject task.
Artifact transforms were added to gradle, and should be a clean way of applying our patches to dependencies. The current approach is fragile as it relies on internal API, and breaks transitive dependencies.
Unfortunately, there have been some issues implementing this.
Documentation
It's not clear what the possible values for built in gradle attributes are, or what to use. The examples use
java
andjar
as values forartifactType
. Where are those defined?jar
is in ArtifactTypeDefinition but there's nothing forjava
.https://github.com/gradle/gradle/blob/5bb0f7bf70c1311a07cf82677ed1b1660bfd8f87/subprojects/core-api/src/main/java/org/gradle/api/artifacts/type/ArtifactTypeDefinition.java#L30-L76
Source transformation?
Haven't been able to get transformation of sources working the same way as with jars. Using artifactType
java
orsources
seems to result in nothing happening? The sources used when importing into IDEA don't get transformations applied.Mixin/gradle-plugin/src/main/java/org/minimallycorrect/mixinplugin/MixinGradlePlugin.java
Lines 129 to 133 in 8daf682
Looks like this is the same as gradle/gradle#11519 "DefauitArtifactResolutionQuery does not care for specified Transformers and ArtifactAttributes"
Per-dependency transformation
It doesn't seem to be possible to register a transformer for a specific set of dependencies, it gets ran on all of them. This means we need to pass a huge blob of parameters in registered once, and determine what to do per dependency. Extra work for gradle here as it's running the transform (and doing cache stuff) for every dep. Somewhat breaks caching, as if the input for any dep changes the cache is stale.
Mixin/gradle-plugin/src/main/java/org/minimallycorrect/mixinplugin/transform/MixinTransform.java
Lines 25 to 26 in 8daf682
Once we've done that, it's hard to figure out what dependency the input file is from as only a
File
is provided. Raised gradle/gradle#11831 to ask about that.Mixin/gradle-plugin/src/main/java/org/minimallycorrect/mixinplugin/transform/MixinTransform.java
Lines 56 to 102 in 8daf682
Transformer parameters can't reference task outputs or configs?
Only serializable values seem to work in the task parameters, so we have to do a horrible hack with static state and find the task again when running. This also means the dependency isn't being taken into account. Initially expected it would be, as for tasks you can do
@InputFiles
and a file dependency from another task's outputs will automatically depend on that task being ran first.Mixin/gradle-plugin/src/main/java/org/minimallycorrect/mixinplugin/transform/MixinTransform.java
Lines 24 to 34 in 8daf682
Mixin/gradle-plugin/src/main/java/org/minimallycorrect/mixinplugin/ApplyMixins.java
Lines 52 to 55 in 8daf682
Mixin/gradle-plugin/src/main/java/org/minimallycorrect/mixinplugin/ApplyMixins.java
Lines 126 to 129 in 8daf682
Is there a better workaround than this static hack? Is pretty awful, so don't want to turn on using transformers at all as the generated dependency doesn't depend on that. Generated dep approach also has working dependency on the subproject task.
Raised gradle/gradle#11847
The text was updated successfully, but these errors were encountered: