question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spring classpath filtering via Gradle plugin

See original GitHub issue

We should be able to do that with something like:

compile("org.springframework:spring-web") {
		registerTransform {
			from.attribute(filtered, false).attribute(artifactType, "jar")
			to.attribute(filtered, true).attribute(artifactType, "jar")
			artifactTransform(FilterClasses::class.java)
		}
	}
}

// Same for spring-webflux, spring-context, spring-data-commons, etc.
class SpringFuWebFilter : ArtifactTransform() {
	
	private val classesToFilter = arrayOf(
			"org/springframework/remoting/**",
			"org/springframework/web/accept/**",
			"org/springframework/web/bind/**",
			"org/springframework/web/client/**",
			"org/springframework/web/context/**",
			"org/springframework/web/filter/**",
			"org/springframework/web/jsf/**",
			"org/springframework/web/method/**",
			"org/springframework/web/multipart/**",
		)
)

	override fun transform(input: File): List<File> {
		return if (...) listOf(input) else emptyList()
	}
}

See also https://github.com/gradle/gradle/blob/master/buildSrc/subprojects/packaging/src/main/kotlin/org/gradle/gradlebuild/packaging/MinifyPlugin.kt

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
sdeleuzecommented, May 28, 2020

I think GraalVM native images or Jlink are better solution to this need.

0reactions
sdeleuzecommented, Jun 29, 2019

Gradle 5.5 with official support and documentation for artifact transformation has been released.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring classpath filtering via Gradle plugin · Issue #34 - GitHub
We should be able to do that with something like: compile("org.springframework:spring-web") { registerTransform { from.attribute(filtered, ...
Read more >
73. Properties and Configuration - Spring
Only production configuration is filtered that way (in other words, ... You can then refer to your Gradle project's properties via placeholders, as...
Read more >
The Java Plugin - Gradle User Manual
The Java plugin adds the java extension to the project. This allows to configure a number of Java related properties inside a dedicated...
Read more >
Filtering artifacts by capabilities/attributes - Gradle Forums
Hi! I hope my question is not too weird, I would like to create a Gradle plugin that is capable of finding Jar...
Read more >
Testing in Java & JVM projects - Gradle User Manual
You can enable filtering either in the build script or via the --tests command-line option. Here's an example of some filters that are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found