You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Gary Gregory <ga...@gmail.com> on 2021/08/01 17:35:48 UTC

Profile pitfall or user error?

Hi All:

I want to use a property in a profile in a Java 8 Maven 3.8.1 project, but
it does not work within a file activation element. In the example below
this file activation works:

<exists>${java.home}/../lib/tools.jar</exists>

but this one does not:

<exists>${toolsJar}</exists>

The profile:

  <profiles>
    <profile>
      <id>jdk9</id>
      <activation>
        <jdk>[1.9,)</jdk>
      </activation>
      <!-- No dependencies needed by Jigsaw -->
      <dependencies />
    </profile>
    <profile>
      <id>default-jdk</id>
      <properties>
        <toolsJar>${java.home}/../lib/tools.jar</toolsJar>
      </properties>
      <activation>
        <file>
          <!-- ${toolsJar} does not work here. -->
          <exists>${java.home}/../lib/tools.jar</exists>
        </file>
      </activation>
      <dependencies>
        <dependency>
          <groupId>jdk.tools</groupId>
          <artifactId>jdk.tools</artifactId>
          <scope>system</scope>
          <version>8</version>
          <systemPath>${toolsJar}</systemPath>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

Am I doing something wrong?

Gary

Re: Profile pitfall or user error?

Posted by Gary Gregory <ga...@gmail.com>.
I found a workaround by declaring the toolsJar property in the project
properties instead of the profile itself. I suppose I was looking for
"local" profile properties which obviously is not a thing in Maven ;-)

Gary

On Sun, Aug 1, 2021 at 1:35 PM Gary Gregory <ga...@gmail.com> wrote:

> Hi All:
>
> I want to use a property in a profile in a Java 8 Maven 3.8.1 project, but
> it does not work within a file activation element. In the example below
> this file activation works:
>
> <exists>${java.home}/../lib/tools.jar</exists>
>
> but this one does not:
>
> <exists>${toolsJar}</exists>
>
> The profile:
>
>   <profiles>
>     <profile>
>       <id>jdk9</id>
>       <activation>
>         <jdk>[1.9,)</jdk>
>       </activation>
>       <!-- No dependencies needed by Jigsaw -->
>       <dependencies />
>     </profile>
>     <profile>
>       <id>default-jdk</id>
>       <properties>
>         <toolsJar>${java.home}/../lib/tools.jar</toolsJar>
>       </properties>
>       <activation>
>         <file>
>           <!-- ${toolsJar} does not work here. -->
>           <exists>${java.home}/../lib/tools.jar</exists>
>         </file>
>       </activation>
>       <dependencies>
>         <dependency>
>           <groupId>jdk.tools</groupId>
>           <artifactId>jdk.tools</artifactId>
>           <scope>system</scope>
>           <version>8</version>
>           <systemPath>${toolsJar}</systemPath>
>         </dependency>
>       </dependencies>
>     </profile>
>   </profiles>
>
> Am I doing something wrong?
>
> Gary
>
>