0

i wont to reduce the size of the pom file and clear the project from unused dependencies. I write code on IntelliJ IDEA on a Spring Boot app. I Installed the plugin from Apache Maven Dependency like the tutorial :

Link of tutorial here and the plugin on the pom.xml

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.1.1</version>
            <executions>
                <execution>
                    <id>copy</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>[ groupId ]</groupId>
                                <artifactId>[ artifactId ]</artifactId>
                                <version>[ version ]</version>
                                <type>[ packaging ]</type>
                                <classifier> [classifier - optional] </classifier>
                                <overWrite>[ true or false ]</overWrite>
                                <outputDirectory>[ output directory ]</outputDirectory>
                                <destFileName>[ filename ]</destFileName>
                            </artifactItem>
                        </artifactItems>
                        <!-- other configurations here -->
                    </configuration>
                </execution>
            </executions>
        </plugin>

, but i couldn't understand how it is work. Any idea on how to do it work ? I saw some other questions but nothing has worked for me!

Tried already this solution but i could make it work Link solution and also the Jonnyzz Dependencies Plugin for IntelliJ.

  • Either add the entire `pom.xml` or let us know how did you come to conclusion that in the project,there are unused dependencies. There is no point in the above plugin. is `dependency:analyze` used ? it determines which are: used and declared; used and undeclared; unused and declared. – Vinay Veluri Nov 27 '19 at 11:59
  • Does this answer your question? [Is there a simple way to remove unused dependencies from a maven pom.xml?](https://stackoverflow.com/questions/1517611/is-there-a-simple-way-to-remove-unused-dependencies-from-a-maven-pom-xml) – Vinay Veluri Nov 27 '19 at 12:02
  • If you don't need the dependencies, why are they there in the first place? – M. Deinum Nov 27 '19 at 12:06
  • VinayVeluri i saw a comment right from my dependency that said "Unused Dependecy", and i thought that there are more. I saw the example that you posted but i count understand how to make it work. I am kinda new on pom.xml configuration. – Konstantinos Kalivas Nov 27 '19 at 12:07
  • Because the pom.xml is part of a project that it's need to be refactor and i am cleaning it so it can be more flexible to understand from someone new on the project – Konstantinos Kalivas Nov 27 '19 at 12:09
  • I also tried the Jonnyzzz Dependencies on intelliJ but it dint work to remove the unused dependencies – Konstantinos Kalivas Nov 27 '19 at 12:19
  • 2
    Use the dependency plugin to analyze your dependencies, then manually remove them. I wouldn't go so far to exclude transitive dependencies (unless you really know what you are doing) as that will come back and bite you in the future. You don't need to add the dependency just run `mvn dependency:analyze` to get a report upon which you can act. – M. Deinum Nov 27 '19 at 12:23
  • Just adding up that just because a dependency is not listed in the section "Unused declared dependencies found" of `mvn dependency:analyze` command doesn't mean you don't use them, some of your other libs might use them and you can break your build. Be careful there. – lauksas Nov 27 '19 at 12:46

0 Answers0