Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Anderssorby
Copy link
Contributor

Now it parses the pom.xml and extracts the repositories. Probably there are improvements that can be made.

@fzakaria
Copy link
Owner

Sorry I haven't reviewed this yet; it's on my radar.
I've been writing the Maven documentation at https://github.com/NixOS/nixpkgs/pull/100660/files

Copy link
Owner

@fzakaria fzakaria left a 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.

  1. I suspect many put repositories in settings.xml which can be read via a Maven library
  2. There is better libraries to read pom.xml native to Maven

👍 thank you for the contribution so far!

Comment on lines +118 to +124
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());
Copy link
Owner

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 )
{
     ...
}

Copy link
Contributor Author

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.

Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants