Maven scala compile failing if resource defined

View: New views
6 Messages — Rating Filter:   Alert me  

Maven scala compile failing if resource defined

by corcorda :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm using the maven-scala-plugin for a scala only project and it was working great. I've added maven to the project late so unfortunately it doesn't follow the standard directory structure. The structure is like so:
src/package...
src/generatedSourceFiles/package...
src/resources/log4.properties (only 1 resource so far)

If I add the <resources> tag to the pom and do a clean compile the resource is copied but the compile finishes saying "nothing to compile...". If I delete the resource (from the resource/ dir) and do another clean compile the code is compiled fine (but obviously no resource is copied).

I've attached my pom.xml. Is there something I'm doing wrong?

Any help would be great.

Thanks,

Dave

pom.xml

Re: [scala-tools] Maven scala compile failing if resource defined

by Josh Suereth :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Resources are considered static things that get appended to the classpath, and are not compiled.  They should be copied into the resulting jars that are generated.

What behavior are you expecting?

On Wed, Oct 14, 2009 at 9:59 AM, corcorda <dave.corcoran@...> wrote:

Hi,

I'm using the maven-scala-plugin for a scala only project and it was working
great. I've added maven to the project late so unfortunately it doesn't
follow the standard directory structure. The structure is like so:
src/package...
src/generatedSourceFiles/package...
src/resources/log4.properties (only 1 resource so far)

If I add the <resources> tag to the pom and do a clean compile the resource
is copied but the compile finishes saying "nothing to compile...". If I
delete the resource (from the resource/ dir) and do another clean compile
the code is compiled fine (but obviously no resource is copied).

I've attached my pom.xml. Is there something I'm doing wrong?

Any help would be great.

Thanks,

Dave

http://www.nabble.com/file/p25891617/pom.xml pom.xml
--
View this message in context: http://www.nabble.com/Maven-scala-compile-failing-if-resource-defined-tp25891617p25891617.html
Sent from the Scala - Tools mailing list archive at Nabble.com.



Re: [scala-tools] Maven scala compile failing if resource defined

by David Bernard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

you should not put root of resources under a sub folder or your code
(to compile) source.
minimal changes to try :
move src/resources/log4.properties to resources/log4.properties
add <resources> tag to the pom.xml

/davidB

On Wed, Oct 14, 2009 at 19:54, Josh Suereth <joshua.suereth@...> wrote:

> Resources are considered static things that get appended to the classpath,
> and are not compiled.  They should be copied into the resulting jars that
> are generated.
>
> What behavior are you expecting?
>
> On Wed, Oct 14, 2009 at 9:59 AM, corcorda <dave.corcoran@...> wrote:
>>
>> Hi,
>>
>> I'm using the maven-scala-plugin for a scala only project and it was
>> working
>> great. I've added maven to the project late so unfortunately it doesn't
>> follow the standard directory structure. The structure is like so:
>> src/package...
>> src/generatedSourceFiles/package...
>> src/resources/log4.properties (only 1 resource so far)
>>
>> If I add the <resources> tag to the pom and do a clean compile the
>> resource
>> is copied but the compile finishes saying "nothing to compile...". If I
>> delete the resource (from the resource/ dir) and do another clean compile
>> the code is compiled fine (but obviously no resource is copied).
>>
>> I've attached my pom.xml. Is there something I'm doing wrong?
>>
>> Any help would be great.
>>
>> Thanks,
>>
>> Dave
>>
>> http://www.nabble.com/file/p25891617/pom.xml pom.xml
>> --
>> View this message in context:
>> http://www.nabble.com/Maven-scala-compile-failing-if-resource-defined-tp25891617p25891617.html
>> Sent from the Scala - Tools mailing list archive at Nabble.com.
>>
>
>

Re: [scala-tools] Maven scala compile failing if resource defined

by corcorda :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Josh,

I think you may have misread my mail, or maybe it wasn't clear enough. I know resources should just be copied into somewhere on the classpath. The problem is that when I put a resource in my resource directory it gets copied, but none of the .scala files get compiled. So my out/ directory just has the resource and no class files. If I delete the resource file from the resources dir and do a clean compile the out/ directory is filled with classes as expected. I was wondering why having a resource folder was stopping the build.

Regards,

Dave

Josh Suereth wrote:
Resources are considered static things that get appended to the classpath,
and are not compiled.  They should be copied into the resulting jars that
are generated.

What behavior are you expecting?

Re: [scala-tools] Maven scala compile failing if resource defined

by corcorda :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi David,

I tried it in several places, including putting it above the src folder as you suggested. It has the same effect. I only put it under src orginally because the maven spec suggests using src/main/resources

Thanks,

Dave

David Bernard-3 wrote:
you should not put root of resources under a sub folder or your code
(to compile) source.
minimal changes to try :
move src/resources/log4.properties to resources/log4.properties
add <resources> tag to the pom.xml

/davidB

Re: Maven scala compile failing if resource defined

by corcorda :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

For anyone else that runs into this problem, the solution was to remove
<outputDirectory>out</outputDirectory>
from the pom.xml. Everything now compiles fine *and* the resources are copied.

corcorda wrote:
Hi,

I'm using the maven-scala-plugin for a scala only project and it was working great. I've added maven to the project late so unfortunately it doesn't follow the standard directory structure. The structure is like so:
src/package...
src/generatedSourceFiles/package...
src/resources/log4.properties (only 1 resource so far)

If I add the <resources> tag to the pom and do a clean compile the resource is copied but the compile finishes saying "nothing to compile...". If I delete the resource (from the resource/ dir) and do another clean compile the code is compiled fine (but obviously no resource is copied).

I've attached my pom.xml. Is there something I'm doing wrong?

Any help would be great.

Thanks,

Dave

pom.xml