last day (14 days later) » 

4:48 PM
0
A: Can you get plugin configuration from a POM using aether?

TunakiI don't know if there is a simpler way, but you can use the Aether API to resolve the POM artifact you're interested in, and then build a Maven model from it with the Model Builder API. First of all, if the coordinates to your artifact isn't to the POM artifact, you need to convert them to the P...

 
Trying to test the above code, although it fetches the jar not the pom
 
@user_mda I have included the code to fetch the POM not the JAR. Look at Artifact pomArtifact and buildingRequest.setPomFile(pomArtifact.getFile());.
 
yes I copied the same code, but it fails at parsing it, since pomArtifact.getFile() gives me a jar
 
The pom artifact is constructed with new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), "pom", artifact.getVersion());, so it should not reference the JAR, the 3rd parameter is the extension, which is "pom" here (and it didn't in the tests I've made). What are you using for coordinate?
 
Yes Thats what I expected it to do, I am using the following to assign coordinates -- String.format("%s:%s:%s", groupID, artifactID, version);
 
4:48 PM
Can you post System.out.println(artifact) and System.out.println(pomArtifact)? They should not be the same.
 
You re right in that they are not the same , artifact is the jar om artifact is the pom but pomArtifact.getFile gets the jar not the pom.xml
 
Ooh I see I made a small mistake in the code I posted! Sorry for that! It should be ArtifactRequest request = new ArtifactRequest(pomArtifact, ...) and not ArtifactRequest request = new ArtifactRequest(artifact, ...) I just edited the mistake.
 
Thank you! That gets me the pom although I am getting a different error
Hi , looks like it is throwing another error
 
Hey! What's the error you're having?
 
no model resolver provided, cannot resolve parent POM com.group.id:artifactID:0.8-SNAPSHOT for POM ${appGroupId}:artifactID:[unknown-version] ,
 
4:51 PM
Oh a snapshot
Are you sure this parent POM is present in the remote repository you're using?
 
should it matter if its a snapshot as long as it fetches the correct pom?
So what the code does it that it is trying to create an effective om by trying to resolve the parent pom correct?
 
Yep
Where did it fail? On the modelBuilder.build call? Or on the resolveArtifact?
 
what is a model resolver? also the parent pom it is referring to is the artifact's pom itself
 
what?! :D this can't be
 
it fails on this line where it sets the pom
 
4:56 PM
Can you tell me the coordinates you are using so that I can test?
 
This is internal to my company :D
 
Ok :) What's the snapshot policy of your remote repository? Print System.out.println(aetherSession.getRemoteRepository())
 
sorry was debugging a biit on my side, I see there is the parent pom in the repo
also the error is this
no model resolver provided, cannot resolve parent POM "correct-parent-pomhere:0.8-SNAPSHOT" for POM ${appGroupId}:correct-artifact-id-for the current pom:[unknown-version] ,
not sure why it would say unknown version,
is that the problem?
Btw thanks for sticking aroung while I debug
my remote repo is a cached copy of releases and snapshots
 
Hmm ok I'm reproducing the issue with another example POM having a parent, looking into it
 
cool thanks!
 
5:21 PM
not entirely familiar with the lib but should we be setting a model resolver on the request?
 
5:36 PM
Yes
Can you post the code you're using to create your Aether RepositorySystemSession @user_mda?
 
5:56 PM
public class AetherSession {

private final RepositorySystem repoSystem;
private final RepositorySystemSession repoSession;
private final RemoteRepository remoteRepo;

private AetherSession(RepositorySystem repoSystem,
RepositorySystemSession repoSession, RemoteRepository remoteRepo) {
this.repoSession = repoSession;
this.repoSystem = repoSystem;
this.remoteRepo = remoteRepo;
}

public RepositorySystem getRepoSystem() {
return repoSystem;
}

public RepositorySystemSession getRepoSession() {
return repoSession;
 
Thanks
 
6:12 PM
I am going to try it out by setting the model resolver
 
Yeah that's the issue
Ok @user_mda I found a way to do it. It's really not pretty though...
 
were you able to get a resolved pom?
 
Yep
 
oh great
 
I tested with org.springframework.batch:spring-batch-admin-manager:1.3.1.RELEASE
it has a parent POM
 
6:15 PM
Nice
did you have to do more than setting a resolver?
 
No, it was enough
 
Did you set it with request.setModelResolver(new MavenModelResolver(getSystem(), getSession(), getRemoteRepositories()));
 
Hmm no I don't have that class
You'll need to change a little your AetherSession class
and store the ServiceLocator as well
 
Do you have to build a model resolver? Thought I could get it through the dependency
why the aetherSession
 
Yeah it needs to be built
Apparently, it can't be injected
 
6:30 PM
ah
 
Basically, instead of return new AetherSession(repoSystem, session, central);, you'll need to have return new AetherSession(repoSystem, session, central, locator);
in your build() method
and have a new field for the locator with a getter
 
is the locator to build the model resolver?
 
yes, it's needed
I made the edit @user
Tell me if you hit any issue
 
Thanks!
I will try it and let u know
 

last day (14 days later) »