0

I am new to maven and hit a problem that looks easy in the first place but I already kept me busy for a whole day about and no way to get it working.

First as part of running eclipse:eclipse plugin I create a linked folder like below:

<linkedResources>
<linkedResource>
    <name>properties</name>
    <type>2</type>
    <location>${PARENT-2-PROJECT_LOC}/some_other_project/properties</location>
</linkedResource>
<linkedResource>
    <name>properties/messages.properties</name>
    <type>1</type>
    <location>${PARENT-2-PROJECT_LOC}/some_other_project/properties/messages.properties</location>
</linkedResource>

And then I am adding that folder as a source folder like below:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
  <execution>
    <id>add-source</id>
    <phase>generate-sources</phase>
    <goals>
      <goal>add-source</goal>
    </goals>
    <configuration>
      <sources>
        <source>properties</source>
        <source>some_real_folder</source>
      </sources>
    </configuration>
  </execution>
</executions>
</plugin>

However when I am looking at the generated .classpath in eclipse the “some_real_folder” is there but the “properties” is not. It looks like by default the build-helper-maven-plugin will check if the folder is there and if it is not it won’t add it.

I am using maven 3.0.4 outside eclipse to run the build and I can see in the maven logs something like this:

[INFO] Source directory: <some path>\properties added.

This is my project structure:

project1 
  \-- properties (this is the real folder) 

project2
   \-- some_real_folder
   \-- properties (this is the link resource pointing to the project1/properties folder)

All I need is to have both "some_real_folder" and the linked resource "properties" added to the .classpath of the project2

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
Julian
  • 3,678
  • 7
  • 40
  • 72
  • Can you show the directory structure of your project? Which Eclipse version do you use? Do you use m2e ? – khmarbaise Aug 08 '12 at 06:22
  • It is not a lot to show. I have: project1 \-- properties (this is the real folder) project2 \-- some_real_folder \-- properties (this is the link resource) I need both "some_real_folder" and the linked resource "properties" to be part of the .classpath of the project2 – Julian Aug 08 '12 at 06:25
  • Sorry not sure how to make it look nicer. – Julian Aug 08 '12 at 06:32
  • Simply edit your post there you make better formatting. – khmarbaise Aug 08 '12 at 06:45

1 Answers1

0

It is a bad practice to include stuff from outside a artefact directly into a artefact. You should only include into project2 stuff below folder project2 and something from project2's dependencies. (I'm not sure whether what you are doing is possible at all.)

So, if you want to have project1/properties available in project2, you usually pack project1/properties in project1's artefact and add a dependency on project1 to project2. If this does not work for some reason (for example since you want to move project1's stuff to another location in project2) you can unpack it with maven-dependency-plugin dependency:copy-dependencies into project2's target to some appropriate place.

Dr. Hans-Peter Störr
  • 25,298
  • 30
  • 102
  • 139