# Duplicate classes in kotlin-runtime and com.intellij:annotations

**URL:** <https://discuss.kotlinlang.org/t/duplicate-classes-in-kotlin-runtime-and-com-intellij-annotations/154>\
**Category:** Uncategorized\
**Created:** [August 18, 2015, 8:54am UTC](https://discuss.kotlinlang.org/t/duplicate-classes-in-kotlin-runtime-and-com-intellij-annotations/154 "2015-08-18T08:54:33Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![pdvrieze](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/pdvrieze/32/1882_2.png) [@pdvrieze](https://discuss.kotlinlang.org/u/pdvrieze)\
**Post date:** [April 15, 2016, 10:47am UTC](https://discuss.kotlinlang.org/t/duplicate-classes-in-kotlin-runtime-and-com-intellij-annotations/154/3 "2016-04-15T10:47:00Z")

</div>

While exclusion is “nice”, we can do better. I’ve added the following snippets to my build file to handle it better (Other annotations in the annotation package are used as well).

Basically, the excluded annotations library is replaced by a file dependency on a jar file that automatically has the offending classes stripped out.

```auto
configurations {
    cleanedAnnotations

    compile.exclude group: 'org.jetbrains' , module:'annotations'
}

```

…

```auto
dependencies {
    compile files("${buildDir}/libs/annotations-cleaned.jar") { builtBy 'cleanAnnotationsJar' }
    cleanedAnnotations 'org.jetbrains:annotations:13.0'

```

…

```auto
task cleanAnnotationsJar(type:Jar) {
    configurations.cleanedAnnotations.each { f ->
        from zipTree(f)
    }
    archiveName = "annotations-cleaned.jar"
    exclude 'org/jetbrains/annotations/NotNull.class'
    exclude 'org/jetbrains/annotations/Nullable.class'
}

```

---

_[View the full topic](https://discuss.kotlinlang.org/t/duplicate-classes-in-kotlin-runtime-and-com-intellij-annotations/154)._
