You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Hilco Wijbenga <hi...@gmail.com> on 2010/10/12 06:48:09 UTC

Property for the location of the local repository

Hi all,

I could have sworn I've used ${localRepository} before but it doesn't
seem to work. I've also tried ${settings.localRepository} and
${maven.repo.local}. How do I refer to the location of the local
repository in a portable way? Is there a difference between Maven2 and
Maven3?

Cheers,
Hilco

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


[SOLVED] Re: Property for the location of the local repository

Posted by Hilco Wijbenga <hi...@gmail.com>.
On 21 October 2010 09:49, Jon Paynter <ki...@gmail.com> wrote:
> On Wed, Oct 20, 2010 at 10:46 PM, Martin Höller <ma...@xss.co.at> wrote:
>
>> Hi!
>>
>> On Wednesday 20 October 2010 Hilco Wijbenga wrote:
>> > On 11 October 2010 21:48, Hilco Wijbenga <hi...@gmail.com>
>> wrote:
>> > > I could have sworn I've used ${localRepository} before but it doesn't
>> > > seem to work. I've also tried ${settings.localRepository} and
>> > > ${maven.repo.local}. How do I refer to the location of the local
>> > > repository in a portable way? Is there a difference between Maven2 and
>> > > Maven3?
>> >
>> > I had a look in the source code and found the following:
>> >
>> [...]
>> > Is there some documentation on how properties are handled internally?
>>
> I don't know what is actually the prefered way of accessing the path to the
>> local repository (but I'm quite sure I saw discussions about it on this
>> list before). However, running your example pom.xml works as soon as I
>> changed ${maven.local.repo} to ${settings.localRepository}. This is working
>>  with maven 2.2.1 and maven 3.0-beta-3.
>
>
>  I was wondering the same thing - and I just ended up creating my own custom
> property.
>
> If you find a built-in property, please let us know.

