Giriş
Açıklaması şöyle
The Maven Dependency Plugin helps manage your project’s dependencies by providing useful tasks, such as analyzing, copying, and unpacking dependencies. This is essential for avoiding dependency conflicts and ensuring that your application runs smoothly.
Bu plugin'i kurmaya gerek yok. Otomatik olarak indirilir. Projenin bağımlılıklarını yönetir. Açıklaması şöyle
analyze analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared.analyze-dep-mgt analyzes your projects dependencies and lists mismatches between resolved dependencies and those listed in your dependencyManagement section.analyze-only is the same as analyze, but is meant to be bound in a pom. It does not fork the build and execute test-compile.analyze-report analyzes the dependencies of this project and produces a report that summarises which are: used and declared; used and undeclared; unused and declared.analyze-duplicate analyzes the <dependencies/> and <dependencyManagement/> tags in the pom.xml and determines the duplicate declared dependencies.build-classpath tells Maven to output the path of the dependencies from the local repository in a classpath format to be used in java -cp. The classpath file may also be attached and installed/deployed along with the main artifact.copy takes a list of artifacts defined in the plugin configuration section and copies them to a specified location, renaming them or stripping the version if desired. This goal can resolve the artifacts from remote repositories if they don't exist in either the local repository or the reactor.copy-dependencies takes the list of project direct dependencies and optionally transitive dependencies and copies them to a specified location, stripping the version if desired. This goal can also be run from the command line.display-ancestors displays all ancestor POMs of the project. This may be useful in a continuous integration system where you want to know all parent poms of the project. This goal can also be run from the command line.get resolves a single artifact, eventually transitively, from a specified remote repository.go-offline tells Maven to resolve everything this project is dependent on (dependencies, plugins, reports) in preparation for going offline.list alias for resolve that lists the dependencies for this project.list-classes displays the fully package-qualified names of all classes found in a specified artifact.list-repositories displays all project dependencies and then lists the repositories used.properties set a property for each project dependency containing the to the artifact on the file system.purge-local-repository tells Maven to clear dependency artifact files out of the local repository, and optionally re-resolve them.resolve tells Maven to resolve all dependencies and displays the version. JAVA 9 NOTE: will display the module name when running with Java 9.resolve-plugins tells Maven to resolve plugins and their dependencies.sources tells Maven to resolve all dependencies and their source attachments, and displays the version.tree displays the dependency tree for this project.unpack like copy but unpacks.unpack-dependencies like copy-dependencies but unpacks.
analyze seçeneği
"Used undeclared dependencies found"
"Unused declared dependencies found"
şeklinde kullanılmayan dependency listesini verir. Bence çıktısı doğru değil.
get seçeneği
"mvn install" ile de tetiklenir
Örnek
Şöyle yaparız. Burada mvn test ile testleri çalıştırınca gidip configuration altında belirtilen dosyaları indirir. Ancak bu indirilen dosyalar dependency olarak görünmezler. Sadece test için gereklidirler
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>get</id>
<phase>generate-test-resources</phase>
<goals>
<goal>get</goal>
</goals>
<configuration>
<artifact>com.hazelcast:hazelcast:3.7</artifact>
<artifact>com.hazelcast:hazelcast:3.7:jar:tests</artifact>
</configuration>
</execution>
</executions>
</plugin>
Örnek
Şöyle yaparız. Burada komut satırından indirme işlemi yapılıyor.
mvn dependency:get -Dartifact=com.hazelcast:hazelcast:3.10.4
mvn dependency:get -Dartifact=com.hazelcast:hazelcast:3.10.4:jar:tests
go-offline seçeneği
Bazı bug'ları olsa da tüm bağımlılıkları indirir. Genelde Docker ile kullanılırlist seçeneği
Örnek
Şöyle yaparız.
Açıklaması şöyle.
Şöyle yaparız
Örnek
Şöyle yaparız.
Şöyle yaparız.
XML
Örnek - copy
Derleme bitince ismi "MyDLL-1.2.3-Win64.x64-vc11.dll" olan dosyasını "MyDLL.dll"olarak belirli bir dizine kopyalamak için şöyle yaparız.
Örnek
Şöyle yaparız.
mvn -o dependency:list
resolve seçeneğiAçıklaması şöyle.
It downloads all dependencies required either by your application or by plugins called during a build process.Örnek
Şöyle yaparız
mvn -B dependency:resolve dependency:resolve-plugins
tree seçeneğiÖrnek
Şöyle yaparız.
$ mvn dependency:tree -Dverbose > foo.txt
Windows'ta ekranı temizlemek için şöyle yaparız.$ cls & mvn dependency:tree -Dverbose > foo.txt
tree seçeneği İle Bağımlılığın Nereden Geldiğini Bulmak
Örnek
Şöyle yaparız
#To check where a specific dependency is coming from,
./mvnw dependency:tree -Dincludes=<groupId>:<artifactId>
# e.g
./mvnw dependency:tree -Dincludes=org.slf4j:slf4j-api
Örnek
mvn dependency:tree -Dverbose -Dincludes=guava
mvn dependency:tree -Dverbose -Dincludes=guava-jdk5
Örnek - copy
Derleme bitince ismi "MyDLL-1.2.3-Win64.x64-vc11.dll" olan dosyasını "MyDLL.dll"olarak belirli bir dizine kopyalamak için şöyle yaparız.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dll</id>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItem>
<groupId>com.foo.bar</groupId>
<artifactId>MyDLL</artifactId>
<destFileName>MyDLL.dll</destFileName>
<classifier>Win64</classifier>
<outputDirectory>target</outputDirectory>
<type>x64.vc11.dll</type>
</artifactItem>
</configuration>
</execution>
</executions>
</plugin>
Örnek - copy-dependencies
Derleme safhasında projenin bağımlılıklarını kopyalamak için şöyle yaparız.
Şöyle yaparızz. DLL'leri aynı jar gibi belli bir dizine indirir.
tgz dosyasını açmak için şöyle yaparız.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>compile</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<includeScope>system</includeScope>
</configuration>
</execution>
</executions>
</plugin>
Örnek - copy-dependencies
Paketleme safhasında dependecy'leri kopyalamak için şöyle yaparız. Dependency'ler target dizini altındaki lib dizinine kopyalanır. Böylece runnable jar üretebiliriz.
Örnek - unpackPaketleme safhasında dependecy'leri kopyalamak için şöyle yaparız. Dependency'ler target dizini altındaki lib dizinine kopyalanır. Böylece runnable jar üretebiliriz.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
Şöyle yaparızz. DLL'leri aynı jar gibi belli bir dizine indirir.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jdesktop</groupId>
<artifactId>jdic-native</artifactId>
<version>${jdic.version}</version>
<classifier>${build.type}</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
unpack
Örnek
Şöyle yaparız Her şeyi target/dependency dizinine kopyalıyor. Bu dizinde şu alt dizinler oluşturur
BOOT-INF/lib : Kullandığım kütüphanelerin sınıfları
META-INF : Jar hakkında bilgiler
BOOT-INF/classes : Benim sınıflarım
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version</version>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
unpack-dependencies
Örnek
<plugin>
<!-- this is to extract the JRE tgz file we downloaded -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>com.oracle.java</includeGroupIds>
<includeTypes>tgz</includeTypes>
<includeArtifactIds>jre</includeArtifactIds>
<includeClassifiers>win32</includeClassifiers>
<outputDirectory>target/win32</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Hiç yorum yok:
Yorum Gönder