maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hilco Wijbenga <hilco.wijbe...@gmail.com>
Subject Re: Property for the location of the local repository
Date Wed, 20 Oct 2010 17:45:34 GMT
On 11 October 2010 21:48, Hilco Wijbenga <hilco.wijbenga@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


Mime
View raw message