**Maven PAR Plugin 1.0.0.M1** 是一个用于创建 **PAR(Portable Application Resource)** 文件的 Maven 插件

在dmServer引入后,ThorstenMaus创建了一个Maven插件用于生成PAR文件,此插件随dmServer2.0的进展得到更新,新增支持非JAR文件类型,如OSGi RFC66标准的.war文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Maven PAR Plugin 1.0.0.M1 是一个用于创建 PAR(Portable Application Resource) 文件的 Maven 插件。PAR 文件是一种打包格式,通常用于将多个模块或资源打包为一个可部署的单元,常见于某些特定的 Java 应用场景(如 OSGi 或特定企业应用)。

以下是对 Maven PAR Plugin 1.0.0.M1 的详细介绍和使用方法:


1. PAR 文件简介

PAR 文件是一种打包格式,通常包含以下内容:

  • 多个 JAR 文件(模块或库)。
  • 配置文件(如 MANIFEST.MF 或其他资源文件)。
  • 其他依赖资源。

PAR 文件的主要目的是将多个模块打包为一个整体,便于部署和管理。


2. Maven PAR Plugin 1.0.0.M1 的功能

Maven PAR Plugin 用于将 Maven 项目打包为 PAR 文件。它的主要功能包括:

  • 将多个模块打包为一个 PAR 文件。
  • 支持自定义配置文件和资源。
  • 与其他 Maven 插件(如 maven-jar-plugin)兼容。

3. 使用 Maven PAR Plugin 1.0.0.M1

以下是如何在 Maven 项目中配置和使用该插件的步骤:

3.1 添加插件到 pom.xml

pom.xml<build> 部分添加 Maven PAR Plugin:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-par-plugin</artifactId>
            <version>1.0.0.M1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>par</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
3.2 配置 PAR 文件

可以通过插件的 <configuration> 部分自定义 PAR 文件的生成方式。例如:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-par-plugin</artifactId>
    <version>1.0.0.M1</version>
    <configuration>
        <outputDirectory>target/par</outputDirectory>
        <includes>
            <include>**/*.jar</include>
            <include>**/*.properties</include>
        </includes>
    </configuration>
</plugin>
3.3 构建 PAR 文件

使用以下 Maven 命令构建 PAR 文件:

mvn clean package

构建完成后,PAR 文件将生成在 target 目录中。


4. 注意事项

  • 版本问题1.0.0.M1 是一个里程碑版本(Milestone),可能不够稳定。建议在生产环境中使用正式版本(如果存在)。
  • 兼容性:确保插件与您的 Maven 版本兼容。
  • 依赖管理:如果 PAR 文件包含多个模块,确保所有依赖已正确配置。

5. 替代方案

如果您不需要 PAR 文件,可以考虑使用其他打包格式,例如:

  • JAR:使用 maven-jar-plugin 打包为 JAR 文件。
  • WAR:使用 maven-war-plugin 打包为 WAR 文件(适用于 Web 应用)。
  • OSGi Bundle:如果用于 OSGi 环境,可以使用 maven-bundle-plugin

6. 总结

Maven PAR Plugin 1.0.0.M1 是一个用于生成 PAR 文件的 Maven 插件,适用于需要将多个模块打包为单一文件的场景。通过合理配置,可以轻松集成到 Maven 项目中。

Shortly after the introduction of SpringSource dm Server (Application Platform at the time), Thorsten Maus created a Maven plugin for creating PAR files. This was a great community contribution and we even used it in the Getting Started Guide for dm Server 1.0.x.

As dm Server’s 2.0 milestones have progressed we’ve been adding new functionality to the PAR file. The most interesting feature is that now a PAR file can contain more than just JAR files. With the introduction of OSGi RFC 66, the dm Server has deprecated Web Modules in favor of the standard Web Container files using a .war extension. Because of this, the PAR plugin needed to be updated to support these different types as dependencies. Thorsten graciously agreed to donate his code to SpringSource and I’m pleased to announce the 1.0.0.M1 release of the Apache Licensed Maven PAR Plugin.

Git - git://git.springsource.org/maven-par-plugin/maven-par-plugin.git

Usage

Use of the plugin has changed only slightly and can now default all of the information needed.

Repository

To get the plugin, you’ll need to reference the SpringSource Enterprise Bundle Repository as a

com.springsource.repository.bundles.milestone SpringSource Enterprise Bundle Repository - SpringSource Bundle Milestones http://repository.springsource.com/maven/bundles/milestone

Build Plugin

Next you will need to set your packaging type to par and add the plugin to your build plugin list.

org.apache.maven.plugins maven-par-plugin 1.0.0.M1

By default all of the PAR manifest headers are populated using defaults from the POM but can be overridden with configuration.
Header POM Element
Application-SymbolicName ${project.artifactId}
Application-Name ${project.name}
Application-Description ${project.description}
Application-Version ${project.version}

org.apache.maven.plugins maven-par-plugin 1.0.0.M1 override.symbolic.name Override Name Override Description 1000.0.0.override

