You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将内部Ivy仓库替换为Artifactory并迁移至Maven的技术咨询

Migrating from Ivy (SVN) to Maven + Artifactory: Fixing Configurations & Publications Gaps

Hey there, let’s break this down step by step since you’re new to both Ivy and Maven—no need to feel stuck! The makepom Ant task is great for basic conversions, but it’s definitely limited when it comes to handling Ivy’s more flexible configurations and publications nodes. Here’s how to map those to Maven’s structure manually:

First: Understand Ivy Configurations ↔ Maven Equivalents

Ivy’s configurations are all about grouping dependencies and defining which artifacts get used where. Maven uses dependency scopes and (for advanced cases) profiles to handle this. Here’s the most common mapping:

  • Ivy’s compile configuration → Maven’s compile scope (default, used for main code)
  • Ivy’s test configuration → Maven’s test scope (only for test code)
  • Ivy’s provided configuration → Maven’s provided scope (like servlet APIs, provided by the runtime)
  • Ivy’s runtime configuration → Maven’s runtime scope (used at runtime but not compilation)

If you have custom configurations (e.g., dev for development-only dependencies), you’ll need to either map them to an existing Maven scope or use Maven profiles to activate those dependencies only in specific environments.

How to Fix Dependencies After makepom

When makepom generates your pom.xml, it probably dumped all dependencies into the default compile scope. Go through your original ivy.xml and adjust each dependency’s <scope> in the pom to match its Ivy configuration. For example:

<!-- Ivy dependency in test configuration -->
<dependency org="junit" name="junit" rev="4.13.2" conf="test->default"/>

<!-- Becomes this in pom.xml -->
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.13.2</version>
  <scope>test</scope>
</dependency>

Next: Translate Ivy Publications to Maven Build Plugins

Ivy’s publications define which artifacts you want to publish (e.g., main JAR, sources JAR, javadoc). Maven handles this via its default packaging (usually JAR) plus plugins to attach additional artifacts.

Common Publication Mappings

  1. Main JAR: Maven automatically builds this if your packaging is set to jar (which makepom should have done).
  2. Sources/Javadoc JARs: If your Ivy publications include these, add the following plugins to your pom’s <build><plugins> section:
    <!-- Attach sources JAR -->
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-source-plugin</artifactId>
      <version>3.2.1</version>
      <executions>
        <execution>
          <id>attach-sources</id>
          <goals>
            <goal>jar-no-fork</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    
    <!-- Attach javadoc JAR -->
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-javadoc-plugin</artifactId>
      <version>3.5.0</version>
      <executions>
        <execution>
          <id>attach-javadocs</id>
          <goals>
            <goal>jar</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    
  3. Custom Artifacts (e.g., shaded JARs, zip distributions): Use plugins like maven-assembly-plugin or maven-shade-plugin to define and publish these, matching what your Ivy publications did.

Step-by-Step Migration Workflow

  1. Generate Base Pom: Use makepom to get the basic structure (groupId, artifactId, version, core dependencies).
  2. Fix Dependency Scopes: Manually update each dependency’s scope to match its original Ivy configuration.
  3. Add Publication Plugins: Configure Maven plugins to replicate your Ivy publications.
  4. Test Locally: Run mvn clean install to build and install artifacts to your local Maven repo—verify everything compiles and dependencies are resolved correctly.
  5. Configure Artifactory: Update your settings.xml to point to your Artifactory instance (add release and snapshot repositories). Then run mvn deploy to push artifacts to Artifactory.

Quick Tips for Newbies

  • Start with a small, simple project first—get that working before tackling larger, more complex ones.
  • Don’t overcomplicate custom configurations right away—stick to standard Maven scopes unless you really need the flexibility.
  • If you’re unsure about a plugin or scope, you can look up Maven’s official docs as you go; no need to memorize everything upfront.

内容的提问来源于stack exchange,提问作者Ed Dunn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:05:30