How do you create a maven assembly that includes shell scripts and properrties file not in jar?

Paul Taylor :

Im trying to use Maven to build a standalone application

Using the assembly plugin described at How do you create a standalone application with dependencies intact using Maven?

This creates widget distribution zip containing

widget-1.0
widget-1.0/lib/widget.jar
widget-1.0/lib/3rdpartyjar1.jar
widget-1.0/lib/3rdpartyjar2.jar

...

but in my src tree I have:

src/main/bin/widget.sh 

and this doesnt make into the final distribution zip, I would like it to go here

widget-1.0/widget.sh

Also in my src tree i have a properties file in

src/main/properties/widget.properties

that currently make its way into

widget-1.0/lib/widget.jar

but because I want it to be editable I want it to be in

widget-1.0/widget.properties

Is it possible to do this within maven ?

EDIT Using information in blog got working as follows:

  1. Renamed bin folder to scripts folder because this is standard Maven name
  2. Moved widget.properties into script folder
  3. Modifed my assembly.xml to contain a fileset

Here is the new xml

<?xml version="1.0" encoding="UTF-8"?>
<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
    <id>distribution</id>
    <formats>
        <format>zip</format>
    </formats>
    <dependencySets>
        <dependencySet>
            <scope>runtime</scope>
            <outputDirectory>lib</outputDirectory>
            <unpack>false</unpack>
        </dependencySet>
    </dependencySets>
    <fileSets>
        <fileSet>
            <directory>${project.build.scriptSourceDirectory}</directory>
            <outputDirectory></outputDirectory>
            <includes>
                <include>widget.sh</include>
                <include>widget.properties</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

However minor point but unable to find a list of maven standard folder variables anywhere , i.e is there an equivalent to ${project.build.scriptSourceDirectory} for the properties folder

jqno :

I found this blog post to be a good tutorial on how to do this.

Also, I think the name of the folder in which you place your files is relevant. Maven obviously does different things with files in src/main/java than with files in src/main/resources. I'm not 100% sure, but the name of this folder might mean the difference between a file ending up inside the jar or not.

Here is a list of Maven directory name properties.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do you create a file in assembly with a dynamically specified file path?

From Dev

How to create a jar with Maven that includes dependencies in a separate folder for each dependency

From Dev

How to create maven uber jar which includes dependencies with scope provided

From Dev

How to configure a manifest file of a jar file by using the maven assembly plugin?

From Dev

How to create jar file that only includes properties files using eclipse?

From Java

How to create a runnable jar with maven that includes dependencies in a separate "lib" folder (not an uber jar)

From Dev

Using maven assembly plugin to create ZIP file containing a fat jar (jar-with-dependencies)

From Dev

How do you create a shell script?

From Java

How do I create a private Maven repository on S3 from jar not .java file?

From Dev

How do I create an executable jar file including dependencies where the main class is in Test, using Maven

From Dev

How exactly do you get a JAR into Maven Central

From Linux

How do you write a linux shell script to manipulate filenames and create new file

From Javascript

How do you run a js file using npm scripts?

From Dev

Create JAR with one file in Maven

From Dev

Create jar file from maven

From Java

How to make a JAR file that includes DLL files?

From Dev

How do you create a file with an empty name?

From Dev

How do you create and use a .cma file?

From Java

How to configure maven:assembly root path in the jar

From Dev

Does sbt/maven includes the complete dependency in jar file?

From Dev

How can I create a runnable JAR file with Maven + JavaFX

From Dev

How to create a executable jar file using Maven and Netbeans

From Dev

How to create executable jar file from springboot - maven application?

From Dev

How to create jar file without java classes but with a folder using maven

From Dev

How to create executable jar in Kotlin using maven-assembly-plugin without a main class?

From Java

Maven - How do I create source jar for test package?

From Java

How do I create a standalone jar from a maven project?

From Dev

How do I create a Fat Jar with Maven Shade?

From Dev

Postgres: How do you create a USER MAPPING for a user whose name includes a period character ('.')

Related Related

  1. 1

    How do you create a file in assembly with a dynamically specified file path?

  2. 2

    How to create a jar with Maven that includes dependencies in a separate folder for each dependency

  3. 3

    How to create maven uber jar which includes dependencies with scope provided

  4. 4

    How to configure a manifest file of a jar file by using the maven assembly plugin?

  5. 5

    How to create jar file that only includes properties files using eclipse?

  6. 6

    How to create a runnable jar with maven that includes dependencies in a separate "lib" folder (not an uber jar)

  7. 7

    Using maven assembly plugin to create ZIP file containing a fat jar (jar-with-dependencies)

  8. 8

    How do you create a shell script?

  9. 9

    How do I create a private Maven repository on S3 from jar not .java file?

  10. 10

    How do I create an executable jar file including dependencies where the main class is in Test, using Maven

  11. 11

    How exactly do you get a JAR into Maven Central

  12. 12

    How do you write a linux shell script to manipulate filenames and create new file

  13. 13

    How do you run a js file using npm scripts?

  14. 14

    Create JAR with one file in Maven

  15. 15

    Create jar file from maven

  16. 16

    How to make a JAR file that includes DLL files?

  17. 17

    How do you create a file with an empty name?

  18. 18

    How do you create and use a .cma file?

  19. 19

    How to configure maven:assembly root path in the jar

  20. 20

    Does sbt/maven includes the complete dependency in jar file?

  21. 21

    How can I create a runnable JAR file with Maven + JavaFX

  22. 22

    How to create a executable jar file using Maven and Netbeans

  23. 23

    How to create executable jar file from springboot - maven application?

  24. 24

    How to create jar file without java classes but with a folder using maven

  25. 25

    How to create executable jar in Kotlin using maven-assembly-plugin without a main class?

  26. 26

    Maven - How do I create source jar for test package?

  27. 27

    How do I create a standalone jar from a maven project?

  28. 28

    How do I create a Fat Jar with Maven Shade?

  29. 29

    Postgres: How do you create a USER MAPPING for a user whose name includes a period character ('.')

HotTag

Archive