Mystery solved. The problem I ran into was related to
maven-antrun-plugin. Version 1.4 apparently has a serious bug with
properties (I didn't actually check whether anything was reported).

If I use version 1.6 (the latest at this time) then
${settings.localRepository} works as expected.

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


Re: Property for the location of the local repository

Posted by Jon Paynter <ki...@gmail.com>.
On Wed, Oct 20, 2010 at 10:46 PM, Martin Höller <ma...@xss.co.at> wrote:

> Hi!
>
> On Wednesday 20 October 2010 Hilco Wijbenga wrote:
> > On 11 October 2010 21:48, Hilco Wijbenga <hi...@gmail.com>
> wrote:
> > > I could have sworn I've used ${localRepository} before but it doesn't
> > > seem to work. I've also tried ${settings.localRepository} and
> > > ${maven.repo.local}. How do I refer to the location of the local
> > > repository in a portable way? Is there a difference between Maven2 and
> > > Maven3?
> >
> > I had a look in the source code and found the following:
> >
> [...]
> > Is there some documentation on how properties are handled internally?
>
I don't know what is actually the prefered way of accessing the path to the
> local repository (but I'm quite sure I saw discussions about it on this
> list before). However, running your example pom.xml works as soon as I
> changed ${maven.local.repo} to ${settings.localRepository}. This is working
>  with maven 2.2.1 and maven 3.0-beta-3.


 I was wondering the same thing - and I just ended up creating my own custom
property.

If you find a built-in property, please let us know.

Re: Property for the location of the local repository

Posted by Martin Höller <ma...@xss.co.at>.
Hi!

On Wednesday 20 October 2010 Hilco Wijbenga wrote:
> On 11 October 2010 21:48, Hilco Wijbenga <hi...@gmail.com> wrote:
> > I could have sworn I've used ${localRepository} before but it doesn't
> > seem to work. I've also tried ${settings.localRepository} and
> > ${maven.repo.local}. How do I refer to the location of the local
> > repository in a portable way? Is there a difference between Maven2 and
> > Maven3?
>
> I had a look in the source code and found the following:
>
[...]
> Is there some documentation on how properties are handled internally?
> How *does* project.build.directory get its value?
>
> Example POM:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project
>   xmlns="http://maven.apache.org/POM/4.0.0"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>org.example</groupId>
>   <artifactId>maven-local-repo</artifactId>
>   <packaging>jar</packaging>
>   <version>0.1-SNAPSHOT</version>
>   <name>${x} - {y}</name>
>   <properties>
>     <x>${maven.local.repo}</x>
>     <y>${project.build.directory}</y>
>   </properties>
>   <build>
>     <plugins>
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-antrun-plugin</artifactId>
>         <version>1.6</version>
>         <executions>
>           <execution>
>             <phase>clean</phase>
>             <goals>
>               <goal>run</goal>
>             </goals>
>             <configuration>
>               <target>
>                 <echo>${x}</echo>
>                 <echo>${y}</echo>
>               </target>
>             </configuration>
>           </execution>
>         </executions>
>       </plugin>
>     </plugins>
>   </build>
> </project>
>
> Simply run mvn clean.

I don't know what is actually the prefered way of accessing the path to the 
local repository (but I'm quite sure I saw discussions about it on this 
list before). However, running your example pom.xml works as soon as I 
changed ${maven.local.repo} to ${settings.localRepository}. This is working 
with maven 2.2.1 and maven 3.0-beta-3.

hth,
- martin


Re: Property for the location of the local repository

Posted by Hilco Wijbenga <hi...@gmail.com>.
On 11 October 2010 21:48, Hilco Wijbenga <hi...@gmail.com> wrote:
> I could have sworn I've used ${localRepository} before but it doesn't
> seem to work. I've also tried ${settings.localRepository} and
> ${maven.repo.local}. How do I refer to the location of the local
> repository in a portable way? Is there a difference between Maven2 and
> Maven3?

I had a look in the source code and found the following:

hilco@centaur ~/open-source/maven/maven3 $ find . -name '.svn' -prune
-o -type f | xargs grep LOCAL_REPO_PROPERTY
./maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java:
public static final String LOCAL_REPO_PROPERTY = "maven.repo.local";
./maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java:
   String localRepoProperty = request.getUserProperties().getProperty(
MavenCli.LOCAL_REPO_PROPERTY );
./maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java:
       localRepoProperty = request.getSystemProperties().getProperty(
MavenCli.LOCAL_REPO_PROPERTY );

So "maven.repo.local" seems to be the right property. As far as I can
tell, however, it never gets set?

hilco@centaur ~/open-source/maven/maven3 $ find . -name '.svn' -prune
-o -type f | xargs grep maven.repo.local
./maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java:
public static final String LOCAL_REPO_PROPERTY = "maven.repo.local";
(see above)
./maven-embedder/src/test/resources/settings/invalid-settings.xml:
<localRepository>/Users/jvanzyl/maven-repo-local</localRepository
(test code)
./build.xml:ant -Dmaven.repo.local=/my/integration/repository
./build.xml:    <property name="maven.repo.local"
value="${user.home}/.m2/repository" />
./build.xml:    <echo>maven.repo.local = ${maven.repo.local}</echo>
./build.xml:      <localRepository path="${maven.repo.local}" />
./build.xml:      <localRepository path="${maven.repo.local}" />
./build.xml:      <localRepository path="${maven.repo.local}" />
./build.xml:      <localRepository path="${maven.repo.local}" />
./build.xml:      <arg value="-Dmaven.repo.local=${maven.repo.local}" />
(ant stuff)
./maven-core/src/main/java/org/apache/maven/settings/MavenSettingsBuilder.java:
   String ALT_LOCAL_REPOSITORY_LOCATION = "maven.repo.local";
(never used anywhere)
./maven-core/src/main/resources/org/apache/maven/messages/messages_de.properties:maven.repo.local.unset.warning=maven.repo.local
ist nicht gesetzt.
./maven-core/src/main/resources/org/apache/maven/messages/messages_ja.properties:maven.repo.local.unset.warning=maven.repo.local
\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u305b\u3093.
./maven-core/src/main/resources/org/apache/maven/messages/messages_el.properties:maven.repo.local.unset.warning=maven.repo.local
\u00e4\u00e5\u00ed \u00dd\u00f7\u00e5\u00e9
\u00ef\u00f1\u00e9\u00f3\u00f4\u00e5\u00df.
./maven-core/src/main/resources/org/apache/maven/messages/messages_es.properties:maven.repo.local.unset.warning=\u00a1maven.repo.local
no est\u00e1 definido!
./maven-core/src/main/resources/org/apache/maven/messages/messages_nl.properties:maven.repo.local.unset.warning=maven.repo.local
is niet ingesteld.
./maven-core/src/main/resources/org/apache/maven/messages/messages_fr.properties:maven.repo.local.unset.warning=maven.repo.local
n'est pas d\u00e9fini.
./maven-core/src/main/resources/org/apache/maven/messages/messages.properties:maven.repo.local.unset.warning=maven.repo.local
is not set.
./maven-core/src/main/resources/org/apache/maven/messages/messages_no.properties:maven.repo.local.unset.warning=maven.repo.local
er ikke definert.
./maven-core/src/main/resources/org/apache/maven/messages/messages_zh_CN.properties:maven.repo.local.unset.warning=\u6ca1\u6709\u8bbe\u7f6e
maven.repo.local \u5c5e\u6027\u3002
./maven-core/src/main/resources/org/apache/maven/messages/messages_pl.properties:maven.repo.local.unset.warning=maven.repo.local
nie jest zdefiniowane.
./maven-core/src/main/resources/org/apache/maven/messages/messages_ko.properties:maven.repo.local.unset.warning
= maven.repo.local \uC774 \uC124\uC815\uB418\uC5B4\uC788\uC9C0
\uC54A\uC2B5\uB2C8\uB2E4.
(i18n messages)
./maven-core/src/site/apt/configuration-management.apt:
maven.repo.local
(system,user,default=${maven.user.config.dir}/repository)
(documentation)
./maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java:
           System.getProperty( "maven.repo.local", System.getProperty(
"user.home" ) + "/.m2/repository" );
./maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java:
           System.getProperty( "maven.repo.local", System.getProperty(
"user.home" ) + "/.m2/repository" );
(more tests)
./maven-compat/src/main/resources/META-INF/maven/plugin-expressions/rootless.paramdoc.xml:
         <key>-Dmaven.repo.local=/path/to/local/repo</key>
(documentation)
./pom.xml:      <id>maven-repo-local</id>
./pom.xml:          <name>maven.repo.local</name>
./pom.xml:                  <name>maven.repo.local</name>
./pom.xml:                  <value>${maven.repo.local}</value>
(use it)

I can't tell where maven.repo.local is being set and in my POM it
shows up as "${maven.repo.local}". I could definitely be missing
something (I can't work out where ${project.build.directory} is set
either) :-) but is ${maven.repo.local} working for anyone?

Is there some documentation on how properties are handled internally?
How *does* project.build.directory get its value?

Example POM:

<?xml version="1.0" encoding="UTF-8"?>
<project
  xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.example</groupId>
  <artifactId>maven-local-repo</artifactId>
  <packaging>jar</packaging>
  <version>0.1-SNAPSHOT</version>
  <name>${x} - {y}</name>
  <properties>
    <x>${maven.local.repo}</x>
    <y>${project.build.directory}</y>
  </properties>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.6</version>
        <executions>
          <execution>
            <phase>clean</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <echo>${x}</echo>
                <echo>${y}</echo>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Simply run mvn clean.

Cheers,
Hilco

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