The_invaders
The_invaders

Reputation: 39

Maven custom file structure

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

Upvotes: 1

Views: 186

Answers (2)

The_invaders
The_invaders

Reputation: 39

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>

Upvotes: 1

Arnaud Jeansen
Arnaud Jeansen

Reputation: 1726

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

Upvotes: 1

Related Questions