You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Alexander Bender (JIRA)" <ji...@apache.org> on 2016/07/28 06:23:20 UTC

[jira] [Comment Edited] (MNG-6071) GetResource ('/) returns 'null' if build is started with -f

    [ https://issues.apache.org/jira/browse/MNG-6071?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15397013#comment-15397013 ] 

Alexander Bender edited comment on MNG-6071 at 7/28/16 6:23 AM:
----------------------------------------------------------------

- I need to know the target folder because the build will put some files there in a different step. The files cannot be in the resources.
-- (Elastic search phonetic dependencies need to be in the file system and are put there via maven-dependency-plugin / unpack-dependencies)
- I tried to call it this way because i'm within a shell script and telling maven where the pom.xml is is better than navigating to the file itself.

I understand that you are trying to help my find a solution to my problem and I am grateful for that. Does this mean that the behavior described by me is "by design" or am I just trying something that is not supported and works by sheer luck?


was (Author: mpsabe):
- I need to know the target folder because the build will put some files there in a different step. The files cannot be in the resources.
- I tried to call it this way because i'm within a shell script and telling maven where the pom.xml is is better than navigating to the file itself.

I understand that you are trying to help my find a solution to my problem and I am grateful for that. Does this mean that the behavior described by me is "by design" or am I just trying something that is not supported and works by sheer luck?

> GetResource ('/) returns 'null' if build is started with -f
> -----------------------------------------------------------
>
>                 Key: MNG-6071
>                 URL: https://issues.apache.org/jira/browse/MNG-6071
>             Project: Maven
>          Issue Type: Request
>    Affects Versions: 3.2.1, 3.3.1, 3.3.9
>         Environment: Windows 10 x64
> Tested in cmd.exe, git bash.
>            Reporter: Alexander Bender
>            Priority: Minor
>
> I set up a very simple test maven project with only a dependency to testNG.
> {code}
>     public class TestTest {
>     @Test
>     public void test() {
>         System.out.println(getClass().getResource("/"));
> {code}
> Depending on how I build this, the call either returns null or the expected directory. How is that?
> {code}
>     // Prints: file:/C:/workspace/test/testproject/target/test-classes/
>     mvn clean test -Dtest=TestTest -f testproject/pom.xml
>     // Prints: null
>     mvn clean test -Dtest=TestTest -f ./testproject/pom.xml
> {code}
> Note that the second call includes "./" after -f.
> I actually want to find out the /target folder regardless of scenario (testNG in IntelliJ, Maven, Jenkins Buid, ...). So far, this way has proven the most reliable.
> {code}
>         System.out.println(getClass().getResource("./"));
> {code}
> This seems to reliably point to file:/C:/workspace/test/testproject/target/test-classes/com/testproject/test. Would this be safer to use?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)