There is also a configuration tag that selects between g r o u p I d . {groupId}. groupId.{artifactId}- v e r s i o n . {version}. version.{type} and a r t i f a c t I d . {artifactId}. artifactId.{type} for the file names of the files contained within the PAR file. This value defaults to false.
PAR

Next, add your list of dependencies. The plugin packages all of the direct dependencies listed in the POM. It does not care about scopes or transitive dependencies.

com.springsource.dmserver greenpages.app-solution ${project.version} com.springsource.dmserver greenpages.jpa-solution ${project.version} com.springsource.dmserver greenpages.db-solution ${project.version} com.springsource.dmserver greenpages.web-solution ${project.version} war

Build

Run mvn package.

[INFO] [par:par]
[INFO] Assembling Artifacts for PAR ‘solution/greenpages/target/greenpages-solution-1.0.0.SNAPSHOT.par’
[INFO] Added ‘greenpages.app-solution.jar’
[INFO] Added ‘greenpages.jpa-solution.jar’
[INFO] Added ‘greenpages.db-solution.jar’
[INFO] Added ‘greenpages.web-solution.war’

随着DM服务器的2个里程碑的进展,我们已经向PAR文件添加了新的功能。最有趣的特性是现在PAR文件可以包含不止JAR文件。随着OSGi RFC 66的引入,dm服务器已经弃用了Web模块,转而使用使用.war扩展名的标准Web容器文件。因此,需要更新PAR插件以支持这些不同类型作为依赖项。托斯滕亲切地同意将他的代码捐赠给SelfSo源,我很高兴地宣布Apache授权的Maven Par插件的1.0.0.M1版本。
感谢您提供背景信息!从您的描述来看,您提到的 Maven PAR Plugin 是由 Thorsten Maus 创建的,用于在 SpringSource dm Server(后来称为 VMware vFabric tc Server)中生成 PAR(Portable Application Resource) 文件。这是一个非常有价值的社区贡献,尤其是在 dm Server 1.0.x 的入门指南中被广泛使用。

以下是对这一背景的详细分析和补充信息:


1. SpringSource dm Server 和 PAR 文件

  • SpringSource dm Server

    • 一个基于 OSGi 的应用服务器,专为模块化 Java 应用设计。
    • 支持将应用打包为 PAR 文件,其中可以包含多个 OSGi Bundle(模块)和共享资源。
    • 后来被 VMware 收购并更名为 VMware vFabric tc Server
  • PAR 文件

    • 一种打包格式,用于将多个 OSGi Bundle 和共享资源打包为一个可部署单元。
    • 类似于 WAR 文件,但更适合模块化应用。

2. Maven PAR Plugin 的作用

Thorsten Maus 创建的 Maven PAR Plugin 是为了简化在 Maven 项目中生成 PAR 文件的过程。它的主要功能包括:

  • 将多个 Maven 模块打包为 PAR 文件。
  • 支持自定义配置文件和资源。
  • 与 dm Server 的部署需求兼容。

3. 使用 Maven PAR Plugin

以下是如何在 Maven 项目中配置和使用该插件的步骤:

3.1 添加插件到 pom.xml

pom.xml<build> 部分添加 Maven PAR Plugin:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-par-plugin</artifactId>
            <version>1.0.0.M1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>par</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
3.2 配置 PAR 文件

可以通过插件的 <configuration> 部分自定义 PAR 文件的生成方式。例如:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-par-plugin</artifactId>
    <version>1.0.0.M1</version>
    <configuration>
        <outputDirectory>target/par</outputDirectory>
        <includes>
            <include>**/*.jar</include>
            <include>**/*.properties</include>
        </includes>
    </configuration>
</plugin>
3.3 构建 PAR 文件

使用以下 Maven 命令构建 PAR 文件:

mvn clean package

构建完成后,PAR 文件将生成在 target 目录中。


4. 历史背景和社区贡献

  • Thorsten Maus 的贡献:

    • 他创建的 Maven PAR Plugin 填补了 dm Server 生态系统中 Maven 支持的空缺。
    • 该插件被广泛用于 dm Server 1.0.x 的入门指南中,帮助开发者快速上手。
  • dm Server 的演变

    • dm Server 是 SpringSource 推出的应用服务器,后来被 VMware 收购并更名为 VMware vFabric tc Server
    • 随着技术发展,OSGi 和模块化应用的需求逐渐减少,PAR 文件的使用也逐渐减少。

5. 现代替代方案

如果您正在使用现代技术栈,以下是一些替代方案:

  • Spring Boot
    • 提供了一种更简单的方式来构建和部署 Java 应用。
    • 支持将应用打包为 JAR 或 WAR 文件。
  • Docker
    • 使用容器化技术将应用及其依赖打包为一个镜像,便于部署和扩展。

6. 总结

Thorsten Maus 创建的 Maven PAR Plugin 是一个重要的社区贡献,尤其是在 SpringSource dm Server 生态系统中。它简化了 PAR 文件的生成过程,帮助开发者更好地利用 dm Server 的模块化特性。尽管 dm Server 和 PAR 文件的使用逐渐减少,但这一贡献仍然具有历史意义。

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Bol5261

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值