# Can I remove classes from a jar file?

**URL:** <https://discuss.gradle.org/t/can-i-remove-classes-from-a-jar-file/50238>\
**Category:** Help/Discuss\
**Created:** [January 13, 2025, 3:51pm UTC](https://discuss.gradle.org/t/can-i-remove-classes-from-a-jar-file/50238 "2025-01-13T15:51:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![furstenheim](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@furstenheim](https://discuss.gradle.org/u/furstenheim)\
**Post date:** [January 13, 2025, 3:51pm UTC](https://discuss.gradle.org/t/can-i-remove-classes-from-a-jar-file/50238/1 "2025-01-13T15:51:24Z")

</div>

I’m using a library that is being a [bad netizen](https://github.com/aws/aws-sdk-java-v2/issues/4213) and it is including a bunch of classes for another path (in this case com.kotlin).

If this library was including them as dependencies, I could simply do

```gradle
testImplementation(library) {
  exclude(group = "com.kotlin")
}

```

However, it is not the case. They are just included in the jar file. How can I remove those files from the jar file, or at least instruct Gradle not to include them in the classpath?

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [January 13, 2025, 4:50pm UTC](https://discuss.gradle.org/t/can-i-remove-classes-from-a-jar-file/50238/2 "2025-01-13T16:50:07Z")

</div>

That’s by far not trivial.  
But the best method would probably be an artifact transform that carves out those files from that jar and leaves all other artifacts untouched.
