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

Compiled plugins not used correctly #145

Closed
Turbo87 opened this issue Nov 3, 2016 · 11 comments
Closed

Compiled plugins not used correctly #145

Turbo87 opened this issue Nov 3, 2016 · 11 comments
Assignees

Comments

@Turbo87
Copy link
Contributor

Turbo87 commented Nov 3, 2016

I'm currently using 2749c1c of this Gradle plugin, and when I run the runIdea task sometimes the recompiled plugin doesn't seem to be used by the started IntelliJ instance. For example when I use println() in my code and run it, it prints the stuff properly to the console, but then when I remove the println() calls and run runIdea again sometimes the console output is visible again. Unfortunately I haven't been able to reliably reproduce this, but removing the sandbox and running runIdea again seems to at least solve the issue.

@Turbo87
Copy link
Contributor Author

Turbo87 commented Nov 3, 2016

FWIW when I was using v0.1.9 I didn't notice any problems like that, so the issues was likely introduced somewhere in between.

@Turbo87
Copy link
Contributor Author

Turbo87 commented Nov 6, 2016

I think I've figured out what's wrong here.

I just had the same issue again and had a look inside the sandbox folder. In the plugins/Ember.js/lib folder I found multiple JAR files of my plugin:

  • intellij-emberjs-2016.2.1-15.jar
  • intellij-emberjs-2016.2.1-18.jar
  • intellij-emberjs-2016.2.1-19.jar
  • intellij-emberjs-2016.2.1-20.jar

I'm using https://github.com/Zoltu/Gradle.Plugin.Versioning to set the plugin version automatically based on the Git tags in my repository, which means that each time I commit something the version string changes and a new JAR file is created.

It seems that as long as the JAR file name stays the same the problem doesn't exist, but as soon as I commit and a new file is generated, IntelliJ will use the old JAR file instead of the new code.

I can work around this issue by deleting the old JAR file from the folder mentioned above, but maybe the Gradle plugin should instead remove and recreate the lib folder of the plugin to make sure there are no such JAR files lingering around.

@zolotov
Copy link
Member

zolotov commented Nov 6, 2016

IntelliJ will use the old JAR file instead of the new code.

IntelliJ doesn't make choice between jars. Gradle plugin also doesn't make it – the plugin uses the output file of builtin jar task: https://github.com/JetBrains/gradle-intellij-plugin/blob/master/src/main/groovy/org/jetbrains/intellij/IntelliJPlugin.groovy#L175

I don't see a thing to fix in gradle-intellij-plugin. I'd say it's either Gradle's bug or versioning-plugin messes up the result of built-in gradle's tasks.

@Turbo87
Copy link
Contributor Author

Turbo87 commented Nov 6, 2016

I'd say it's either Gradle's bug or versioning-plugin messes up the result of built-in gradle's tasks.

as you can see in https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html#org.gradle.api.tasks.bundling.Jar:archiveName adding the plugin version to the JAR filename is the default behavior of Gradle

@zolotov
Copy link
Member

zolotov commented Nov 6, 2016

I know and gradle-plugin doesn't care how the file is named.

So the answer is the same: I don't see any thing to fix in gradle intellij plugin. If you see one – explanation or contribution are welcome. Until then: won't fix.

@zolotov zolotov added the wontfix label Nov 6, 2016
@zolotov zolotov closed this as completed Nov 6, 2016
@Turbo87
Copy link
Contributor Author

Turbo87 commented Nov 6, 2016

I don't quite understand how you don't see this as a bug... 🤔

IntelliJ doesn't make choice between jars.

How does IntelliJ figure out what JARs to load? Does it just load all JAR files in the lib folders? I assume in that case it will skip plugin JARs that are already loaded?

As I mentioned above: I think the right solution is removing old JAR files produced by the plugin, but since we can't know what the old JAR files are called we will likely just have to remove the lib folder before copying the new JAR files over.

@zolotov
Copy link
Member

zolotov commented Nov 6, 2016

I missed the part that all these jars are located in the sandbox. Will take a look

@zolotov zolotov reopened this Nov 6, 2016
@zolotov zolotov self-assigned this Nov 6, 2016
@zolotov zolotov removed the wontfix label Nov 6, 2016
@zolotov
Copy link
Member

zolotov commented Nov 6, 2016

depends on #17

@Turbo87
Copy link
Contributor Author

Turbo87 commented Nov 6, 2016

I missed the part that all these jars are located in the sandbox. Will take a look

sorry, should've made that clearer. thanks for looking into this!

@Turbo87
Copy link
Contributor Author

Turbo87 commented Nov 9, 2016

in case others are hitting the same issue, here is my current workaround:

task cleanSandboxPlugins(type: Delete) {
    delete '.sandbox/plugins'
}

prepareSandbox.dependsOn cleanSandboxPlugins

This assumes that you've set sandboxDirectory to project.rootDir.canonicalPath + "/.sandbox".

@Turbo87
Copy link
Contributor Author

Turbo87 commented Dec 20, 2016

Awesome, thanks!

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