0

Is it possible to grant/request evelated privileges for particular goals within a pom?

Splecifically I need to retrieve an artifact from a repository then store that artifact in a file system directory the user does not have write permissions on.

Ideally I would like to elevate the users privileges just for the goal that writes the retrived file to the file system.

Is there any way to use the maven-dependency-plugin copy goal using sudo or something similar to achive this?

It needs to go in the pom.xml so it will work for testing the project within eclipse, so

sudo mvn ...

isn't an option (irrespective of that being a good idea or not).

TaninDirect
  • 458
  • 1
  • 7
  • 15

1 Answers1

1

I don't think that's possible. But the question is a bit confusing. You want to pull the artifact from a repository that the user can't access or you want to install the resulting artifact in a local repository that the user can't access?

In either case i can't see why a user that's trying to install an artifact (or pull a dependency) would be using a repository that it can't access. Maybe if you give a bit of context we can suggest an alternative

Hilikus
  • 9,954
  • 14
  • 65
  • 118
  • Got it. But why is the user running mvn install not able to write in the repo. it doesn't make sense. Can you give more context to determine if you have a strong reason to violate the normal use case or if it's just a mistake/misconfiguration – Hilikus Sep 19 '12 at 04:07
  • It's quite possibly a misconfiguration as I'm quite new to maven. It is not being done as part of the install phase to deploy the app, rather it is being done as part of the initialize phase to prepare the environment for running the unit tests. This means it isn't trying to store the file in the local repo, but rather in another file system directory. – TaninDirect Sep 19 '12 at 04:27
  • If you do such things than you don't have a unit tests. This is called an integration test. May be you should about using an contious integration solution to do such things. – khmarbaise Sep 19 '12 at 06:20
  • can't you just change the folder's permission to allow the user running maven to use it? Everything that the user running maven needs should be w/r by it. What is the folder that's causing you trouble? what is being written to it? is it something that maven tries to write or is it something your unit tests try to write? – Hilikus Sep 19 '12 at 12:46
  • Given this is being used in this particular instance to help configure the test environment, it can easily be worked around by changing directory permissions, calling out to a script using maven-exec or something similar, but I was hoping there was a more general way of elevating the privileges. Thanks for your help looking into this. – TaninDirect Sep 20 '12 at 00:01