Question

I have a some perl file in my src/main/java/com/pac/report.pl which I want to package as part of my classes in the jar file.

Using maven maven-jar-plugin include directives, I have tried below and various other suggestions I pulled off the web, but doesn't copy the perl file as part of my classes in the jar file. Does anyone know what I am doing wrong.

<plugin>
 <artifactId>maven-jar-plugin</artifactId>
 <version>2.4</version>
  <configuration>
    <includes>
     <include>**/*</include>
     </includes>
  </configuration>
 </plugin>

EDIT

Also let me point out that I don't want to place the file in the resource directory due to legacy call and dependent reasons.

Was it helpful?

Solution

That is because the classes packaged into your jar aren't taken from src, but rather from target (specifically /target/classes), and the compiler completely ignores your non-java file.

Try placing your file in src/main/resources/com/pac/report.pl and it should be packaged into the jar (with the relative path of /com/pac/report.pl) since thats the default location where the resources plugin looks for additional files to add to /target before the jar plugin runs.

EDIT - or, if you dont want to / cant do this the way maven expects, you could manually bind an execution of the resources plugin to the lifecycle to pick up your file and copy it over to target. something like this:

<build>
    <plugins>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>compile</phase> <!-- or later -->
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target/classes</outputDirectory>
              <resources>          
                <resource>
                  <!-- path to your *.pl file here -->
                </resource>
              </resources>              
            </configuration>            
          </execution>
        </executions>
      </plugin>
    </plugins>
    ...
  </build>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top