maven creates a ? directory instead of .m2 repository

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

maven creates a ? directory instead of .m2 repository

Dan Pungă
Hello all!

I'm trying to get a Java app deployed in an OpenShift container and I'm
experiencing a strange behaviour.

At build time (firs build), maven is creating a ? directory inside the
context from which it's called (so in my project's root folder) to
create the repository directory and download the build time
dependencies. I'd really want to know why it does that, and make it use
the .m2 location from the home folder. I have a feeling it has to do
with some sort of fishy user permission, but I'm not sure if it's
actually the case or where am I doing wrong.

That's the short description of the problem. My working system is like this:
- on a OpenShift/docker virtual machine running centos 7
- I've installed maven version 3.3.9 from
https://www.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
- I've setup a $HOME directory which contains a .m2 directory that
contains my settings.xml to make maven use a local/cached repository
- this was done under root, but I've recursively changed ownership and
permission to the common user 1001 for what's related to maven
- my sources come on this system with a bit if an awkward set of
permissions so that the owner is user (1001), but the group is root

When I run maven with just the targets used for the project, it doesn't
read from the settings.xml, but instead tries to connect to the global
repository.
When running maven with the "-s $HOME/.m2/settings.xml" option, it does
take it into consideration and the build works fine, but it is
downloadying all the repository artifacts into ?/repository folder under
the local dir (app folder, the one which holds the pom.xml file).

Any idea what would be the reason for this behaviour?

Thank you in advance!

Reply | Threaded
Open this post in threaded view
|

Re: maven creates a ? directory instead of .m2 repository

mgainty
mg>diag advice below


________________________________
From: Dan Pungă <[hidden email]>
Sent: Monday, February 19, 2018 4:00 PM
To: [hidden email]
Subject: maven creates a ? directory instead of .m2 repository

Hello all!

I'm trying to get a Java app deployed in an OpenShift container and I'm
experiencing a strange behaviour.

At build time (firs build), maven is creating a ? directory inside the
context from which it's called (so in my project's root folder) to
create the repository directory and download the build time
dependencies. I'd really want to know why it does that, and make it use
the .m2 location from the home folder. I have a feeling it has to do
with some sort of fishy user permission, but I'm not sure if it's
actually the case or where am I doing wrong.

That's the short description of the problem. My working system is like this:
- on a OpenShift/docker virtual machine running centos 7
- I've installed maven version 3.3.9 from
https://www.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
- I've setup a $HOME directory which contains a .m2 directory that
contains my settings.xml to make maven use a local/cached repository
- this was done under root, but I've recursively changed ownership and
permission to the common user 1001 for what's related to maven

mg>did you follow the steps for useradd here?
https://www.ehowstuff.com/how-to-add-user-to-root-group-on-centos-5-7/
How to Add User to root Group on CentOS 5/CentOS 6<https://www.ehowstuff.com/how-to-add-user-to-root-group-on-centos-5-7/>
www.ehowstuff.com
useradd is a low-level utility to create new users to the system. When used without the -D option, useradd command will create a new user account using the command ...

mg>what happens when you look at user groups..do you see new user (whatever name you used)
mg>grep PossibleIncorrectlyInterpretedUserNameInRootGroup /etc/group


- my sources come on this system with a bit if an awkward set of
permissions so that the owner is user (1001), but the group is root

When I run maven with just the targets used for the project, it doesn't
read from the settings.xml, but instead tries to connect to the global
repository.

mg> -o option tells maven to run offline

When running maven with the "-s $HOME/.m2/settings.xml" option, it does
take it into consideration and the build works fine, but it is
downloadying all the repository artifacts into ?/repository folder under
the local dir (app folder, the one which holds the pom.xml file).

Any idea what would be the reason for this behaviour?

Thank you in advance!

Reply | Threaded
Open this post in threaded view
|

Re: maven creates a ? directory instead of .m2 repository

Dan Pungă
Thank you for your advice and suggestion!

Your answer made me think that it has to do with poor OS config from my
part (that's what happen with mindless copying..:) ).
I guess maven is trying to read the $USER and $HOME environment
variables of the current user, but since my user 1001 has just the $UID
and not the rest of its environment setup, it fails. So it's not added
to groups, doesn't have a name, password, home directory, etc.

The workaround that I've found was to specifically pass -Duser.dir=$HOME
when invoking maven under user 1001 and it solved my issue.

Thank you!

On 20.02.2018 15:27, Martin Gainty wrote:

> mg>diag advice below
>
>
> ________________________________
> From: Dan Pungă <[hidden email]>
> Sent: Monday, February 19, 2018 4:00 PM
> To: [hidden email]
> Subject: maven creates a ? directory instead of .m2 repository
>
> Hello all!
>
> I'm trying to get a Java app deployed in an OpenShift container and I'm
> experiencing a strange behaviour.
>
> At build time (firs build), maven is creating a ? directory inside the
> context from which it's called (so in my project's root folder) to
> create the repository directory and download the build time
> dependencies. I'd really want to know why it does that, and make it use
> the .m2 location from the home folder. I have a feeling it has to do
> with some sort of fishy user permission, but I'm not sure if it's
> actually the case or where am I doing wrong.
>
> That's the short description of the problem. My working system is like this:
> - on a OpenShift/docker virtual machine running centos 7
> - I've installed maven version 3.3.9 from
> https://www.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
> - I've setup a $HOME directory which contains a .m2 directory that
> contains my settings.xml to make maven use a local/cached repository
> - this was done under root, but I've recursively changed ownership and
> permission to the common user 1001 for what's related to maven
>
> mg>did you follow the steps for useradd here?
> https://www.ehowstuff.com/how-to-add-user-to-root-group-on-centos-5-7/
> How to Add User to root Group on CentOS 5/CentOS 6<https://www.ehowstuff.com/how-to-add-user-to-root-group-on-centos-5-7/>
> www.ehowstuff.com
> useradd is a low-level utility to create new users to the system. When used without the -D option, useradd command will create a new user account using the command ...
>
> mg>what happens when you look at user groups..do you see new user (whatever name you used)
> mg>grep PossibleIncorrectlyInterpretedUserNameInRootGroup /etc/group
>
>
> - my sources come on this system with a bit if an awkward set of
> permissions so that the owner is user (1001), but the group is root
>
> When I run maven with just the targets used for the project, it doesn't
> read from the settings.xml, but instead tries to connect to the global
> repository.
>
> mg> -o option tells maven to run offline
>
> When running maven with the "-s $HOME/.m2/settings.xml" option, it does
> take it into consideration and the build works fine, but it is
> downloadying all the repository artifacts into ?/repository folder under
> the local dir (app folder, the one which holds the pom.xml file).
>
> Any idea what would be the reason for this behaviour?
>
> Thank you in advance!
>
>