I need to programmatically gather some paths inside a Maven project, in particular to refer to the project artifact. Using
URL MyClass.class.getClassLoader().getResource(String name) works for a path relative to the target/classes folder of the project, but since the artifact sits in the target folder it is not possible to reference it. A path like
System.getProperty("user.dir") + "/target" does not convince me at all at least for the fact that the target folder name, while standard, is not safely portable.
Is there a Maven-aware library solution that exploits a relative path?