0

I would like to have a property/argument on Maven that will install a different dependency depending on the argument.

That is, when a user specifies -DgpuCuda=True, the dependency on the pom.xml will change accordingly.

So mvn -gpuCuda=True install will install DL4J-GPU instead of DL4J-CPU.

If -gpuCuda=True is specified, then this will be installed:

<dependency>
 <groupId>org.nd4j</groupId>
 <artifactId>nd4j-cuda-10.1</artifactId>
 <version>1.0.0-beta4</version>
</dependency>

If -gpuCuda=False, this will be installed:

<dependency>
 <groupId>org.nd4j</groupId>
 <artifactId>nd4j-native</artifactId>
 <version>1.0.0-beta4</version>
</dependency>

Is this possible? What would a workaround be? Thanks!!

Eduardo Morales
  • 764
  • 7
  • 29
  • 2
    Possible duplicate of [Different dependencies for different build profiles](https://stackoverflow.com/questions/166895/different-dependencies-for-different-build-profiles). As for how to call it then, simply go for `-P,gpuCuda` where `gpuCuda` is optional – XtremeBaumer Aug 07 '19 at 14:34

1 Answers1

2

You add something like

 <profiles>

    <profile>
      <id>gpu</id>
      <activation>
        <property>
          <name>gpuCuda</name>
          <value>True</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.nd4j</groupId>
          <artifactId>nd4j-cuda-10.1</artifactId>
          <version>1.0.0-beta4</version>
        </dependency>
      </dependencies>
    </profile>

    <profile>
      <id>cpu</id>
      <activation>
        <property>
          <name>gpuCuda</name>
          <value>False</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
           <groupId>org.nd4j</groupId>
           <artifactId>nd4j-native</artifactId>
           <version>1.0.0-beta4</version>
        </dependency>
      </dependencies>
    </profile>
</profiles

Then you activate/deactivate the profiles by the command line properties you stated, like mvn -DgpuCuda=True install.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142