0

I am using Maven resources plugin and want to override include pattern from CLI. Is there a way?

I tried this

<configuration>
                        <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                        <resources>
                            <resource>
                                <directory>${basedir}/src/main/content/jcr_root</directory>
                                <filtering>false</filtering>
                                <includes>
                                <include>${include.val}</include>
                                </includes>

                            </resource>
                        </resources>

                    </configuration>

Command from CLI is : mvn clean install -Dinclude.val=/components/content/anchor/

But my use-case is I may have multiple values to include based on the input and this is dynamic. So I cannot have an XML include element for every include.

The include pattern as far as I read - does not take comma separated values. Is there any other way? Or any other plugin?

I feel not taking comma separated values is a short-coming of this plugin. And though it accepts pattern, it does not take the normal regular expressions, so i cant have a pattern added here too.

Any pointers would help.

Use case: The use case is of atomic packaging. We have multiple files in the source directory Lets assume only 2 files got modified by the developer. lets assume we get to know the exact 2 files that got modified. I want only those 2 modified files to be included in the final package post maven build. If i have a command, that can take comma separated include patterns then this can be achieved very easily.

I read about this on the internet. Found some useful resources but could not get that working https://blog.sonatype.com/2011/03/configuring-plugin-goals-in-maven-3/

Wanted to know if anyone has made this working or found any alternative

  • 1
    The first question coming into my mind: Why do you need such a construction? Why using a directory which is not convention? And more important: What kind of problem you are trying to solve? Furthermore reading about the existing configuration: https://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html – khmarbaise Mar 18 '19 at 05:40
  • Added the use case in the question. – user2110254 Mar 18 '19 at 10:14
  • Using a directory is valid. Why do you say its not convention? – user2110254 Mar 18 '19 at 11:14
  • I would suggest to simply use the conventions and put the files into `src/main/resources` and they will be picked up automatically simply by using `mvn clean package` otherwise you need to define several options etc. which is really clumsy and error prone. What I don't understand is: `I want only those 2 modified files to be included in the final package post maven build.`...? – khmarbaise Mar 21 '19 at 10:22

0 Answers0