softprops / coffeescripted-sbt

pour some coffee for scala
MIT License
55 stars 5 forks source link

Files with the same name in different folders cause a duplicate mappings error during the compile:copy-resources phase #6

Closed vjpr closed 12 years ago

vjpr commented 12 years ago

It appears that when you compile two files with the same name but in different folders - the sbt copy-resources task produces the following error:

[error] {file:/Users/Vaughan/dev/x-unfiltered/}default-8111a8/compile:copy-resources: Duplicate mappings:
[error]     /Users/Vaughan/dev/x-unfiltered/target/scala-2.9.1/classes/RPCClient.js
[error] from
[error]     /Users/Vaughan/dev/x-unfiltered/target/scala-2.9.1/classes/extension/chrome/javascripts/rpc/RPCClient.js
[error]         /Users/Vaughan/dev/x-unfiltered/target/scala-2.9.1/classes/public/javascripts/rpc/RPCClient.js

By running sbt with debug level logging (set logLevel in Global := Level.Debug) I get the following debug output showing the problem:

[debug] Copy resource mappings: 
[debug]     (/Users/Vaughan/dev/x-unfiltered/target/scala-2.9.1/classes/extension/chrome/javascripts/rpc/RPCClient.js,/Users/Vaughan/dev/x-unfiltered/target/scala-2.9.1/classes/RPCClient.js)
[debug]     (/Users/Vaughan/dev/x-unfiltered/target/scala-2.9.1/classes/public/javascripts/rpc/RPCClient.js,/Users/Vaughan/dev/x-unfiltered/target/scala-2.9.1/classes/RPCClient.js)
 [debug]    (/Users/Vaughan/dev/x-unfiltered/src/main/resources/akka.conf.old,/Users/Vaughan/dev/x-unfiltered/target/scala-2.9.1/classes/akka.conf.old)

The problem appears to be that coffeescripted-sbt artifacts are being mapped to files in the classes directory - the root compilation directory. This also occurs for less-sbt artifacts too. This is an unnecessary step and I'm not sure why it is doing this.

I think it must be something to do with the compile:managed-resource-directories setting being used by the compile:copy-resources task.

This only occurs when using a custom output directory as recommended:

(resourceManaged in (Compile, CoffeeKeys.coffee)) <<= (crossTarget in Compile)(_ / "your_preference" / "js")

Not sure whether this can be fixed or if its an sbt bug?

vjpr commented 12 years ago

I have since resolved this issue by using:

(resourceManaged in (Compile, CoffeeKeys.coffee)) <<= (resourceManaged in Compile)

instead of:

(resourceManaged in (Compile, CoffeeKeys.scalate)) <<= (crossTarget in Compile)(_ / "classes" / "public" / "js")
softprops commented 12 years ago

On Sat, Nov 12, 2011 at 6:22 AM, Vaughan Rouesnel < reply@reply.github.com

wrote:

It appears that when you compile two files with the same name but in different folders - the sbt copy-resources task produces the following error:

[error] {file:/Users/Vaughan/dev/x-unfiltered/}default-8111a8/compile:copy-resources: Duplicate mappings: [error] /Users/Vaughan/dev/x-unfiltered/target/scala-2.9.1/classes/RPCClient.js [error] from [error] /Users/Vaughan/dev/x-unfiltered/target/scala-2.9.1/classes/extension/chrome/javascripts/rpc/RPCClient.js [error] /Users/Vaughan/dev/x-unfiltered/target/scala-2.9.1/classes/public/javascripts/rpc/RPCClient.js

By running sbt with debug level logging (set logLevel in Global := Level.Debug) I get the following debug output showing the problem:

[debug] Copy resource mappings: debug debug debug

The problem appears to be that coffeescripted-sbt artifacts are being mapped to files in the classes directory - the root compilation directory. This also occurs for less-sbt artifacts too. This is an unnecessary step and I'm not sure why it is doing this.

I think it must be something to do with the compile:managed-resource-directories setting being used by the compile:copy-resources task.

Not sure whether this can be fixed or if its an sbt bug?

Thanks I'll look into it it. What version of sbt/coffeescripted-sbt are you using?

vjpr commented 12 years ago

Version 0.2.0.

I've closed the ticket already as it appeared to be a problem with using the custom output directory, that is, using resourceManaged instead of crossTarget.

Might be worth putting a note in the documentation about it.