skip to Main Content

This time we use Jenkins to help us to build Java, it used to work well, but if we add a local jar file, it failed.

...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project ruoyi-admin: /BOOT-INF/lib/cesiumlanguagewriter-2.20.1.jar (No such file or directory) -> [Help 1]
[ERROR] 
[JENKINS] Archiving /var/lib/jenkins/workspace/qrd_back/ruoyi-system/pom.xml to com.ruoyi/ruoyi-system/3.8.5/ruoyi-system-3.8.5.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/qrd_back/ruoyi-system/target/ruoyi-system-3.8.5.jar to com.ruoyi/ruoyi-system/3.8.5/ruoyi-system-3.8.5.jar
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :ruoyi-admin
...

this jar file cesiumlanguagewriter-2.20.1.jar is our local jar file, we include it in ruoyi-adminpom.xml file

<?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>ruoyi</artifactId>
        <groupId>com.ruoyi</groupId>
        <version>3.8.5</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <packaging>jar</packaging>
    <artifactId>ruoyi-admin</artifactId>

    <dependencies>

        ......
        <dependency>
            <groupId>cesiumlanguagewriter</groupId>
            <artifactId>cesiumlanguagewriter</artifactId>
            <version>2.20.1</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/cesiumlanguagewriter-2.20.1.jar</systemPath>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>lib</directory>
                <targetPath>/BOOT-INF/lib/</targetPath>
                <includes>
                    <include>**/*.jar</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                ...
            </plugin>
            <plugin>   
                ...
           </plugin>   
        </plugins>
        <finalName>${project.artifactId}</finalName>
    </build>

</project>

it looks fine, and exactly, it can build with command mvn clean package in our local Windows environment, and in our local Ubuntu environment, but not enable to build in Jenkins, what are the difference between the Ubuntu environment and Jenkins?

Ubuntu and Jenkins use the same Maven, the difference between them may be the settings.xml, but because I am newbie in Java, so I can not find the difference between them

the mavn version on the Ubuntu(it can build success):

jenkins@sakuramoyu:~/workspace/ruoyi_qrd$ mvn --version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.19, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-71-generic", arch: "amd64", family: "unix"

Edit

The command Jenkins use is mvn -B -f /var/lib/jenkins/workspace/qrd_back/pom.xml clean package, I think it will cause the problem, what are the difference between mvn clean package

Edit2

If I run build with mvn -B -f /var/lib/jenkins/workspace/qrd_back/pom.xml clean package -X, it tells me

...
[DEBUG] ignoreDelta true
[INFO] Copying 1 resource to /BOOT-INF/lib/
[DEBUG] file cesiumlanguagewriter-2.20.1.jar has a filtered file extension
[DEBUG] copy /var/lib/jenkins/workspace/qrd_back/ruoyi-admin/lib/cesiumlanguagewriter-2.20.1.jar to /BOOT-INF/lib/cesiumlanguagewriter-2.20.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for ruoyi 3.8.5:
[INFO]
[INFO] ruoyi .............................................. SUCCESS [  0.186 s]
[INFO] ruoyi-common ....................................... SUCCESS [  8.158 s]
[INFO] ruoyi-system ....................................... SUCCESS [  2.043 s]
[INFO] ruoyi-framework .................................... SUCCESS [  1.785 s]
[INFO] ruoyi-quartz ....................................... SUCCESS [  1.148 s]
[INFO] ruoyi-generator .................................... SUCCESS [  1.174 s]
[INFO] ruoyi-admin ........................................ FAILURE [  0.701 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  15.679 s
[INFO] Finished at: 2023-05-23T09:40:23+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project ruoyi-admin: /BOOT-INF/lib/cesiumlanguagewriter-2.20.1.jar (No such file or directory)
-> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project ruoyi-admin: /BOOT-INF/lib/cesiumlangua
gewriter-2.20.1.jar (No such file or directory)
...

it means the local jar file is filtered? so it can not find it?

2

Answers


  1. Chosen as BEST ANSWER

    after a long time struggle, I found a solution: Edit ruoyi-adminpom.xml,

    remove all the resource part in <build>

    <!-- REMOVE IT -->
    <resources>
      <resource>
         <directory>lib</directory>
         <targetPath>/BOOT-INF/lib/</targetPath>
         <includes>
            <include>**/*.jar</include>
         </includes>
      </resource>
    </resources>
    

    add one line here:

    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <version>2.1.1.RELEASE</version>
      <configuration>
        <includeSystemScope>true</includeSystemScope> <!-- HERE -->
        <fork>true</fork> 
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>repackage</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    

    sorry I just a newbie in Java and Maven, so why it can happen, I don't know


  2. You are not building that jar. You are telling Maven that it is to be found at a given directory relative to the project directory. It seems that in the Jenkins build that directory is set to a path where that jar is not there:

    /BOOT-INF/lib/cesiumlangua
    gewriter-2.20.1.jar (No such file or directory)
    

    You didn’t share enough information to find more but if you are using a Maven plugin to copy the jar file it maybe filtering a jar file because it is not supposed to do that.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search