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

如何将Eclipse产品及物化产物部署至Maven与Nexus仓库?

Hey there! Let's break down how to handle both your deployment needs—getting your Eclipse product into a Maven repo, and pushing that materialized product to Nexus when single-artifact guides fall short.

Deploying an Eclipse Product to a Maven Repository

Since Eclipse products rely on OSGi bundles and p2 repositories, Tycho is the go-to Maven plugin for this workflow. Here's a step-by-step approach:

  • Set up your Tycho build foundation
    First, configure your parent pom.xml to use Tycho, include Eclipse's p2 repositories (for dependencies), and define your project group/version:

    <properties>
      <tycho-version>4.0.0</tycho-version>
      <project.version>1.0.0-SNAPSHOT</project.version>
    </properties>
    <repositories>
      <repository>
        <id>eclipse-releases</id>
        <url>https://download.eclipse.org/releases/latest/</url>
        <layout>p2</layout>
      </repository>
    </repositories>
    <build>
      <plugins>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-maven-plugin</artifactId>
          <version>${tycho-version}</version>
          <extensions>true</extensions>
        </plugin>
      </plugins>
    </build>
    
  • Configure your product project
    In your Eclipse product project's pom.xml, set the packaging to eclipse-product and link to your .product file:

    <packaging>eclipse-product</packaging>
    <build>
      <plugins>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-product-plugin</artifactId>
          <version>${tycho-version}</version>
          <configuration>
            <productFile>src/main/resources/com.yourcompany.yourproduct.product</productFile>
            <archiveFileName>${project.artifactId}-${project.version}.zip</archiveFileName>
          </configuration>
        </plugin>
      </plugins>
    </build>
    
  • Deploy the built product
    Use Maven's deploy goal to push the generated zip artifact to your Maven repo (or Nexus). You can either rely on Tycho's default deployment or explicitly configure the maven-deploy-plugin if you need custom paths:

    mvn clean deploy -Dmaven.deploy.repo.id=your-nexus-repo-id -Dmaven.deploy.repo.url=http://your-nexus-url/repository/maven-releases/
    

    Make sure your settings.xml has the Nexus credentials mapped to your-nexus-repo-id:

    <servers>
      <server>
        <id>your-nexus-repo-id</id>
        <username>nexus-user</username>
        <password>nexus-password</password>
      </server>
    </servers>
    
Deploying a Materialized Eclipse Product to Nexus

A materialized product is the fully expanded, runnable version of your Eclipse product (not just a zip archive). Since Nexus/Maven repos work best with packaged artifacts, here's how to handle this:

  • Package the materialized product
    First, use Tycho's tycho-p2-director-plugin to materialize the product, then use maven-assembly-plugin to package the entire directory into a zip/tar.gz:

    <!-- In your product project's pom.xml -->
    <plugin>
      <groupId>org.eclipse.tycho</groupId>
      <artifactId>tycho-p2-director-plugin</artifactId>
      <version>${tycho-version}</version>
      <executions>
        <execution>
          <id>materialize-product</id>
          <goals>
            <goal>materialize-products</goal>
          </goals>
          <configuration>
            <products>
              <product>
                <id>com.yourcompany.yourproduct.product</id>
                <rootFolder>materialized-product</rootFolder>
              </product>
            </products>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-assembly-plugin</artifactId>
      <version>3.6.0</version>
      <executions>
        <execution>
          <id>package-materialized</id>
          <phase>package</phase>
          <goals>
            <goal>single</goal>
          </goals>
          <configuration>
            <descriptors>
              <descriptor>src/main/assembly/materialized-assembly.xml</descriptor>
            </descriptors>
          </configuration>
        </execution>
      </executions>
    </plugin>
    

    Create the materialized-assembly.xml descriptor to bundle the entire materialized directory:

    <assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
      <id>materialized</id>
      <formats>
        <format>zip</format>
      </formats>
      <fileSets>
        <fileSet>
          <directory>${project.build.directory}/materialized-product</directory>
          <outputDirectory>/</outputDirectory>
          <includes>
            <include>**/*</include>
          </includes>
        </fileSet>
      </fileSets>
    </assembly>
    
  • Deploy the packaged materialized product
    Use the maven-deploy-plugin to push the generated zip to Nexus, adding a classifier to distinguish it from the regular product zip:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-deploy-plugin</artifactId>
      <version>3.1.0</version>
      <executions>
        <execution>
          <id>deploy-materialized</id>
          <phase>deploy</phase>
          <goals>
            <goal>deploy-file</goal>
          </goals>
          <configuration>
            <file>${project.build.directory}/${project.artifactId}-${project.version}-materialized.zip</file>
            <groupId>com.yourcompany</groupId>
            <artifactId>your-eclipse-product</artifactId>
            <version>${project.version}</version>
            <classifier>materialized</classifier>
            <packaging>zip</packaging>
            <repositoryId>your-nexus-repo-id</repositoryId>
            <url>http://your-nexus-url/repository/maven-releases/</url>
          </configuration>
        </execution>
      </executions>
    </plugin>
    

    Run mvn clean deploy as before, and the materialized product will show up in Nexus with the materialized classifier.

If you need to deploy materialized products for multiple platforms (Windows, Linux, macOS), just create separate assembly descriptors and classifiers (e.g., materialized-linux-x86_64, materialized-win32-x86_64) to keep them organized.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 04:22:23