You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by KedarMhaswade <ke...@gmail.com> on 2007/11/05 17:11:31 UTC

Maven's current working directory and changing resources location ...

I have two questions, answers to which were not obvious.

1- What is the current working directory (i.e.
System.getProperty("user.dir"))? Can this be printed
    when one does "mvn -X ..."?
2- In our company we have resources (properties files for resource bundles)
along side the Java sources
    because we have an ongoing strategy for Localized Strings where the
developers prefer to keep the
    strings used by com.example.Foo at the same location in a file named
"LocalStrings.properties".
    I added:
  <build>
    <resources>
      <resource directory="src/main/java"/>
    </resources>
  </build>

   for my resources to get copied into target folder upon "mvn package". But
I get:
   Project ID: org.bykedar:learnmvn
POM Location: /Users/kedar/Personal/bnevins/projects/learnmvn/pom.xml
Validation Messages:

    [0]  'build.resources.resource.directory' is missing.


Reason: Failed to validate POM for project org.bykedar:learnmvn at
/Users/kedar/Personal/bnevins/projects/learnmvn/pom.xml

   Is there  an example somewhere of how to do this?

Thanks,

Kedar
-- 
View this message in context: http://www.nabble.com/Maven%27s-current-working-directory-and-changing-resources-location-...-tf4752607s177.html#a13589892
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven's current working directory and changing resources location ...

Posted by Dimitris Kapanidis <di...@scytl.com>.
Dimitris Kapanidis wrote:
> KedarMhaswade wrote:
>> Thank you. I somehow misread "directory" as an attribute of <resource>.
>>
>> Regards,
>> Kedar
>>
>> Saritha SV wrote:
>>  
>>> Hi
>>>
>>> For changing Resources  location you can give the following :
>>>
>>> <build>
>>>     <resources>
>>>       <resource>
>>>         <directory>src/main/java</directory>
>>>
>>>       </resource>
>>>     </resources>
>>>   </build>
>>>
>>>     
>
> This in my case cannot work, as the dependency is a module of the same 
> project (it is an applet that needs to be put inside a war)
>
> I tried it with maven-dependency-plugin injecting the dependency in 
> the correct directory. All went well until the time of the release. 
> During the release it was giving me a dependency not found error, 
> since it was not installed yet (it is included in the same release). 
> So I rejected that solution and went to maven-assembly-plugin. (hooked 
> assembly in package and set "pom" packaging type).
>
Here is a more detailed description of my solution, maybe it can work in 
your case too:
...
    <packaging>pom</packaging>
...
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                <appendAssemblyId>false</appendAssemblyId>
                   <descriptors>
                       
<descriptor>src/main/config/assemble/webapp.xml</descriptor>
                   </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id><!-- this is used for 
inheritance merges -->
                        <phase>package</phase><!-- append to the 
packaging phase. -->
                        <goals>
                            <goal>single  </goal><!-- goals == mojos -->
                        </goals>
                    </execution>
                </executions>
            </plugin>
...

and webapp.xml is:

<assembly>
    <id>webapp</id>
    <formats>
        <format>war</format>
    </formats>
....

      <dependencySet>
            <includes>
                <include>artifactName </include>
            </includes>
            <scope>provided</scope>
            <outputFileNameMapping>filename</outputFileNameMapping>
        </dependencySet>
</assembly>

You have to define the dependency in the pom.xml also. Hope it helps, 
although I don't consider it a clean solution.

