最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Issue in jar generation in maven project - Stack Overflow

programmeradmin8浏览0评论

I am trying produce the artifact of jide-oss repository.

I have updated its pom.xml with the following pom.xml contents.

   <?xml version="1.0"?>
<!--
~ @(#)pom.xml 5/16/2012
~
~ Copyright 2002 - 2012 JIDE Software Inc. All rights reserved.
-->

<project xmlns=".0.0" xmlns:xsi=";
         xsi:schemaLocation=".0.0 .xsd">
    <parent>
        <groupId>.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>7</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.jidesoft</groupId>
    <artifactId>qhr-jide-oss</artifactId>
    <name>JIDE Common Layer</name>
    <version>3.7.1</version>
    <packaging>jar</packaging>
    <description>JIDE Common Layer (Professional Swing Components)</description>
    <url>;/url>
    <licenses>
        <license>
            <name>GPL with classpath exception</name>
            <url>.txt</url>
            <distribution>repo</distribution>
        </license>
        <license>
            <name>Free commercial license</name>
            <url>.htm</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <developers>
        <developer>
            <id>jidesoft</id>
            <name>jidesoft</name>
            <email>[email protected]</email>
        </developer>
    </developers>
    <distributionManagement>
        <repository>
            <id>sonatype-nexus-staging</id>
            <url>;/url>
        </repository>
    </distributionManagement>
    <scm>
        <connection>scm:git:git://github/jidesoft/jide-oss.git</connection>
        <developerConnection>scm:git:https://[email protected]/jidesoft/jide-oss.git</developerConnection>
        <url>;/url>
    </scm>

    <repositories>
        <repository>
            <id>central</id>
            <url>;/url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.formdev</groupId>
            <artifactId>flatlaf</artifactId>
            <version>3.5</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>

            <plugin>
                <groupId>.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <compilerArgs>
                        <arg>--add-exports</arg>
                        <arg>java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED</arg>
                        <arg>--add-exports</arg>
                        <arg>java.desktop/javax.swing.plaf.synth=ALL-UNNAMED</arg>
                        <arg>--add-exports</arg>
                        <arg>java.desktop/sun.swing=ALL-UNNAMED</arg>
                        <arg>--add-exports</arg>
                        <arg>java.desktop/sun.awt=ALL-UNNAMED</arg>
                        <arg>--add-exports</arg>
                        <arg>java.desktop/sun.awt.image=ALL-UNNAMED</arg>
                        <arg>--add-exports</arg>
                        <arg>java.desktop/sun.awt.shell=ALL-UNNAMED</arg>
                        <arg>--add-exports</arg>
                        <arg>java.desktop/sun.awt.dnd=ALL-UNNAMED</arg>
                        <arg>--add-exports</arg>
                        <arg>java.desktop/sun.awt.windows=ALL-UNNAMED</arg>
                        <arg>--add-exports</arg>
                        <arg>java.base/sun.security.action=ALL-UNNAMED</arg>
                    </compilerArgs>
                    <source>11</source> <!-- Set source compatibility to Java 11 -->
                    <target>11</target> <!-- Set target compatibility to Java 11 -->
                </configuration>
            </plugin>

            <plugin>
                <groupId>.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.4.0</version>
                <executions>
                    <execution>
                    <id>add-source</id>
                     <phase>generate-sources</phase>
                      <goals>
                          <goal>add-source</goal>
                      </goals>
                        <configuration>
                            <sources>
                                <source>${basedir}/src</source>
                                <source>${basedir}/src-jdk9</source>
                                <source>${basedir}/src-apple</source>

                            </sources>
                        </configuration>
                    </execution>
                     <execution>
                         <id>add-resource</id>
                         <phase>process-resources</phase>
                         <goals>
                             <goal>add-resource</goal>
                         </goals>
                         <configuration>
                             <resources>
                                 <resource>
                                     <directory>${basedir}/src</directory>
                                     <includes>
                                         <include>**/*.properties</include>
                                         <include>**/*.png</include>
                                         <include>**/*.jpg</include>
                                         <include>**/*.xml</include>
                                     </includes>
                                     <excludes>
                                         <exclude>**/*.java</exclude>
                                     </excludes>
                                 </resource> 
                                 <resource>
                                     <directory>${basedir}/properties</directory>
                                     <filtering>true</filtering>
                                     <includes>
                                         <include>**/*.properties</include>
                                         <include>**/*.png</include>
                                         <include>**/*.jpg</include>
                                         <include>**/*.xml</include>
                                     </includes>
                                 </resource>
                             </resources>
                         </configuration>
                     </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

When I run mvn clean package. The generated jar's all the classes have INTERNAL SERVER error. I think this issue is happening due to add-resource phase. The repository does not follow standard package conventions. There are properties file in src directory .Also src directory contains images. I don`t want to restructure whole project. I want to build the artifact using src, src-jdk9 ,src-apple and properties folder. How can I build the jar if my source folder contains java and non-java files. Thanks

发布评论

评论列表(0)

  1. 暂无评论