ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

idea swing gui设计后用mvn打包的pom配置

2022-06-09 10:31:49  阅读:157  来源: 互联网

标签:plugin -- com gui idea maven pom org true


一下时pom配置文件:

<?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>TestPub</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>

        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>3.17.0</version>
        </dependency>

        <dependency>
            <groupId>de.ruedigermoeller</groupId>
            <artifactId>fst</artifactId>
            <version>2.57</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <groupId>com.intellij</groupId>
            <artifactId>forms_rt</artifactId>
            <version>7.0.3</version>
        </dependency>
    </dependencies>
<!--    方式一-->
<!--    <build>-->
<!--        <plugins>-->
<!--            <plugin>-->
<!--                <groupId>org.apache.maven.plugins</groupId>-->
<!--                <artifactId>maven-assembly-plugin</artifactId>-->
<!--                <version>2.4.1</version>-->
<!--                <configuration>-->
<!--                    <appendAssemblyId>false</appendAssemblyId>-->
<!--                    <finalName>xxx-xxx</finalName>-->
<!--                    <descriptorRefs>-->
<!--                        &lt;!&ndash;将依赖的jar包中的class文件打进生成的jar包&ndash;&gt;-->
<!--                        <defcriptorRef>jar-with-dependencies</defcriptorRef>-->
<!--                    </descriptorRefs>-->
<!--                    <archive>-->
<!--                        <manifest>-->
<!--                            <addClasspath>true</addClasspath>-->
<!--                            &lt;!&ndash;指定入口函数&ndash;&gt;-->
<!--                            <mainClass>com.test.myFram</mainClass>-->
<!--                        </manifest>-->
<!--                    </archive>-->
<!--                </configuration>-->
<!--                <executions>-->
<!--                    <execution>-->
<!--                        <id>make-assembly</id>-->
<!--                        <phase>package</phase>-->
<!--                        <goals>-->
<!--                            <goal>assembly</goal>-->
<!--                        </goals>-->
<!--                    </execution>-->
<!--                </executions>-->
<!--            </plugin>-->
<!--            &lt;!&ndash; IDEA Gui Designer Plugin &ndash;&gt;-->
<!--            <plugin>-->
<!--                <groupId>org.codehaus.mojo</groupId>-->
<!--                <artifactId>ideauidesigner-maven-plugin</artifactId>-->
<!--                <version>1.0-beta-1</version>-->
<!--                <executions>-->
<!--                    <execution>-->
<!--                        <goals>-->
<!--                            <goal>javac2</goal>-->
<!--                        </goals>-->
<!--                    </execution>-->
<!--                </executions>-->

<!--                <configuration>-->
<!--                    <fork>true</fork>-->
<!--                    <debug>true</debug>-->
<!--                    <failOnError>true</failOnError>-->
<!--                </configuration>-->
<!--            </plugin>-->
<!--        </plugins>-->
<!--    </build>-->

<!--    方式二-->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <!-- 生成的jar中,包含pom.xml和pom.properties这两个文件 -->
<!--                        <addMavenDescriptor>true</addMavenDescriptor>-->
                        <!-- 生成MANIFEST.MF的设置 -->
                        <manifest>
                            <!--这个属性特别关键,如果没有这个属性,有时候我们引用的包maven库
                            下面可能会有多个包,并且只有一个是正确的,其余的可能是带时间戳的,
                            此时会在classpath下面把那个带时间戳的给添加上去,然后我们
                            在依赖打包的时候,打的是正确的,所以两头会对不上,报错。-->
                            <useUniqueVersions>false</useUniqueVersions>
                            <!-- 为依赖包添加路径, 这些路径会写在MANIFEST文件的Class-Path下 -->
                            <addClasspath>true</addClasspath>
                            <!-- 这个jar所依赖的jar包添加classPath的时候的前缀,如果这个
                            jar本身和依赖包在同一级目录,则不需要添加-->
                            <classpathPrefix>lib/</classpathPrefix>
                            <!-- jar启动入口类-->
                            <mainClass>com.test.myFram</mainClass>
                        </manifest>
<!--                        <manifestEntries>-->
<!--                            &lt;!&ndash; 在Class-Path下添加配置文件的路径 &ndash;&gt;-->
<!--                            &lt;!&ndash;                            <Class-Path>../config</Class-Path>&ndash;&gt;-->
<!--                            &lt;!&ndash; 假如这个项目可能要引入一些外部资源,但是你打包的时候并不想把-->
<!--                            这些资源文件打进包里面,这个时候你必须在这边额外指定一些这些资源-->
<!--                            文件的路径,这个位置指定的话,要根据你预期的这些位置去设置,我这边-->
<!--                            所有jar都在lib下,资源文件都在config下,lib和config是同级的 &ndash;&gt;-->
<!--                            &lt;!&ndash; 同时还需要注意另外一个问题,假如你的pom文件里面配置了-->
<!--                            <scope>system</scope>,就是你依赖是你本地的资源,这个时候使用-->
<!--                            这个插件,classPath里面是不会添加,所以你得手动把这个依赖添加进-->
<!--                            这个地方,用空格隔开就行&ndash;&gt;-->
<!--                            <Class-Path></Class-Path>-->
<!--                        </manifestEntries>-->
                    </archive>
                    <!-- jar包的位置-->
                    <outputDirectory>${project.build.directory}/</outputDirectory>
                    <includes>
                        <!-- 打jar包时,只打包class文件 -->
                        <!-- 有时候可能需要一些其他文件,这边可以配置,包括剔除的文件等等-->
                        <include>**/*.class</include>
                    </includes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>package</phase><!--阶段-->
                        <goals>
                            <goal>copy-dependencies</goal><!--目标-->
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <!--已存在的Release版本不重复copy-->
                            <overWriteReleases>false</overWriteReleases>
                            <!--已存在的SnapShot版本不重复copy-->
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <!--不存在或者有更新版本的依赖才copy-->
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- IDEA Gui Designer Plugin -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>ideauidesigner-maven-plugin</artifactId>
                <version>1.0-beta-1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>javac2</goal>
                        </goals>
                    </execution>
                </executions>

                <configuration>
                    <fork>true</fork>
                    <debug>true</debug>
                    <failOnError>true</failOnError>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

方式一和方式二打包都是可行的,没什么区别。

idea下的swing设计的maven打包需要引入依赖

     <dependency>
            <groupId>com.intellij</groupId>
            <artifactId>forms_rt</artifactId>
            <version>7.0.3</version>
        </dependency>
和使用插件
            <!-- IDEA Gui Designer Plugin -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>ideauidesigner-maven-plugin</artifactId>
                <version>1.0-beta-1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>javac2</goal>
                        </goals>
                    </execution>
                </executions>

                <configuration>
                    <fork>true</fork>
                    <debug>true</debug>
                    <failOnError>true</failOnError>
                </configuration>
            </plugin>
jar包的下载都可以去如下地址查询:https://mvnrepository.com/search?q=

其他类型参考资料:

java – IntelliJ GUI Designer Maven可执行JAR导出: https://www.icode9.com/content-1-474354.html

IntelliJ基于Grandle通过GUI Form创建Swing项目的过程:https://blog.csdn.net/qq_35205516/article/details/103855901



标签:plugin,--,com,gui,idea,maven,pom,org,true
来源: https://www.cnblogs.com/ruber/p/16358364.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有