Skip to content

Conversation

ia3andy
Copy link
Contributor

@ia3andy ia3andy commented Oct 16, 2019

Closes #4601

@ia3andy
Copy link
Contributor Author

ia3andy commented Oct 16, 2019

I abstracted MavenExtensionsTest so we have the same coverage for Gradle.

Note that one test is not passing with Gradle and I think it should come in another issue/PR:
https://github.com/quarkusio/quarkus/pull/4614/files#diff-cec51f6e2476bda2790e7fe4074caabdR19

@ia3andy ia3andy requested review from geoand and gsmet October 16, 2019 15:36
protected boolean containsBOM() {
return buildContent.contains("enforcedPlatform(\"io.quarkus:quarkus-bom:");
protected boolean containsBOM() throws IOException {
return getModel().getBuildContent().contains("enforcedPlatform(\"io.quarkus:quarkus-bom:");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although G:A:V syntax is more common, people can also declare gradle dependencies with expanded syntax like this:

group: 'io.quarkus', name: 'quarkus-bom', version: '0.25.0'

with any amount of spacing or newlines in between

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, not mentioning the code formatting could vary. This functionality needs to be re-written properly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qute to the rescue :)

StringBuilder newBuildContent = new StringBuilder();
readLineByLine(buildContent, new AppendDependency(newBuildContent, dependency));
buildContent = newBuildContent.toString();
readLineByLine(getModel().getBuildContent(), new AppendDependency(newBuildContent, dependency));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while it's not an issue with this PR specifically, I was looking into the code for AppendDependency and I noticed 2 corner cases that don't currently work:

  1. It looks for line.startsWith("dependencies {" which doesn't account for additional spacing between dependencies and { and also doesn't account for leading whitespace (which is normal if this is being applied in a subprojects{} block for example).
  2. If we have the quarkus plugin installed already, but no dependencies{} at all, nothing gets added. For this case I think we should probably add the quarkus-bom dependency with a version corresponding to the quarkus-gradle-plugin, followed by the rest of the requested extension dependencies as normal

Copy link
Contributor Author

@ia3andy ia3andy Oct 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I didn't really look at the business involved.. I just fixed the bug using the same system used in MavenBuildFile and added the tests that should have been there in the first place..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point we are going to rewrite most of the codegen part with a real template engine for Quarkus that is beeing developed https://github.com/quarkusio/qute.

But for now, any corner case you see, please feel free to provide a PR with some tests :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this part of the code is messy currently... So trying to improve little things probably doesn't make a ton sense, tests on the other hand definitely do :).
@ia3andy did you sign up for rewriting the part this qute? :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geoand why not, that might be fun, though for now I have plenty on my plate 😅

@geoand
Copy link
Contributor

geoand commented Oct 17, 2019

@ia3andy seems like the JVM tests are failing

@ia3andy
Copy link
Contributor Author

ia3andy commented Oct 17, 2019

@gsmet we need that merged asap too

@aloubyansky aloubyansky added this to the 0.26.0 milestone Oct 17, 2019
@aloubyansky aloubyansky merged commit 0761299 into quarkusio:master Oct 17, 2019
@ia3andy ia3andy deleted the fix-4601 branch October 17, 2019 14:12
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.

Adding extension using gradle plugin erase gradle config files content

4 participants