> Somewhere I read if I remember correclty that in the release plugin 
> you should put install in the preparationGoals in special cases like 
> this, but never tried it. Anyone had any similar problems?
>
>
>>> and place the properties file in  the directory src/main/java .
>>>
>>> Then the properties file   will be  incuded in your generated jar 
>>> file .
>>>
>>> Thanks
>>> Saritha SV
>>>
>>>
>>>
>>> On 11/5/07, KedarMhaswade <ke...@gmail.com> wrote:
>>>    
>>>> I have two questions, answers to which were not obvious.
>>>>
>>>> 1- What is the current working directory (i.e.
>>>> System.getProperty("user.dir"))? Can this be printed
>>>>    when one does "mvn -X ..."?
>>>> 2- In our company we have resources (properties files for resource
>>>> bundles)
>>>> along side the Java sources
>>>>    because we have an ongoing strategy for Localized Strings where the
>>>> developers prefer to keep the
>>>>    strings used by com.example.Foo at the same location in a file 
>>>> named
>>>> "LocalStrings.properties".
>>>>    I added:
>>>> <build>
>>>>    <resources>
>>>>      <resource directory="src/main/java"/>
>>>>    </resources>
>>>> </build>
>>>>
>>>>   for my resources to get copied into target folder upon "mvn 
>>>> package".
>>>> But
>>>> I get:
>>>>   Project ID: org.bykedar:learnmvn
>>>> POM Location: /Users/kedar/Personal/bnevins/projects/learnmvn/pom.xml
>>>> Validation Messages:
>>>>
>>>>    [0]  'build.resources.resource.directory' is missing.
>>>>
>>>>
>>>> Reason: Failed to validate POM for project org.bykedar:learnmvn at
>>>> /Users/kedar/Personal/bnevins/projects/learnmvn/pom.xml
>>>>
>>>>   Is there  an example somewhere of how to do this?
>>>>
>>>> Thanks,
>>>>
>>>> Kedar
>>>> -- 
>>>> View this message in context:
>>>> http://www.nabble.com/Maven%27s-current-working-directory-and-changing-resources-location-...-tf4752607s177.html#a13589892 
>>>>
>>>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>>
>>>>       
>>>     
>>
>>   
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Dimitris Kapanidis
Software Q.A. Manager

Scytl Secure Electronic Voting
Tuset 20 - 08006 Barcelona
Phone: + 34 934 230 324
Fax:   + 34 933 251 028
http://www.scytl.com

NOTICE: The information in this e-mail and in any of its attachments is confidential and intended solely for the attention and use of the named addressee(s). If you are not the intended recipient, any disclosure, copying, distribution or retaining of this message or any part of it, without the prior written consent of Scytl Secure Electronic Voting, SA is prohibited and may be unlawful. If you have received this in error, please contact the sender and delete the material from any computer.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven's current working directory and changing resources location ...

Posted by Dimitris Kapanidis <di...@itconsulting.gr>.
KedarMhaswade wrote:
> Thank you. I somehow misread "directory" as an attribute of <resource>.
>
> Regards,
> Kedar
>
> Saritha SV wrote:
>   
>> Hi
>>
>> For changing Resources  location you can give the following :
>>
>> <build>
>>     <resources>
>>       <resource>
>>         <directory>src/main/java</directory>
>>
>>       </resource>
>>     </resources>
>>   </build>
>>
>>     

This in my case cannot work, as the dependency is a module of the same 
project (it is an applet that needs to be put inside a war)

I tried it with maven-dependency-plugin injecting the dependency in the 
correct directory. All went well until the time of the release. During 
the release it was giving me a dependency not found error, since it was 
not installed yet (it is included in the same release). So I rejected 
that solution and went to maven-assembly-plugin. (hooked assembly in 
package and set "pom" packaging type).

Somewhere I read if I remember correclty that in the release plugin you 
should put install in the preparationGoals in special cases like this, 
but never tried it. Anyone had any similar problems?


>> and place the properties file in  the directory src/main/java .
>>
>> Then the properties file   will be  incuded in your generated jar file .
>>
>> Thanks
>> Saritha SV
>>
>>
>>
>> On 11/5/07, KedarMhaswade <ke...@gmail.com> wrote:
>>     
>>> I have two questions, answers to which were not obvious.
>>>
>>> 1- What is the current working directory (i.e.
>>> System.getProperty("user.dir"))? Can this be printed
>>>    when one does "mvn -X ..."?
>>> 2- In our company we have resources (properties files for resource
>>> bundles)
>>> along side the Java sources
>>>    because we have an ongoing strategy for Localized Strings where the
>>> developers prefer to keep the
>>>    strings used by com.example.Foo at the same location in a file named
>>> "LocalStrings.properties".
>>>    I added:
>>> <build>
>>>    <resources>
>>>      <resource directory="src/main/java"/>
>>>    </resources>
>>> </build>
>>>
>>>   for my resources to get copied into target folder upon "mvn package".
>>> But
>>> I get:
>>>   Project ID: org.bykedar:learnmvn
>>> POM Location: /Users/kedar/Personal/bnevins/projects/learnmvn/pom.xml
>>> Validation Messages:
>>>
>>>    [0]  'build.resources.resource.directory' is missing.
>>>
>>>
>>> Reason: Failed to validate POM for project org.bykedar:learnmvn at
>>> /Users/kedar/Personal/bnevins/projects/learnmvn/pom.xml
>>>
>>>   Is there  an example somewhere of how to do this?
>>>
>>> Thanks,
>>>
>>> Kedar
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Maven%27s-current-working-directory-and-changing-resources-location-...-tf4752607s177.html#a13589892
>>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>       
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven's current working directory and changing resources location ...

