简体   繁体   中英

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

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM