Open linux-china opened 2 years ago
this is not something that should be done by jbang idea plugin imo - at least not in its final form. users should not be encouraged to edit build.gradle when using jbang - build.gradle is to be treated as purely temporary intermediate format as jbang edit will regenerate build.gradle anyway.
we have prs/issues that suggest to add deps.txt as a more centralized location if that is a problem.
@maxandersen I have implemented this feature in 0.3.0 version. Sync Dependencies Action: right click script file and sync dependencies between JBang and Gradle. //DEPS
to implementation
or implementation to //DEPS
.
I really don't think this is right. Sure it's a nice feature but we should NOT assume build.gradle even exist.
If build.gradle not found, and Sync JBang DEPS
will not available.
For most developers, two ways to open JBang with IDEA:
idea -e Hello.java
: Light mode, and JBang plugin will not be loaded by IDEAjbang edit --open=idea HelloWorld.java
: build.gradle available for pluginidea .
: open current directory as idea projectI think we should have a good practice to code JBang script with IDEA, and developers can enjoy features supplied by the plugin.
Sync DEPS as IDEA module's libraries when using idea .
to open JBang project without build.gradle
The new logic as following:
I'm concerned whatever this sync does it gets out of sync (no pun intended :) with how jbang edit works; especially upcoming jbang edit . (see https://github.com/jbangdev/jbang/pull/1042).
p.s. could we move to use pull-request before pushing to main - would be great to learn a bit more on how idea plugins evolves and pull-requests lets one see that vs raw push to main - even if pushed more or less directly.
Gradle project models for dependencies sync :
settings.gradle
include 'app'
include 'jbang1'
sourceSets {
hello {
java {
srcDirs = ["src/hello/java"]
}
}
I really do not think the same action should be used to sync from build.gralde to java file and the java file to idea library. It's not symmetrical actions.
I agree, too complicated for developers. What's your suggestion? just to keep DEPS to idea module in IDE?
If developers want to generate build.gradle, and it's easy with following command.
jbang edit --open=[editor] helloworld.java
I think build.gradle to DEPS not necessary, and I can remove these code.
the feature is interesting (similar could be done for maven) but should be in separate actions. so if interested in tuning that keep it in a separate action "Sync JBang with Gradle" or similar.
Also perfectly fine dropping it for now as we have no tests and there are so many edge cases I fear its going to be a nightmare to maintain.
In edit mode, some developers add dependencies in build.gradle for code completion etc. Finally they should copy dependencies to JBang script with
//DEPS
directive. Introduce a shortcut to sync dependencies from Gradle to JBang script with//DEPS
filled.Reverse flow should be considered too. Introduce intention action for
//DEPS
and add dependency to build.gradle. With Github Copilot, and it's easy to add dependency in script.