You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/08/19 20:04:12 UTC

[GitHub] [netbeans] sdedic opened a new pull request, #4517: [Preview] Gradle project introspection

sdedic opened a new pull request, #4517:
URL: https://github.com/apache/netbeans/pull/4517

   This is a WIP **and will not be merged** - I'll create a new PR for the actual merge. This PR is meant as a heads-up or preview.
   
   The original goal was to 'find out what file(s) / artifact(s) a project produces". I started with JAR initially ... and then followed up by support for micronaut / native-image. And then things got very complicated. With all the Gradle convetions, defaulting from task to extension properties ...
   
   Initially I wanted to extract metadata out of the gradle build: If the IDE knows what tasks are there, what are properties of those tasks and - if the value is structured - what are the nested properties etc, the IDE might be able to quick-parse the buildscript, ignore closures and find out property values. The same for extensions.
   Then I've realized that I could eventually extract the computed values, too - it is possible to ask provider NOT to run tasks, but return values as they are computed at the start of the build. Not perfect, but sufficient.
   
   So in this PR you can find & comment the code that sucks information out of the gradle build. With this support, finding out the directory and filename of a JAR produced is a simple matter of:
   
   ```
               BuildPropertiesSupport props = BuildPropertiesSupport.get(project);
               Property p = props.findTaskProperty("jar", "archiveFileName");
               if (p != null && p.getStringValue() != null) {
                   filename = p.getStringValue();
               } else {
                   // Some guess based on project name and version
               }
               p = props.findTaskProperty("jar", "destinationDirectory");
               if (p != null && p.getStringValue() != null) {
                   dir = p.getStringValue();
               }
   ```
   
   ... and it WORKS !


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lkishalmi commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
lkishalmi commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1223607699

   Back to Our original issue. Aren't you looking for the outgoing variants by
   chance? Do a gradlew oV in your project and see the output.
   
   On Mon, Aug 22, 2022, 14:53 Svatopluk Dedic ***@***.***>
   wrote:
   
   > Well, I'm not sure that the instantiation does not happen with the current
   > implementation. I'm sure it happens for the jar and war task if they are
   > exists as well as the compile tasks.
   >
   > OK, I'll try with more examples, but the task creation stacktrace I saw
   > originated from enumeration in detectPlugins -- I suspect that all tasks
   > were created, not just jar/war/ear.
   >
   > —
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/netbeans/pull/4517#issuecomment-1223156348>,
   > or unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/AAKRKRLF5BALPNN7BAI67BLV2PZF5ANCNFSM57B2HF6Q>
   > .
   > You are receiving this because you were mentioned.Message ID:
   > ***@***.***>
   >
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1221889908

   > 
   > ```java
   > GradleJavaProject gjp = GradlJavaProject.get(project);
   > File jar = gjp.getMainJar();
   > ```
   
   Well, the  main issue is not to find exactly the jar; but 
   - what the `build` actually does. Different plugins glue different tasks to `build` lifecycle one. For this, I've analyzed the inter-Task dependencies. It can be still approximated from just known Plugins though. 
   - what the `native-image` output is - in the case native buld. Not just the jar. 
   
   The idea to separate the loading process seems  good, as it duplicates the infrastructure.  I would initially (since I need some results soon) drop the task _properties_ introspection (assuming separate APIs for loading the data) - as actually the task proeprties default to (combination of) proiject extension values, it's a good approximation and a good tradeoff for me.
   
   Are you sure we're not instantiating Tasks even with the current implementation ;) ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1223156348

   > Well, I'm not sure that the instantiation does not happen with the current implementation. I'm sure it happens for the jar and war task if they are exists as well as the compile tasks.
   
   OK, I'll try with more examples, but the task creation stacktrace I saw originated from enumeration in `detectPlugins` -- I suspect that all tasks were created, not just jar/war/ear.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1221952761

   Update: I made a quick check - put a few breakpoints into e.g. `Jar` task ... the fact is, that the tasks **are instantiated already**, because of [detection of task properties](https://github.com/apache/netbeans/blob/master/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java#L223) which is present in the `master`. 
   Even some more weird things. like `computeManifest` execute, thanks to 
   ```
   jar.manifest(manifest -> {
   ```
   https://github.com/micronaut-projects/micronaut-gradle-plugin/blame/f3687ae6b2d8d830b7742788577b80351fa88ffc/docker-plugin/src/main/java/io/micronaut/gradle/docker/MicronautDockerPlugin.java#L157
   
   ... the original impl (2 years ago) used `project.afterEvaluation` - is that one of the typical things the users do mistakes with early evaluation ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lkishalmi commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
lkishalmi commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1242895469

   I'm finishing my ANTLR works. After that I'm going to give this another try.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1221082229

   
   > It is Ok to create a PR in your personal repo and ask for review there. I guess I need to review WIP and WIP 2 commits.?
   
   Yes, just those two. The most interesting part is the `NbProjectInfoBuilder` in NB gradle tooling.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lkishalmi commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
lkishalmi commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1221826551

   Well, well...
   I see some of good improvements on the code, though some of these changes are a bit disturbing.
   And that is the auto-discovery of the task properties.
   
   Gradle evolved quite a lot during the last years. One of the direction they went is doing the lazy initialization of the tasks, by using task registration instead or actual instance creation. Though when you request a task, it will be instantiated. People are very creative to create really poor quality Gradle build scripts, so task instantiation can be really expensive.
   
   If you would like to experiment with this, then probably shall create a feature branch. Create a separate TaskInfoModel add it's own cache, and probably some loading infrastructure. I would not make the NbProjectInfo more bloated.
   
   To find out the directory and filename of the main jar is really easy right now (not fancy and shiny, but works in most cases):
   
   ```java
   GradleJavaProject gjp = GradlJavaProject.get(project);
   File jar = gjp.getMainJar();
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lkishalmi commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
lkishalmi commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1222634631

   Well, I'm not sure that the instantiation does not happen with the current implementation. I'm sure it happens for the jar and war task if they are exists as well as the compile tasks. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1234236277

   Let's focus back on the topic of gathering information. To build `native-image` support, I'd need some information from the extension / task that is configured for the project. I agree that instantiating tasks (= user code) could be dangerous. 
   
   It seems that instantiation happens every time, just because we're **enumerating tasks** from the buildscript, so we can (for example) present them, for example, in the `Navigator` window for a gradle project.
   Not only Jar task, which will be eventually executed as the part of buildscript, but all of them - e.g. `OutgoingVariantsReportTask` (`./gradlew oV`) is instantiated.
   
   So, if the concern that task creation is harmful is valid and important, we should remove the task listing code and corresponding feature(s) in the IDE (or implement them using another technique). Given that this feature is in the Gradle Projects module for some years already, with no significant bug reports against ... I would not go that way: it might be bad (this is why we have 'Do you trust the build script' question, among other reasons)  ... but seems acceptable.
   
   If there Tasks already instantiate ... why don't exploit the data then, so the IDE can evaluate using the most accurate values ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1233874554

   > Back to Our original issue. Aren't you looking for the outgoing variants by chance? Do a gradlew oV in your project and see the output.
   > […](#)
   
   The PR targets two things. First, the ability to find out product(s) of the project. Outgoing variants could be useful, but on the sample project (micronaut project, that includes native-image build plugin), the `gradlew oV` output does not contain an information that such thing is produced:
   ```
   sdedic@sdedic-nb4:oci/microdemo5$ gradle oV  | grep build/
   Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
       - build/libs/microdemo-0.1.jar (artifactType = jar)
       - build/libs/microdemo-0.1.jar (artifactType = jar)
             - build/classes/java/main (artifactType = java-classes-directory)
             - build/resources/main (artifactType = java-resources-directory)
       - build/libs/microdemo-0.1-all.jar (artifactType = jar)
       - build/libs/microdemo-0.1-all.jar (artifactType = jar)
       - build/test-results/test/binary (artifactType = directory)
   ```
   There's no `build/native/nativeCompile/microdemo` in the output, althought the plugin is configured. That's natural, since it shows variant products for individual consumable configurations -- the `native-image` plugin does not create any specific configuration (maybe a deficiency ? especially in the .dll/.so scenario it could be).
   But as I see the output, it seems that the implementation of the project artifact query could be greatly improved following the OutgoingVariants report implementation - a theme for another PR!
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lkishalmi commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
lkishalmi commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1221079746

   Ugh.
   So at first the size of PR scared me, then I realized that this contains #4495.
   
   It is Ok to create a PR in your personal repo and ask for review there. I guess I need to review  WIP and WIP 2 commits.?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1221056557

   @lkishalmi please look at the thing from the conceptual standpoint; it seems that it is possible to deliver quite a lot of pre-computed values "as they are seen by gradle" to nb IDE for processing.
   
   To see captured data logged, use ` -J-Dorg.netbeans.modules.gradle.loaders.LegacyProjectLoader.level=400 ` when running NetBeans.
   
   The attachment is a capture from Micronaut sample project reload:
   [gradle.log](https://github.com/apache/netbeans/files/9385089/gradle.log)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic closed pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
sdedic closed pull request #4517: [Preview] Gradle project introspection
URL: https://github.com/apache/netbeans/pull/4517


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on pull request #4517: [Preview] Gradle project introspection

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4517:
URL: https://github.com/apache/netbeans/pull/4517#issuecomment-1290268551

   Obsoleted by #4729 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists