使用Maven下载依赖项而不会对我的项目进行重复

时间:2011-10-11 14:54:17

标签: maven dependency-management

我正在考虑使用Spring Batch,这似乎主要是distributed/managed using Maven。我不是Maven用户(我总是擅自使用Ant),并且我觉得我不需要纯粹为了能够使用Spring Batch而对我的项目进行mavenise。

是否有可用于下载各种依赖项的工具或Maven命令?没有最近发布的Spring Batch标记为“with dependencies”。

我应该创建一个使用Spring Batch的Maven项目,然后下载这样的依赖项,然后提取我需要的jar吗?

2 个答案:

答案 0 :(得分:1)

使用maven ant工具或常春藤连接构建到maven依赖/存储库系统的ant。

答案 1 :(得分:0)

这是我使用的。如果你把它放在pom.xml中,你可以运行

mvn dependency:copy-dependencies

从命令行开始,你最终会在你的libs目录中使用jar。

<project
  xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>GuavaExtensions</groupId>
  <artifactId>guavaExtensions</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
    <dependency>
      <groupId>com.chuusai</groupId>
      <artifactId>shapeless_2.10.0-M3</artifactId>
      <version>1.2.2</version>
      <exclusions>
        <exclusion>
          <artifactId>scala-library</artifactId>
          <groupId>org.scala-lang</groupId>
        </exclusion>
        <exclusion>
          <artifactId>scala-actors</artifactId>
          <groupId>org.scala-lang</groupId>
        </exclusion>
        <exclusion>
          <artifactId>scala-reflect</artifactId>
          <groupId>org.scala-lang</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>12.0</version>
    </dependency>
    <dependency>
      <artifactId>asm</artifactId>
      <groupId>org.ow2.asm</groupId>
      <version>4.0</version>
      <classifier>sources</classifier>
    </dependency>
    <dependency>
      <artifactId>asm</artifactId>
      <groupId>org.ow2.asm</groupId>
      <version>4.0</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_2.10.0-M4</artifactId>
      <version>1.9-2.10.0-M4-B2</version>
      <exclusions>
        <exclusion>
          <artifactId>scala-library</artifactId>
          <groupId>org.scala-lang</groupId>
        </exclusion>
        <exclusion>
          <artifactId>scala-actors</artifactId>
          <groupId>org.scala-lang</groupId>
        </exclusion>
        <exclusion>
          <artifactId>scala-reflect</artifactId>
          <groupId>org.scala-lang</groupId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <executions>
            <execution>
              <id>default-cli</id>
              <phase>install</phase>
              <goals>
                <goal>copy-dependencies</goal>
              </goals>
              <configuration>
                <outputDirectory>./libs</outputDirectory>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>