I can the the current username in a
I intended to write a maven plugin to provide the property
user.id but then I did not find a way to get the userid with standard java methods.
There are two projects (Java Native Access, Java Native Interface) to have direct access to native informations, but so far I haven't found a way to get the
I fixed my problem by adding a
umask-call in my Dockerfile. I strongly recomend to use a solution that does not requires the user-id within maven.
But working on the issue I created a solution for others that really need this. It takes the
user.name-property from the system-properties and then opens the
passwd-file to search for the uid. Of course this will only work for unix-like systems and it couples the build directly with your environment, so use this solution wisely (idealy not at all).
To use my solution, add this to your
<plugin> <!-- Plugin only works with unix-like environments, please use it wisely! --> <groupId>org.rjung.util</groupId> <artifactId>user-id-maven-plugin</artifactId> <version>1.0</version> <executions> <execution> <goals> <goal>user-id</goal> </goals> </execution> </executions> </plugin>