${project.build.resources[N].directory}
N = Index of your resource (e.g.: 0.1.2 and so on).
According to the documentation, the default resource directory(a.k.a Resources) is located in:
src/main/resources
What would give us the possibility of access through the expression:
${basedir}/src/main/resources
However, it is possible to specify a different directory from the default for resources:
<project>
...
<build>
...
<resources>
<resource>
<directory>[seu-diretório]</directory>
</resource>
</resources>
...
</build>
...
</project>
In addition, it is still possible to specify multiple resource directories:
<project>
...
<build>
...
<resources>
<resource>
<directory>src/main/recursos-1</directory>
</resource>
<resource>
<directory>src/main/recursos-2</directory>
</resource>
...
</resources>
...
</build>
...
</project>
Therefore, the directory expression of a resource is:
${project.build.resources[N].directory}
Where N is your resource index. Example:
${project.build.resources[0].directory}
${project.build.resources[1].directory}
...
This may raise another question: How do I know which directory will be associated with index 0, 1, 2, etc?
There is the plugin help:evaluate that helps test expressions.
Example:
<project>
...
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
</plugin>
...
<resources>
<resource>
<directory>src/main/recursos-1</directory>
</resource>
<resource>
<directory>src/main/recursos-2</directory>
</resource>
...
</resources>
...
</build>
...
</project>
Testing(bash):
mvn help:evaluate -Dexpression=project.build.resources[0].directory | grep -v "\["
mvn help:evaluate -Dexpression=project.build.resources[1].directory | grep -v "\["
Although the plugin documentation specifies the options -q(quiet) and -Dforcestdout, did not succeed to display only the result of the expression ${project.build.Resources[0]. directory}, for this reason I used grep -v to filter the output.
Have you looked at something from here help you?
– StatelessDev
@Statelessdev actually copied and pasted, but without understanding. Why is it a vector? Is there a position 1? What would it mean?
– Jefferson Quesado
Actually, I googled to see if I could find something in English, I found it and put it here to help you haha. If I can solve and post an answer, I’ll learn too. ;)
– StatelessDev
You can use:
${basedir}/src/main/resources/
. Or are you looking for a single variable, which carries all this information?– Dherik
@Dherik I was looking for a variable that beautifully indicated the position. This is the default place, but it can be overwritten by someone with no heart, so I’d like to take this directory that overwrites the pattern.
– Jefferson Quesado
@Jeffersonquesado As far as I know, for this heartless person to overwrite the default "Resources" directory he would have to specify the directory in pom.xml with the <Resources> tag. Because it is possible to specify multiple "Resources", the access form is an array ${project.build.Resources[N]. directory}. Here in the documentation explains about that.
– Tom Melo
@Tommelo is what I’m talking about. Thank you very much for the reference. If you can elaborate an answer, it would be of great value
– Jefferson Quesado