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

Use WAKATIME_HOME env #96

Merged
merged 1 commit into from
Jan 24, 2018
Merged

Use WAKATIME_HOME env #96

merged 1 commit into from
Jan 24, 2018

Conversation

jcrben
Copy link
Contributor

@jcrben jcrben commented Jan 24, 2018

Hey, following up on https://github.com/wakatime/wakatime/issues/73#issuecomment-312964355 - seems that the jetbrains plugin is creating .wakatime/wakatime-master/ and ignoring WAKATIME_HOME

This is just a start, haven't tested it - not much of a Java person - probably still need to add code to read... I may get around to it eventually, or you can take it from here

@@ -47,6 +47,13 @@ public static boolean isPythonInstalled() {

public static String getResourcesLocation() {
if (Dependencies.resourcesLocation == null) {
if (System.getenv("WAKATIME_HOME")) {
File appDataFolder = new File(System.getenv("WAKATIME_HOME"));
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to define appDataFolder here, it's only used to find the window's data folder when WAKATIME_HOME isn't defined.

Copy link
Member

@alanhamlett alanhamlett Jan 24, 2018

Choose a reason for hiding this comment

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

I've removed it in a separate commit, and will release a new version soon after testing (probably within a few days). Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow, that was quick! Thanks again for the awesome project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alanhamlett thoughts on a new version?

Copy link
Member

Choose a reason for hiding this comment

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

It's already been merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But that merge hasn't been put into a new version right?
image

Copy link
Member

Choose a reason for hiding this comment

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

Oh, right! Just released a new version 9.0.2 with your change.

@alanhamlett alanhamlett merged commit f9b0a8c into wakatime:master Jan 24, 2018
@jcrben
Copy link
Contributor Author

jcrben commented Mar 26, 2018

fyi, haven't been able to get this to work running 9.03 - it creates the folder and prompts me for an API key. As usual, it can be tricky to get environment variables into GUI programs but usually my startup.plist file handles it. Also, I tried opening it up with idea in the terminal.

IntelliJ IDEA 2017.3.5 (Ultimate Edition)
Build #IU-173.4674.33, built on March 5, 2018
JRE: 1.8.0_152-release-1024-b15 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6

I'm not so experienced with building Java projects, but at some point perhaps I'll circle back around to build it and see what's happening.

<!--
HACKING:
use my reloadstartup function
launchctl unload /Users/bencreasy/dotfiles/cronjobs/my.startup.plist
launchctl load /Users/bencreasy/dotfiles/cronjobs/my.startup.plist
launchctl start /Users/bencreasy/dotfiles/cronjobs/my.startup.plist
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>my.startup</string>
  <key>ProgramArguments</key>
  <array>
    <string>sh</string>
    <string>-c</string>
    <string>
      launchctl setenv XDG_CONFIG_HOME "$HOME"/.config; 
      launchctl setenv XDG_CACHE_HOME "$HOME"/.cache;
      launchctl setenv XDG_DATA_HOME "$HOME"/.local;
      launchctl setenv ATOM_HOME "$HOME"/.config/atom/;
      launchctl setenv SUBVERSION_HOME "$HOME"/.config/subversion/;
      launchctl setenv ANKI_BASE "$HOME"/dotfiles/local/anki;
      launchctl setenv VBOX_USER_HOME "$HOME"/.config/virtualbox
      launchctl setenv WAKATIME_HOME "$HOME"/.config/wakatime
    </string>
  </array>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>

@jcrben
Copy link
Contributor Author

jcrben commented Apr 1, 2018

resolution

Seems like I got this working - there were two .iml files and it seems like that was causing a boilerplate plugin to load. Will try to circle back around with a fix.

debugging

Hey @alanhamlett - would like to debug this, but I'm not a good enough Java/Intellij developer to figure out how to automatically load the plugin? I left some comments at https://gitter.im/IntelliJ-Plugin-Developers/Lobby?at=5ac1126a7c3a01610d98b010

image

I get the impression from http://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_content.html that I need to bundle this all into a jar file for it to be automatically loaded?

Also tried moving the plugin.xml up to the top-level.

Going to try running the Community Edition next... tried it, same thing - Wakatime does not get installed into my AppMainV2. Log looks like this:

2018-04-01 11:32:02,133 [      0]   INFO -        #com.intellij.idea.Main - ------------------------------------------------------ IDE STARTED ------------------------------------------------------ 
2018-04-01 11:32:02,294 [    161]   INFO -        #com.intellij.idea.Main - IDE: IntelliJ IDEA (build #IC-181.4203.550, 26 Mar 2018 13:02) 
2018-04-01 11:32:02,295 [    162]   INFO -        #com.intellij.idea.Main - OS: Mac OS X (10.12.6, x86_64) 
2018-04-01 11:32:02,295 [    162]   INFO -        #com.intellij.idea.Main - JRE: 1.8.0_60-b27 (Oracle Corporation) 
2018-04-01 11:32:02,295 [    162]   INFO -        #com.intellij.idea.Main - JVM: 25.60-b23 (Java HotSpot(TM) 64-Bit Server VM) 
2018-04-01 11:32:02,303 [    170]   INFO -        #com.intellij.idea.Main - JVM Args: -Xmx512m -Xms256m -XX:MaxPermSize=250m -ea -Didea.config.path=/Users/bencreasy/Library/Caches/IdeaIC2018.1/plugins-sandbox/config -Didea.system.path=/Users/bencreasy/Library/Caches/IdeaIC2018.1/plugins-sandbox/system -Didea.plugins.path=/Users/bencreasy/Library/Caches/IdeaIC2018.1/plugins-sandbox/plugins -Didea.classpath.index.enabled=false -Didea.required.plugins.id=com.your.company.unique.plugin.id -Didea.smooth.progress=false -Dapple.laf.useScreenMenuBar=true -Dapple.awt.fileDialogForDirectories=true -Didea.platform.prefix=Idea -Didea.launcher.port=62582 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA CE.app/Contents/bin -Dfile.encoding=UTF-8 
2018-04-01 11:32:02,304 [    171]   INFO -        #com.intellij.idea.Main - ext: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext: [cldrdata.jar, dnsns.jar, jaccess.jar, jfxrt.jar, localedata.jar, meta-index, nashorn.jar, sunec.jar, sunjce_provider.jar, sunpkcs11.jar, zipfs.jar] 
2018-04-01 11:32:02,304 [    171]   INFO -        #com.intellij.idea.Main - ext: /System/Library/Java/Extensions: [MRJToolkit.jar] 
2018-04-01 11:32:02,304 [    171]   INFO -        #com.intellij.idea.Main - JNU charset: UTF-8 
2018-04-01 11:32:02,320 [    187]   INFO -        #com.intellij.idea.Main - JNA library (64-bit) loaded in 16 ms 
2018-04-01 11:32:02,331 [    198]   INFO -        #com.intellij.idea.Main - initializing environment 
2018-04-01 11:32:02,332 [    199]   INFO - .intellij.util.EnvironmentUtil - loading shell env: /usr/local/bin/bash -l -i -c '/Applications/IntelliJ IDEA CE.app/Contents/bin/printenv.py' '/private/var/folders/h2/g71hf5ls7sxdsj5qq1phv89w0000gq/T/intellij-shell-env.tmp' 
2018-04-01 11:32:02,432 [    299]   INFO -     #com.intellij.util.ui.JBUI - User scale factor: 1.0 
2018-04-01 11:32:02,432 [    299]   INFO -     #com.intellij.util.ui.JBUI - System scale factor: 2.0 (JRE-managed HiDPI) 
2018-04-01 11:32:03,889 [   1756]   INFO - .intellij.util.EnvironmentUtil - shell environment loaded (136 vars) 
2018-04-01 11:32:06,197 [   4064]   INFO - llij.ide.plugins.PluginManager - Cannot find optional descriptor duplicates-groovy.xml 
2018-04-01 11:32:11,093 [   8960]   INFO - .intellij.idea.IdeaApplication - CPU cores: 8; ForkJoinPool.commonPool: java.util.concurrent.ForkJoinPool@2b7bd12f[Running, parallelism = 7, size = 0, active = 0, running = 0, steals = 0, tasks = 0, submissions = 0]; factory: com.intellij.concurrency.IdeaForkJoinWorkerThreadFactory@44d377ab 
2018-04-01 11:32:11,378 [   9245]   INFO - llij.ide.plugins.PluginManager - Cannot find optional descriptor duplicates-groovy.xml 
2018-04-01 11:32:11,556 [   9423]   INFO - llij.ide.plugins.PluginManager - 35 plugins initialized in 247 ms 
2018-04-01 11:32:11,557 [   9424]   INFO - llij.ide.plugins.PluginManager - Loaded bundled plugins: Android Support (10.3.0), Ant Support (1.0), Bytecode Viewer (0.1), CVS Integration (11), Copyright (8.1), Coverage (181.4203.550), Eclipse Integration (3.0), EditorConfig (181.4203.550), Git Integration (8.1), GitHub (181.4203.550), Gradle (181.4203.550), Groovy (9.0), I18n for Java (181.4203.550), IDEA CORE (181.4203.550), IntelliLang (8.0), JUnit (1.0), Java Bytecode Decompiler (181.4203.550), Java Stream Debugger (181.4203.550), JavaFX (1.0), Kotlin (1.2.30-release-IJ2018.1-1), Maven Integration (181.4203.550), Mercurial Integration (10.0), Plugin DevKit (1.0), Properties Support (181.4203.550), Settings Repository (181.4203.550), Smali Support (1.0), Subversion Integration (1.1), Task Management (1.0), Terminal (0.1), TestNG-J (8.0), UI Designer (181.4203.550), XPathView + XSLT Support (4), XSLT-Debugger (1.4), YAML (181.4203.550) 
2018-04-01 11:32:11,557 [   9424]   INFO - llij.ide.plugins.PluginManager - Loaded custom plugins: Plugin display name here (1.0) 
2018-04-01 11:32:12,200 [  10067]   INFO - ellij.vfs.persistent.FSRecords - Marking VFS as corrupted: '/Users/bencreasy/Library/Caches/IdeaIC2018.1/plugins-sandbox/system/caches/names.dat' does not exist 
2018-04-01 11:32:12,202 [  10069]   INFO - ellij.util.io.PagedFileStorage - lower=100; upper=435; buffer=10; max=435 
2018-04-01 11:32:12,270 [  10137]   INFO - pl.local.NativeFileWatcherImpl - Starting file watcher: /Applications/IntelliJ IDEA CE.app/Contents/bin/fsnotifier 
2018-04-01 11:32:12,280 [  10147]   INFO - pl.local.NativeFileWatcherImpl - Native file watcher is operational. 
2018-04-01 11:32:12,667 [  10534]   WARN - nSystem.impl.ActionManagerImpl - keymap "Xcode" not found [Plugin: Git4Idea] 
2018-04-01 11:32:12,683 [  10550]   WARN - nSystem.impl.ActionManagerImpl - keymap "Xcode" not found [Plugin: hg4idea] 
2018-04-01 11:32:12,719 [  10586]   INFO - .history.utils.LocalHistoryLog - local history version mismatch (was: 0, expected: 6), rebuilding... 
2018-04-01 11:32:12,719 [  10586]   INFO - .history.utils.LocalHistoryLog - FS has been rebuild, rebuilding local history... 
2018-04-01 11:32:12,794 [  10661]   INFO - com.intellij.ide.ui.UISettings - Loaded: fontSize=12, fontScale=1.0; restored: fontSize=12, fontScale=1.0 
2018-04-01 11:32:12,843 [  10710]   INFO - .openapi.application.Preloader - Finished preloading com.intellij.ide.ui.OptionsTopHitProvider$Activity@1264e57 
2018-04-01 11:32:12,955 [  10822]   INFO - til.net.ssl.CertificateManager - Default SSL context initialized 
2018-04-01 11:32:12,968 [  10835]   INFO - rains.ide.BuiltInServerManager - built-in server started, port 63343 
2018-04-01 11:32:13,000 [  10867]   INFO - gs.impl.UpdateCheckerComponent - channel: release 
2018-04-01 11:32:13,110 [  10977]   INFO - tellij.ide.SystemHealthMonitor - issue detected: outdated.jre.version.message1 
2018-04-01 11:32:13,179 [  11046]   INFO - il.indexing.FileBasedIndexImpl - Index exts enumerated:162, number of extensions:44 
2018-04-01 11:32:13,184 [  11051]   INFO - il.indexing.FileBasedIndexImpl - Index scheduled:4 
2018-04-01 11:32:13,211 [  11078]   INFO - tellij.psi.stubs.StubIndexImpl - All stub exts enumerated:26, number of extensions:49 
2018-04-01 11:32:13,212 [  11079]   INFO - tellij.psi.stubs.StubIndexImpl - stub exts update scheduled:0 
2018-04-01 11:32:13,615 [  11482]   INFO - ij.psi.stubs.StubUpdatingIndex - Following new file types will be indexed:JAVA,Groovy,kotlin_builtins,Kotlin,Properties,KJSM,HTML,CLASS,XML 
2018-04-01 11:32:13,756 [  11623]   INFO - plication.impl.ApplicationImpl - 89 application components initialized in 2450ms 
2018-04-01 11:32:13,770 [  11637]   INFO - .intellij.idea.IdeaApplication - App initialization took 12320 ms 
2018-04-01 11:32:13,945 [  11812]   INFO - pl$FileIndexDataInitialization - Initialization done:761 
2018-04-01 11:32:14,058 [  11925]   INFO - exImpl$StubIndexInitialization - Initialization done:112 
2018-04-01 11:32:14,263 [  12130]   INFO - j.ide.ui.OptionsTopHitProvider - 294 ms spent to cache options in application 
2018-04-01 11:32:14,659 [  12526]   INFO - .openapi.application.Preloader - Finished preloading com.intellij.openapi.actionSystem.impl.ActionPreloader@2775bba4 
2018-04-01 11:32:15,489 [  13356]   INFO - .openapi.application.Preloader - Finished preloading com.intellij.ide.ui.search.SearchableOptionPreloader@61fae84a 
2018-04-01 11:32:15,608 [  13475]   INFO - .openapi.application.Preloader - Finished preloading com.intellij.codeInsight.completion.CompletionPreloader@ee351d1 
2018-04-01 11:32:15,612 [  13479]   INFO - .openapi.application.Preloader - Finished preloading com.intellij.ide.actions.GotoClassPresentationUpdater@25ea147b 
2018-04-01 11:32:18,948 [  16815]   INFO - ellij.project.impl.ProjectImpl - 20 project components initialized in 332 ms 
2018-04-01 11:32:56,149 [  54016]   INFO - ellij.project.impl.ProjectImpl - 154 project components initialized in 835 ms 
2018-04-01 11:32:56,149 [  54016]   INFO - le.impl.ModuleManagerComponent - 0 module(s) loaded in 0 ms 
2018-04-01 11:32:56,341 [  54208]   INFO - j.ide.script.IdeStartupScripts - 0 startup script(s) found 
2018-04-01 11:32:56,415 [  54282]   WARN - j.ui.mac.MacMainFrameDecorator - no url bundle present. 
To use platform protocol handler to open external links specify required protocols in the mac app layout section of the build file
Example: args.urlSchemes = ["your-protocol"] will handle following links: your-protocol://open?file=file&line=line 
2018-04-01 11:32:57,304 [  55171]   INFO - CompilerBackwardReferenceIndex - backward reference index version differ due to: class java.io.FileNotFoundException 
2018-04-01 11:32:57,484 [  55351]   INFO - ge.ExternalProjectsDataStorage - Loaded external projects data in 3 millis 
2018-04-01 11:32:57,494 [  55361]   INFO - .diagnostic.PerformanceWatcher - Post-startup activities under progress took 66ms; general responsiveness: ok; EDT responsiveness: ok 
2018-04-01 11:32:57,581 [  55448]   INFO - .diagnostic.PerformanceWatcher - Pushing properties took 1ms; general responsiveness: ok; EDT responsiveness: ok 
2018-04-01 11:32:57,817 [  55684]   INFO - tartup.impl.StartupManagerImpl - /Users/bencreasy/ideaWhatever/.idea case-sensitivity: expected=false actual=false 
2018-04-01 11:32:57,823 [  55690]   INFO - pl.projectlevelman.NewMappings - VCS Root: [] - [<Project>] 
2018-04-01 11:32:57,842 [  55709]   INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 260ms; general responsiveness: ok; EDT responsiveness: ok 
2018-04-01 11:32:57,842 [  55709]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 219 files to update 
2018-04-01 11:32:57,857 [  55724]   INFO - tor.impl.FileEditorManagerImpl - Project opening took 2560 ms 
2018-04-01 11:32:58,621 [  56488]   INFO - .diagnostic.PerformanceWatcher - Unindexed files update took 779ms; general responsiveness: ok; EDT responsiveness: ok 
2018-04-01 11:32:58,863 [  56730]   INFO - j.ide.ui.OptionsTopHitProvider - 98 ms spent to cache options in project 
2018-04-01 11:32:59,238 [  57105]   INFO - CompilerWorkspaceConfiguration - Available processors: 8 
2018-04-01 11:33:04,761 [  62628]   INFO - rojectCodeStyleSettingsManager - Initialized from default code style settings. 
2018-04-01 11:35:13,229 [ 191096]   INFO - j.compiler.server.BuildManager - Clearing project build data because the project does not exist or was not opened for more than 30 days: /Users/bencreasy/Library/Caches/IdeaIC2018.1/plugins-sandbox/system/compile-server/ideawhatever_83e4af78 

I also see:
image

but I can't seem to set it to the bundled version for some reason (the macOS .app package doesn't seem to contain a proper JDK) - ended up using a higher external version from zulu and still got a message:
image

@kusold
Copy link

kusold commented Oct 17, 2018

For any MacOS users that are having issues getting IntelliJ to use WAKATIME_HOME, you need to set the variable using launchctl. GUI programs don't read .profile!

❯ cat ~/Library/LaunchAgents/environment.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
        <dict>
                <key>Label</key>
                <string>my.startup</string>
                <key>ProgramArguments</key>
                <array>
                        <string>sh</string>
                        <string>-c</string>
                        <string>
                                launchctl setenv WAKATIME_HOME /Users/mike/.config/wakatime
                        </string>
                </array>
                <key>RunAtLoad</key>
                <true/>
        </dict>
</plist>

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.

None yet

3 participants