简体   繁体   中英

Maven doesn't pick up resources on jenkins(linux)

I'm having really weird issue - I have created multi-module java project that creates "fat-jar". Unfortunetly the "frontend" module jar doesn't have resources in it when launched on jenkins(linux) - it does work on Windows for some reason:

This is the "frontend" pom:

<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>

    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
    <relativePath/>
  </parent>

  <groupId>com.frontend</groupId>
  <artifactId>frontend-app</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <build>
    <resources>
      <resource>
        <directory>dist</directory>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.6</version>
        <executions>
          <execution>
            <id>install node and npm</id>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
            <phase>generate-resources</phase>
          </execution>
          <execution>
            <id>npm install</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>install</arguments>
            </configuration>
          </execution>
          <execution>
            <id>node build app</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>run-script build</arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

I have tried with:

    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>

But that did not help neither.

The default npm build goal is

ng build --output-path dist/META-INF/resources

Jar file in target does not include files from "dist" -> it also does not work when I create it in default location src/main/resources

The maven log output includes this:

[WARNING] JAR will be empty - no content was marked for inclusion!

The dist directory is created and filled during build. Maven locates files on Windows but does not on Jenkins.

EDIT:

The maven goals are the same.

You could check few things on Jenkins. First if mvn goal is exactly same. Second, whether all resources are checked out properly or not. Also, see if file write permission are there for the linux user used by Jenkins process. Finally, append a -X behind your goals on Jenkins to see maven logs in detail and debug your issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM