-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read repos from pom #28
base: master
Are you sure you want to change the base?
Conversation
f3f4133
to
99864d6
Compare
Sorry I haven't reviewed this yet; it's on my radar. |
f3f1bd7
to
9a7ecc1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the contribution -- sorry for getting back to late but I think it needs improvement.
- I suspect many put repositories in settings.xml which can be read via a Maven library
- There is better libraries to read pom.xml native to Maven
👍 thank you for the contribution so far!
public static ImmutableList<URL> getRepositoriesFromPom(Document doc) throws XPathException, MalformedURLException { | ||
|
||
XPath xPath = XPathFactory.newInstance().newXPath(); | ||
String expression = "/project/repositories/repository"; | ||
|
||
NodeList repositories = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET); | ||
LOGGER.debug("Found {} repositories in pom.xml", repositories.getLength()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are maven libraries for parsing the pom file.
I think they should be used instead ?
We also want to parse the ~/.m2/settings.xml file on the users machine.
ModelBuildingRequest req = new DefaultModelBuildingRequest();
req.setProcessPlugins( false );
req.setPomFile( file );
req.setModelResolver( new RepositoryModelResolver( basedir, pathTranslator ) );
req.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
Model model;
try
{
model = builder.build( req ).getEffectiveModel();
}
catch ( ModelBuildingException e )
{
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be better. I don't have a lot of time to work on this anymore however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries; thank you for trying the contribution.
We can keep it open if others want to try and continue it or just close it then for now?
I'm also a bit swamped this quarter so I likely won't be able to make the addition myself.
Now it parses the pom.xml and extracts the repositories. Probably there are improvements that can be made.