1

I want to create a specific custom file structure for developping and I want to know if it could be done with maven.

It is important to mention that i am using c++ for programming language and the Maven-nar-plugin

I want to be able run a command like : mvn dependency:resolve and the required librairies would go in the folder Librairies. That way all i would have to do is link the include folder of a library to my project in Visual Studio.

I dont want to compile with maven I just want to use it's dependency manager

I know you can change the SourceDirectory but can you change where the Librairies will be installed ?

Workspace
|
|-- Project1
|    |-- pom.xml
|
|-- Project2
|    |-- pom.xml
|
|-- Librairies
     |-- ExempleLib-V-2.0
     |         |-- Include
     |         |-- lib
     |
     |-- ExempleLib-V-3.1

2 Answers2

1

Sure, you can tell maven that your local repository is in this Librairies directory rather than in ~/.m2/repository

You can pass parameter maven.repo.local when launching it and it will download everything there

mvn -Dmaven.repo.local=Librairies clean install

Arnaud Jeansen
  • 1,619
  • 15
  • 27
  • this could be a way to do it but i am also using maven for other java applications so the *Libraries* folder would also be filled with non c++ related package and package i dont even use in those projects – The_invaders Feb 07 '18 at 19:06
  • This would only apply when you launch mvn with this flag. So just use the flag when you want to download the dependencies and never use it again... – Arnaud Jeansen Feb 07 '18 at 20:52
1

I found a way using maven-dependency-plugin.

The following code will take every dependency and copy it over to the Librairies folder.
You could even use unpack-dependencies instead of copy-dependencies to directly unpack the dependency in the folder

      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.7</version>
          <executions>
            <execution>
            <id>default-cli</id>
              <goals>
                <goal>copy-dependencies</goal>
              </goals>
              <configuration>
                <outputDirectory>
                  ../Libraries
                </outputDirectory>
              </configuration>
            </execution>
          </executions>
      </plugin>