2

following dependencies need to be resolved and copy child dependencies into a specific location.

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-ejb-client-bom</artifactId>
        <version>${version.org.wildfly.wildfly-ejb-client-bom}</version>
        <type>pom</type>
        <scope>import</scope>   
    </dependency>
    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-jms-client-bom</artifactId>
        <version>${version.org.wildfly.wildfly-jms-client-bom}</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>

But when i copy using maven dependency plugin, only the pom files get copied, not the dependencies defined in those poms.

my plugin is as below,

       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>                         
                        <goal>copy</goal>
                    </goals>                        
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.wildfly</groupId>
                                <artifactId>wildfly-ejb-client-bom</artifactId>
                                <version>${version.org.wildfly.wildfly-ejb-client-bom}</version>
                                <type>pom</type>
                                <outputDirectory>${project.build.directory}/Lib</outputDirectory>   
                            </artifactItem>
                            <artifactItem>
                                <groupId>org.wildfly</groupId>
                                <artifactId>wildfly-jms-client-bom</artifactId>
                                <version>${version.org.wildfly.wildfly-jms-client-bom}</version>
                                <type>pom</type>
                                <outputDirectory>${project.build.directory}/Lib</outputDirectory>
                            </artifactItem>                             
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

any clues?

Kavintha M
  • 21
  • 3
  • The problem is that you are only defined the `pom` which is simply wrong furthermore why do you use dependency plugin instead of producing an EAR file or WAR files which is deployed there... – khmarbaise Dec 21 '17 at 11:54
  • my intention here is to provide a jar file along with separate Library folder. So producing ear is not an option and what is wrong with "pom" . Is there any workaround that i can use ? – Kavintha M Dec 21 '17 at 12:38
  • A jar has no lib folder. The EAR will be best option cause you have an Application server which supports EAR files...The pom type means you get the pom file and not the jar/ear/war's ... – khmarbaise Dec 21 '17 at 12:41
  • I know that a jar has no lib folder. requirement is to provide a jar+Lib+bat to run as standalone. not in an application server. I have a workaround that has to mention each and every artifact of mentioned poms in dependency plugin as s. But still has to specify the versions along with artifacts items which is not a good practice. any idea ? – Kavintha M Dec 21 '17 at 13:07
  • Ah Ok..Than the best solution is to use maven-assembly-plugin instead of maven-dependency-plugin...and you can result in a zip/tar/tar.gz etc. – khmarbaise Dec 21 '17 at 13:23

2 Answers2

0

Using <scope>import</scope> manage dependencies from other projects. See this on Maven documentation for detail solution.

Nish
  • 64
  • 1
  • 5
0

I had the same problem and struggled for a whole day. The scope <scope>import</scope> does only work with dependencyManagement section, we don't really want here. The answer is simple, let the Maven dependency:copy-dependencies plugin get you all transitive dependencies for you - except the pom files.

As the docs state set <excludeTransitive>false</excludeTransitive> and <excludeTypes>pom</excludeTypes>, that should do the trick.

There's also a way to do this without the plugin configuration in your pom, but on the commandline:

mvn --batch-mode --no-transfer-progress -f /path/to/your/pom.xml dependency:copy-dependencies -DexcludeTypes=pom -DoutputDirectory=/Lib

Here's a GitHub gist with a full example. As the default in Maven for excludeTransitives is false, you're example should have worked, but also included the pom files.

jonashackt
  • 12,022
  • 5
  • 67
  • 124