Skip to content

Commit

Permalink
Migrate DontIncludeResourceTransformer
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Nov 26, 2024
1 parent d3bd1c4 commit 5d5030f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 2 additions & 3 deletions api/shadow.api
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,13 @@ public final class com/github/jengelman/gradle/plugins/shadow/transformers/Compo
}

public class com/github/jengelman/gradle/plugins/shadow/transformers/DontIncludeResourceTransformer : com/github/jengelman/gradle/plugins/shadow/transformers/Transformer {
public fun <init> ()V
public fun <init> (Lorg/gradle/api/model/ObjectFactory;)V
public fun canTransformResource (Lorg/gradle/api/file/FileTreeElement;)Z
public fun getName ()Ljava/lang/String;
public fun getObjectFactory ()Lorg/gradle/api/model/ObjectFactory;
public final fun getResource ()Ljava/lang/String;
public final fun getResource ()Lorg/gradle/api/provider/Property;
public fun hasTransformedResource ()Z
public fun modifyOutputStream (Lorg/apache/tools/zip/ZipOutputStream;Z)V
public final fun setResource (Ljava/lang/String;)V
public fun transform (Lcom/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext;)V
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.github.jengelman.gradle.plugins.shadow.transformers

import com.github.jengelman.gradle.plugins.shadow.internal.property
import javax.inject.Inject
import org.gradle.api.file.FileTreeElement
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional

Expand All @@ -11,13 +15,15 @@ import org.gradle.api.tasks.Optional
*
* @author John Engelman
*/
public open class DontIncludeResourceTransformer : Transformer by NoOpTransformer {
public open class DontIncludeResourceTransformer @Inject constructor(
override val objectFactory: ObjectFactory,
) : Transformer by NoOpTransformer {
@get:Optional
@get:Input
public var resource: String? = null
public val resource: Property<String> = objectFactory.property()

override fun canTransformResource(element: FileTreeElement): Boolean {
val path = element.relativePath.pathString
return !resource.isNullOrEmpty() && path.endsWith(resource!!)
return !resource.orNull.isNullOrEmpty() && path.endsWith(resource.get())
}
}

0 comments on commit 5d5030f

Please sign in to comment.