Req: Working with IntelliJ and KoLmafia

MCroft

Developer
Staff member
I had a very easy time importing my svn directory into an IntelliJ (Community Edition 2020.2.2) project on MacOS Big Sur with several different JDKs, but it needed some tweaks to work properly, currently around the Run/Debug configurations.

The last threads on "How do you have your IDE set up?" are 4 years old, and I know that there are a wide variety of tool use experiences, but IJ seems like a pretty easy one for someone to start with.

I'm hoping someone else has more experience with IJ and ANT/SVN based projects and can comment on the following questions. It also seems like a good topic for the Wiki, once I have a good understanding.

My method was pretty simple: I used File>New Project>From Existing Sources, but you can also use File>New Project>From Source Control. It recognized build.xml and the source tree. I didn't have to do any config to get it to work. Obviously if I do a Wiki writeup of this, I'll want to try it fresh to make sure I'm not missing anything.

1: I have my working directory set (on my Mac) to /Users/mcroft/Library/Application Support/KoLMafia, which is working. I could create another working directory if I wanted one, but I don't see a need. I had to set it in the build config.

2: I have a pretty broad ant-style log pattern for session and debug logs. It works, but I have to keep my log dirs tidy or it will open up a 5 year history of sessions.

3: are there configs for testing, coverage, debug, release, etc. that I should consider? Are there ant commands that you make into run/debug configs?

4: Any gotchas?



I'm not just looking to get it working, but I'd like it to work well and help others...
 

fronobulax

Developer
Staff member
Well the good news is that I am using the Community Edition of IntelliJ as well. The bad news is I know my setup is wonky and I just work around that. In particular I don't build from within IntelliJ (but rather run a batch file externally to do so) and when I debug, I build the jar file externally and then edit the debug configuration to point to the jar file just built. This is a hangover from the days when I used IntelliJ for work which meant that maven was the build system and I had to have multiple JDKs/JREs installed to deal with both 32 and 64 bit environments. I suppose, now that my environment only has to deal with KoLmafia I should revisit things but this is a case of it ain't broke bad enough to fix :)

On Windows, the root for my source is merely D:\KoLmafia. I have a symbolic link, dist, which lets me isolate the "running" directories so that they are sync'd to other computers but not the whole source tree.

I almost always use "ant daily" to build and setting the debugger to look at that jar gives me all the debugging access I expect. I have not done profiling in several years and so don't recall if it was even on this configuration. I sometimes open a command line and do "ant test" but I do not use IntelliJ to assist in generating tests, run tests or get test coverage metrics.

I also don't use IntelliJ for commits. "ant daily" gets updates and somehow IntelliJ does know how to get annotation and do diffs.

Not a lot of help...
 

MCroft

Developer
Staff member
no worries, it's good to know that I'm not completely alone in IJ-landia...

Running from the IDE with the run/debug config is working nicely for me with one notable exception: I can either get the version number set (ant daily) or I can get the app to run with the version number but not the right Local Directory.

I think I can fix it with a few changes to build.xml, which I'll try out and then propose as a Feature.

Specifically, I'm going to make the KoLConstants replace tasks into regexreplace tasks so that they aren't hardcoded on REVISION = null; It looks like this was at least partially done elsewhere, but it would help me if it was more robust everywhere. And I'm going to add a write version task that I can call before running my build. Goal is for it to be 100% transparent to anyone not doing what I'm doing. :)
 

Veracity

Developer
Staff member
On my last job, I used IntelliJ, so I installed it on my home computer. I spent a small amount of time trying to set up KoLmafia in it. When I ran KoLmafia, it didn't know the version number. Since I have been debugging KoLmafia without an IDE for many years, I decided it wan't important enough for me to spend time figuring it out.

If you are figuring it out, I will wait for your fixes and try it out. :)
 

fronobulax

Developer
Staff member
Yeah. I just build outside of IntelliJ and edit the debug configuration to point to whatever was just built before running the debugger.

When I was using IntelliJ at work I almost never used the debugger. We had a desktop application with a robust plugin interface. The user would start up the app and it would find and connect jar files associated with plugins and things just worked. Most of my contributions were in plugins and it was a lot easier to debug by observation and print than to get a breakpoint within the plugin. It could be done but it was a ten or so step process that seemed to change with every new release of IntelliJ. As I have often demonstrated here, I am lazy and not always in the good sense.
 
Top