Maven dependency plugin - download the jar during packaging phase

I want Maven to download and put jetty-runner.jar dependency into myproject/target/dependency folder.

Part of my pom.xml:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals><goal>copy</goal></goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.eclipse.jetty</groupId>
                                    <artifactId>jetty-runner</artifactId>
                                    <version>9.1.1.v20140108</version>
                                    <destFileName>jetty-runner.jar</destFileName>
                                    <outputDirectory>${project.build.directory}/dependency</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

However, when I do mvn package from my project directory the jetty-runner.jar is not copied to /target/dependency folder.

What WORKS however is when I add the following line to <configuration>:

<id>default-cli</id>

and run it with mvn dependency:copy.

What am I missing?

Answers


When you configure the maven-dependency-plugin within the <pluginManagement> section, maven will do nothing with it. Your <pluginManagement> section does only define how the maven-dependency-plugin will be configured in case it is invoked. To actually invoke the plugin during the packaging phase, you need to define the invocation in the <plugins> section.

So you can either move the whole plugin configuration from <pluginManamgement> to <plugins> or you can additionally define the maven-dependency-plugin without version and configuration in the <plugins> section:

<build>
  <plugins>
    <!-- no need for version or configuration since both are defined in pluginManagement -->
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
    </plugin>
    ...
  </plugins>
  ...
</build>

Need Your Help

I am getting "Failed with exception java.io.IOException:/user/hive/warehouse/people/part-r-00001.parquet not a SequenceFile

apache-spark hive pyspark apache-spark-sql hiveql

I created a Spark SQL table by calling .saveAsTable on my dataframe. That command succeeded completely. However, now when I query the table, the parquet files seem corrupt. I'm seeing this error:

OutOfMemory although Heap Size is less than 6MB

android heap

In my Android developer console, I see some crashes with