Posted by KedarMhaswade <ke...@gmail.com>.

Thank you. I somehow misread "directory" as an attribute of <resource>.

Regards,
Kedar

Saritha SV wrote:
> 
> Hi
> 
> For changing Resources  location you can give the following :
> 
> <build>
>     <resources>
>       <resource>
>         <directory>src/main/java</directory>
> 
>       </resource>
>     </resources>
>   </build>
> 
> and place the properties file in  the directory src/main/java .
> 
> Then the properties file   will be  incuded in your generated jar file .
> 
> Thanks
> Saritha SV
> 
> 
> 
> On 11/5/07, KedarMhaswade <ke...@gmail.com> wrote:
>>
>>
>> I have two questions, answers to which were not obvious.
>>
>> 1- What is the current working directory (i.e.
>> System.getProperty("user.dir"))? Can this be printed
>>    when one does "mvn -X ..."?
>> 2- In our company we have resources (properties files for resource
>> bundles)
>> along side the Java sources
>>    because we have an ongoing strategy for Localized Strings where the
>> developers prefer to keep the
>>    strings used by com.example.Foo at the same location in a file named
>> "LocalStrings.properties".
>>    I added:
>> <build>
>>    <resources>
>>      <resource directory="src/main/java"/>
>>    </resources>
>> </build>
>>
>>   for my resources to get copied into target folder upon "mvn package".
>> But
>> I get:
>>   Project ID: org.bykedar:learnmvn
>> POM Location: /Users/kedar/Personal/bnevins/projects/learnmvn/pom.xml
>> Validation Messages:
>>
>>    [0]  'build.resources.resource.directory' is missing.
>>
>>
>> Reason: Failed to validate POM for project org.bykedar:learnmvn at
>> /Users/kedar/Personal/bnevins/projects/learnmvn/pom.xml
>>
>>   Is there  an example somewhere of how to do this?
>>
>> Thanks,
>>
>> Kedar
>> --
>> View this message in context:
>> http://www.nabble.com/Maven%27s-current-working-directory-and-changing-resources-location-...-tf4752607s177.html#a13589892
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Maven%27s-current-working-directory-and-changing-resources-location-...-tf4752607s177.html#a13592426
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven's current working directory and changing resources location ...

Posted by Saritha SV <sa...@gmail.com>.
Hi

For changing Resources  location you can give the following :

<build>
    <resources>
      <resource>
        <directory>src/main/java</directory>

      </resource>
    </resources>
  </build>

and place the properties file in  the directory src/main/java .

Then the properties file   will be  incuded in your generated jar file .

Thanks
Saritha SV



On 11/5/07, KedarMhaswade <ke...@gmail.com> wrote:
>
>
> I have two questions, answers to which were not obvious.
>
> 1- What is the current working directory (i.e.
> System.getProperty("user.dir"))? Can this be printed
>    when one does "mvn -X ..."?
> 2- In our company we have resources (properties files for resource
> bundles)
> along side the Java sources
>    because we have an ongoing strategy for Localized Strings where the
> developers prefer to keep the
>    strings used by com.example.Foo at the same location in a file named
> "LocalStrings.properties".
>    I added:
> <build>
>    <resources>
>      <resource directory="src/main/java"/>
>    </resources>
> </build>
>
>   for my resources to get copied into target folder upon "mvn package".
> But
> I get:
>   Project ID: org.bykedar:learnmvn
> POM Location: /Users/kedar/Personal/bnevins/projects/learnmvn/pom.xml
> Validation Messages:
>
>    [0]  'build.resources.resource.directory' is missing.
>
>
> Reason: Failed to validate POM for project org.bykedar:learnmvn at
> /Users/kedar/Personal/bnevins/projects/learnmvn/pom.xml
>
>   Is there  an example somewhere of how to do this?
>
> Thanks,
>
> Kedar
> --
> View this message in context:
> http://www.nabble.com/Maven%27s-current-working-directory-and-changing-resources-location-...-tf4752607s177.html#a13589892
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>