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

Handle gradle included-builds in quarkusDev task #12046

Merged
merged 1 commit into from
Feb 17, 2021

Conversation

glefloch
Copy link
Member

Right now, included build were ignored while creating the quarkus model.

This branch add support for included build by:

  • Looking for included build
  • Building the quarkus model of those projects
  • Adding the model and its dependencies to the current model.

When looking for included builds, the gradle API only gives us the project name and the project directory. That's why I use the Quarkus model to collect included build infos.

close #11902

@aloubyansky
Copy link
Member

That's a tricky one. I am not sure this is the proper way, tbh. AFAIU, included builds should be replacing the matching app dependencies. It's not the same as resolving sets of dependencies separately and then merging them in. E.g. if the included build had a different dependency graph then the dependency it was replacing, I don't think you would get the proper classpath, you would get a mix of both.
Have you tried looking into Configuration.getResolutionStrategy().dependencySubstitution(...)?

@glefloch
Copy link
Member Author

@aloubyansky, I wasn't aware of Configuration.getResolutionStrategy().dependencySubstitution(...) I'm gonna look in this way.

@glefloch glefloch force-pushed the fix/11902 branch 2 times, most recently from 298070a to c98fbaa Compare September 16, 2020 12:33
@gsmet gsmet added the triage/needs-rebase This PR needs to be rebased first because it has merge conflicts label Nov 9, 2020
@gsmet
Copy link
Member

gsmet commented Nov 9, 2020

This PR needs a rebase and probably another look then :).

@ghost ghost added area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/gradle Gradle labels Nov 12, 2020
@glefloch glefloch removed the triage/needs-rebase This PR needs to be rebased first because it has merge conflicts label Feb 11, 2021
@glefloch
Copy link
Member Author

@aloubyansky I was able to work on this. Actually, resolved dependency are already substituted.
A substituted project can be detected like a local module (using instanceof ProjectComponentIdentifier, the only difference of that the included module cannot be retrieved using the project. I used the GradleConnector

Project projectDep = project.getRootProject()
.findProject(((ProjectComponentIdentifier) a.getId().getComponentIdentifier()).getProjectPath());
addDevModePaths(dep, a, projectDep);
Optional<IncludedBuild> includedBuild = includedBuild(project, a.getName());
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't this be replaced with project.getGradle().includedBuild(name)?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I just wrapped that in a try/catch because project.getGradle().includedBuild(name) throws an exception if the project is not an included build.

@@ -402,6 +413,25 @@ private void addDevModePaths(final DependencyImpl dep, ResolvedArtifact a, Proje
}
}

private void addSubstitutedProject(final DependencyImpl dep, File projectFile, LaunchMode mode) {
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, have you tried to measure how long this method takes to execute? Is it seconds?

Copy link
Member Author

@glefloch glefloch Feb 12, 2021

Choose a reason for hiding this comment

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

I just ran some really basics benchmarks, it takes 2 to 4 seconds..

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, do you mind not using Optional in this case? Making includeBuild return boolean will make it look simpler and perform better.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yes for sure. I'm trying to understand why the test fails in ci and passes on my machine. I will remove the optional once everything is ok.

Copy link
Member

Choose a reason for hiding this comment

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

I just ran some really basics benchmarks, it takes 2 to 4 seconds..

Just to clarify, was it a restart/reload that was taking 2 to 4 seconds in dev mode?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's for the first quarkusDev start. Reload is not impacted, and thanks to daemons/caches, next restart are not really impacted.

Copy link
Member

Choose a reason for hiding this comment

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

Right, that's good. Thanks!

Copy link
Member

@aloubyansky aloubyansky left a comment

Choose a reason for hiding this comment

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

Thanks @glefloch !

@glefloch glefloch merged commit 5c7a3cc into quarkusio:master Feb 17, 2021
@quarkus-bot quarkus-bot bot added this to the 1.13 - master milestone Feb 17, 2021
@glefloch glefloch deleted the fix/11902 branch February 17, 2021 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/gradle Gradle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gradle quarkusDev run fails with --include-build
3 participants