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

version could be properties which defined in project gav #69

Closed
cccfeng opened this issue Aug 22, 2018 · 10 comments
Closed

version could be properties which defined in project gav #69

cccfeng opened this issue Aug 22, 2018 · 10 comments

Comments

@cccfeng
Copy link

cccfeng commented Aug 22, 2018

throw new IllegalStateException("project does not have version and neither is a parent pom defined");

parent -->
child1 (g - a -v)
child2 (groupId - artifactId - ${xxx.version})

xxx.version is the property in parent artifactId

@robstoll
Copy link
Collaborator

Thanks for your input, I am not really sure if I get you right. Do you mean something as the following:
parent

<properties><xxx.version>1.0</xxx.version></properties>

child

<parent>...</parent>
<version>${xxx.version}</version>

@cccfeng
Copy link
Author

cccfeng commented Aug 22, 2018

You got it. I found this scene in a real project.

@robstoll
Copy link
Collaborator

robstoll commented Aug 22, 2018

But project.getVersion() is not null in such a case (it's ${xxx.version}), so the problem that this exception is thrown must be elsewhere.

@robstoll
Copy link
Collaborator

It seems to me that an interpolation is required here so that the version resolves to what is defined in the parent (or wherever it was defined). Is that your actual problem?

@cccfeng
Copy link
Author

cccfeng commented Aug 22, 2018

Yes. In fact the program try to compare version and "${parent.version}" , so it is the same that the version equals ${xxx.version} or something else

@robstoll
Copy link
Collaborator

Ok, I think now we are getting to the point 😄
You do not experience the exception in line 96 but in line 105 Non resolved project's GAV: ...
Would you like to try solve the problem yourself? I could give you some hints.

@cccfeng
Copy link
Author

cccfeng commented Aug 22, 2018

Ok,I would like to try it. Is the logic right to solve this problem ?
when version is not null, add the code

  1. whether the version resolved ? if not
  2. whether the version is a maven val, start with ${ and end with }
  3. if version is a maven val , then try to get from self properties.
  4. when self properties is null , try to get from it's parent gav
  5. or else throw the RuntimeException

robstoll pushed a commit to robstoll/pom-explorer that referenced this issue Aug 22, 2018
add test cases where a project with a parent has properties as version
@robstoll
Copy link
Collaborator

robstoll commented Aug 22, 2018

I think that's more or less it. The good thing though, there is already logic for this Project::interpolateValue. I have created two regression tests for you. They should be green at the end. Feel free to enhance the tests they are kind of basic. Have fun and if you have questions keep them posted here.

@cccfeng
Copy link
Author

cccfeng commented Aug 23, 2018

Got it. I will try to finish it.

robstoll added a commit that referenced this issue Aug 23, 2018
@robstoll
Copy link
Collaborator

Sorry, I only pushed the regression test to my fork but not to this repo. It is now inlcuded here as well: #70

@cccfeng cccfeng closed this as completed Dec 28, 2019
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

No branches or pull requests

2 participants