美文网首页
IM即时聊天系统-Openfire爬坑之路三 插件2

IM即时聊天系统-Openfire爬坑之路三 插件2

作者: 渝潼不肖生 | 来源:发表于2020-04-26 16:39 被阅读0次

    现在很多都不用ant这样的古老构建工具了,用maven如何自动构建插件呢.下面举个栗子:

    1. 在plugins下创建一个叫做myplugin的module:


      myplugin结构

    2.myplugin下的pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <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">
    
        <parent>
            <artifactId>plugins</artifactId>
            <groupId>org.igniterealtime.openfire</groupId>
            <version>4.6.0-SNAPSHOT</version>
        </parent>
    
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.example</groupId>
        <artifactId>myplugin</artifactId>
    
        <build>
            <sourceDirectory>src/java</sourceDirectory>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
            </plugins>
        </build>
    </project>
    
    1. 看看plugins下的pom.xml中的<modules>标签下是否添加了myplugin插件


      plugins下的pom.xml

    4.distribution下pom.xml中添加一下代码:

    • 添加依赖配置
    <artifactItem>
           <groupId>com.example</groupId>
           <artifactId>myplugin</artifactId>
           <classifier>openfire-plugin-assembly</classifier>
          <type>jar</type>
          <overWrite>true</overWrite>
          <outputDirectory>${project.build.directory}${file.separator}distribution-base${file.separator}plugins</outputDirectory>
          <destFileName>MyPlugin.jar</destFileName>
     </artifactItem>
    

    如图:


    图示
    • 添加依赖关系
     <dependency>
         <groupId>com.example</groupId>
        <artifactId>myplugin</artifactId>
        <version>${project.version}</version>
        <classifier>openfire-plugin-assembly</classifier>
        <scope>provided</scope>
    </dependency>
    
    图示

    好了,构建吧!
    先plugin模块,后distribution模块,运行代码

    mvn clean
    

    然后

    mvn verify
    
    结果 运行结果

    相关文章

      网友评论

          本文标题:IM即时聊天系统-Openfire爬坑之路三 插件2

          本文链接:https://www.haomeiwen.com/subject/ljedwhtx.html