# Kotlin.compiler.incremental not copying resources

**URL:** <https://discuss.kotlinlang.org/t/kotlin-compiler-incremental-not-copying-resources/5640>\
**Category:** Support\
**Created:** [December 1, 2017, 8:34pm UTC](https://discuss.kotlinlang.org/t/kotlin-compiler-incremental-not-copying-resources/5640 "2017-12-01T20:34:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![smallufo](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/smallufo/32/1618_2.png) [@smallufo](https://discuss.kotlinlang.org/u/smallufo)\
**Post date:** [December 1, 2017, 8:34pm UTC](https://discuss.kotlinlang.org/t/kotlin-compiler-incremental-not-copying-resources/5640/1 "2017-12-01T20:34:44Z")

</div>

I think it may be a bug

**\<kotlin.compiler.incremental\>false\</kotlin.compiler.incremental\>**  
mvn clean compile install  
find . -name ‘log4j.properties’  
./target/classes/log4j.properties  
./src/main/resources/log4j.properties

But , when setting kotlin.compiler.incremental to true  
**\<kotlin.compiler.incremental\>true\</kotlin.compiler.incremental\>**  
mvn clean compile install  
find . -name ‘log4j.properties’  
./src/main/resources/log4j.properties

NOT output to target/classes

environment

\<kotlin.version\>1.2.0\</kotlin.version\>  
\<kotlin.compiler.jvmTarget\>1.8\</kotlin.compiler.jvmTarget\>

$ mvn -version  
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)  
Maven home: /Users/smallufo/maven  
Java version: 9, vendor: Oracle Corporation  
Java home: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home  
Default locale: zh\_TW, platform encoding: UTF-8  
OS name: “mac os x”, version: “10.13.1”, arch: “x86\_64”, family: “mac”

---

<div class="post-metadata">

**Author:** ![upeter75](https://avatars.discourse-cdn.com/v4/letter/u/a587f6/32.png) [@upeter75](https://discuss.kotlinlang.org/u/upeter75)\
**Post date:** [January 30, 2018, 9:58am UTC](https://discuss.kotlinlang.org/t/kotlin-compiler-incremental-not-copying-resources/5640/2 "2018-01-30T09:58:23Z")

</div>

Same issue here. Seems to be a bug. When is it fixed?

---

<div class="post-metadata">

**Author:** ![forinil2](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/forinil2/32/2465_2.png) [@forinil2](https://discuss.kotlinlang.org/u/forinil2)\
**Post date:** [January 30, 2018, 10:14am UTC](https://discuss.kotlinlang.org/t/kotlin-compiler-incremental-not-copying-resources/5640/3 "2018-01-30T10:14:26Z")

</div>

This issue is confusing. I thought resources were copied by [maven-resources-plugin](https://maven.apache.org/plugins/maven-resources-plugin/). How can it be possibly affected by compiler configuration?

---

<div class="post-metadata">

**Author:** ![knyttl](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@knyttl](https://discuss.kotlinlang.org/u/knyttl)\
**Post date:** [February 7, 2018, 12:30pm UTC](https://discuss.kotlinlang.org/t/kotlin-compiler-incremental-not-copying-resources/5640/4 "2018-02-07T12:30:26Z")

</div>

I got into the same problem. The incremental compilation cleans the target/classes and target/testClasses directories. maven-resources-plugin is run before and so the resources are all gone.

This is definitely a bug and very hard to find 😕

---

<div class="post-metadata">

**Author:** ![forinil2](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/forinil2/32/2465_2.png) [@forinil2](https://discuss.kotlinlang.org/u/forinil2)\
**Post date:** [February 7, 2018, 12:37pm UTC](https://discuss.kotlinlang.org/t/kotlin-compiler-incremental-not-copying-resources/5640/5 "2018-02-07T12:37:36Z")

</div>

In that case, this might be a possible workaround (although the resources would be copied twice in this scenario):

```xml
<plugin>
	<artifactId>maven-resources-plugin</artifactId>
	<version>3.0.2</version>
	<executions>
		<execution>
			<id>extra-copy-resources</id>
			<phase>process-classes</phase>
			<goals>
				<goal>resources</goal>
			</goals>          
		</execution>
		<execution>
			<id>extra-copy-test-resources</id>
			<phase>process-test-classes</phase>
			<goals>
				<goal>testResources</goal>
			</goals>          
		</execution>
	</executions>
</plugin>

```

---

<div class="post-metadata">

**Author:** ![pherrera](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/pherrera/32/4763_2.png) [@pherrera](https://discuss.kotlinlang.org/u/pherrera)\
**Post date:** [February 13, 2018, 4:55am UTC](https://discuss.kotlinlang.org/t/kotlin-compiler-incremental-not-copying-resources/5640/6 "2018-02-13T04:55:34Z")

</div>

Run into the same issue using version 1.2.21 of the compiler plugin and wasted hours before randomly trying this after determining that if I did a ‘clean’ and then ‘package’ the resources weren’t there, but doing another ‘package’ retained them, and figured it might be something to do with Kotlin not recompiling anything the second time around.

This used to work however as I have jar files that contain these missing resources, but reverting to earlier versions of my POM with earlier plugin versions didn’t seem to fix it. It feels like something else is involved but this was the only consistent factor I could find

---

<div class="post-metadata">

**Author:** ![chris.hewison](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/chris.hewison/32/4841_2.png) [@chris.hewison](https://discuss.kotlinlang.org/u/chris.hewison)\
**Post date:** [March 1, 2018, 12:32pm UTC](https://discuss.kotlinlang.org/t/kotlin-compiler-incremental-not-copying-resources/5640/7 "2018-03-01T12:32:46Z")

</div>

Also hit the same problem when upgrading from 1.2.0 to 1.2.21.  
Fixed by turning off incremental compiling of Kotlin  
\<kotlin.version\>1.2.21\</kotlin.version\>  
\<kotlin.compiler.incremental\>false\</kotlin.compiler.incremental\>
