0

Maven isn't copying index.html from another project. I've added dependency for project application. But after the clean install the jar file of module2 doesn't have the index.html from application module.

Any suggestion on how to make this work? I've provided the screenshot below.

  <dependency>  
    <groupId>sample.multimodule</groupId>  
    <artifactId>sample.multimodule.application</artifactId>  
    <version>1.4.0-SNAPSHOT</version>  
  </dependency>  

I want the index.html to be included in the module2 after compilation.

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>sample.multimodule</groupId>
    <artifactId>sample.multimodule</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>sample.multimodule.module2</artifactId>

    <version>1.4.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>devops</name>
    <description>DevOps Demo Project</description>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <surefire.version>2.17</surefire.version>
        <jacoco.version>0.7.9</jacoco.version>      
    </properties>
    <distributionManagement>
      <repository>
        <id>release</id>
        <name>releases</name>
        <url>http://localhost:8081/artifactory/maven</url>
      </repository>
      <snapshotRepository>
        <id>snapshot</id>
        <name>snapshots</name>
        <url>http://localhost:8081/artifactory/maven</url>
      </snapshotRepository>
    </distributionManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-logging</artifactId>
        </dependency>
<dependency>
   <groupId>net.sourceforge.nekohtml</groupId>
   <artifactId>nekohtml</artifactId>
   <version>1.9.21</version>
</dependency>
        
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
    <version>2.5.0</version>
</dependency>       
<dependency>
  <groupId>junit</groupId>     <!-- NOT org.junit here -->
  <artifactId>junit</artifactId>
  <version>4.12</version>
  <scope>test</scope>
</dependency>
      <dependency>  
        <groupId>sample.multimodule</groupId>  
        <artifactId>sample.multimodule.application</artifactId>  
        <version>1.4.0-SNAPSHOT</version>  
      </dependency>  
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-release-plugin</artifactId>
              <version>2.5.1</version>
              <configuration>
                <tagNameFormat>v@{project.version}</tagNameFormat>
                <autoVersionSubmodules>true</autoVersionSubmodules>
              </configuration>
            </plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>${surefire.version}</version>
</plugin>
<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>${jacoco.version}</version>
    <executions>
        <execution>
            <id>default-prepare-agent</id>
            <goals><goal>prepare-agent</goal></goals>
        </execution>
        <execution>
            <id>default-report</id>
            <phase>prepare-package</phase>
            <goals><goal>report</goal></goals>
        </execution>
    </executions>
</plugin>           
        </plugins>
    </build>  
</project>

enter image description here

user630702
  • 2,529
  • 5
  • 35
  • 98
  • Does this answer your question? [Maven-dependency-plugin (unpack-dependencies) ignores configuration](https://stackoverflow.com/questions/53557076/maven-dependency-plugin-unpack-dependencies-ignores-configuration) – Joe Sep 19 '21 at 08:07
  • no it doesn't. It is not even realted – user630702 Sep 19 '21 at 08:10
  • 1
    If you're trying to extract a resource from a dependency into the current module's target directory, it's very much related. – Joe Sep 19 '21 at 08:11
  • I tried that but it still doesn't work. Could you please provide an example on how to make this work? – user630702 Sep 19 '21 at 08:20
  • First Maven is not doing that because it's not intended to do so. A dependency is in the end a jar file which can contain resources (like the index.html) but by default it's a file which contains class files. The question is: Why do you have the needed `index.html` in one module but need to use it in another module? Why not moving it to the other module where it's needed? – khmarbaise Sep 19 '21 at 12:18

0 Answers0