How to throw error message when maven profile activation file exists failed to find file

96 Views Asked by At

I have this simple profile which check if file exsist . but the problem is , how to print error massge to the user when it failes to find the file :

<profiles>
        <profile>
            <id>my-json-test</id>
            <activation>
                <file>
                    <exists>/foo/test.json</exists>
                </file>
            </activation>
            
    <build>

.....

Say the file /foo/test.json dosn't exixst .. how this activation can print error ? as now it do not print any thing just fail the build task .

1

There are 1 best solutions below

0
Robert Scholte On

It looks like you are using profiles for the wrong reason. As I read it you want to enforce that this file exists. As with anything you want to enforce, the maven-enforcer-plugin is your friend. In this case try https://maven.apache.org/enforcer/enforcer-rules/requireFilesExist.html