Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 26

Thread: Request: refactor build.xml to support IntelliJ IDEA (please review)

  1. #1
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default Request: refactor build.xml to support IntelliJ IDEA (please review)

    IntelliJ IDEA is mostly compatible with the build system for KoLMafia out of this box with one big exception.
    1. If you use the default application-type run action, there's no revision number in the version string
    2. If you use ANT target daily, it can't set the working directory properly
    3. If you use a JAR application Run task, it can't handle changing jar file names.


    The first is caused by the code that looks at the compiled KoLConstants.class file for the Constants "RELEASED" and "REVISION". If RELEASED is false, then the version is appended. Since the default value in the code is "true", it isn't there unless we make the configuration change it.

    So, the patch refactors the build target "compile", adding antcalls to the new targets "set.version" and "set.released.false". Everywhere we made those replaces, I switched it to antcall, to make it more consistent. Additionally, I added those two antcall targets to my IntelliJ build. And now it works like I want...

    I only tested the things I could test, and since it's the build system, hopefully it can be well tested, but it looks like it should be correct: it should be transparent to anyone doing anything except my IDE-related refactoring.
    Screen Shot 2020-10-09 at 7.24.05 PM.png
    build.refactor.patch
    Last edited by MCroft; 10-10-2020 at 02:50 AM.

  2. #2
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,868

    Default

    The few things I tried worked for me. My only concern is whether something breaks with Jenkins which is not something I can test. We can wait a bit until I can monitor Jenkins after a checking so I can revert if something did break.

  3. #3
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default

    Sure, I definitely don't want to be the guy who broke the build.

    Anyone who needs it can apply the patch and it should be transparent to everyone else.

  4. #4
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,671

    Default

    I'm missing something.

    I imported my SVN project into a new IntelliJ project
    I set my SDK to Java 14
    I have your changes to build.xml - hence the required ant tasks.
    I set build.xml to be the "ant build file" for the project
    I set up the Run/Debug task as shown on your image
    Warning: Class 'net.sourceforge.kolmafia.KoLmafia' not found in module 'kolmafia'

    When I Build from the menu, it does this:

    Clearing build system data...
    Executing pre-compile tasks...
    Loading Ant Configuration...
    Running Ant Tasks...
    Cleaning output directories...
    Running 'before' tasks
    Checking sources
    Running 'after' tasks
    Finished, saving caches...
    Executing post-compile tasks...
    Loading Ant Configuration...
    Running Ant Tasks...

    No class files anywhere.

    I removed build.xml as the "build file" to use.
    I told IntelliJ to use project output files for classes
    I invalidated caches and restarted
    I told it to rebuild the project. No output files anywhere.
    Try to Run. It can't find the class to run.

  5. #5
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default

    This doesn't seem to have gotten as far as you got before, when you got it to run without the version number.

    let me try it with a clean project.

    I created a new directory and did svn co from it.

    I imported project from existing sources. I accepted the defaults on the import.

    I added build.xml to the ant tab.

    I set up my run configuration as shown.
    + to add configuration, select "Application"
    main class: net.sourceforge.kolmafia.KoLmafia
    Working directory:/Users/mcroft/Library/Application Support/KoLmafia
    (or wherever, this is important after launch...)
    Use classpath of module: kolmafia
    JRE: Default (or whatever)
    Before Launch:
    Run Ant target 'set.released.false'
    Run Ant target 'set.version'
    Build (not Build Project, just vanilla Build)
    Edit: Run Ant target 'unset.properties' Don't skip this step. It needs to undo the props to follow the ant build process correctly

    Apply the config.

    It does a lot less when I run it. Build window says:
    Executing pre-compile tasks...
    Loading Ant Configuration...
    Running Ant Tasks...
    Executing post-compile tasks...
    Loading Ant Configuration...
    Running Ant Tasks...

    Run window says (once I expand that command to see the ugly command line with classpath):
    /Library/Java/JavaVirtualMachines/adoptopenjdk-13-openj9.jdk/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=57919:/Applications/IntelliJ IDEA CE.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/mcroft/projects/kolmafia/out/production/kolmafia:/Users/mcroft/projects/kolmafia/lib/jar/jna-4.1.0.jar:/Users/mcroft/projects/kolmafia/lib/jar/jdom-2.0.6.jar:/Users/mcroft/projects/kolmafia/lib/jar/sqljet-1.1.12.jar:/Users/mcroft/projects/kolmafia/lib/jar/lz4-java-1.4.1.jar:/Users/mcroft/projects/kolmafia/lib/jar/antlr-runtime-3.4.jar:/Users/mcroft/projects/kolmafia/lib/jar/svnkit-cli-1.10.1.jar:/Users/mcroft/projects/kolmafia/lib/jar/jna-platform-4.1.0.jar:/Users/mcroft/projects/kolmafia/lib/jar/sequence-library-1.0.4.jar:/Users/mcroft/projects/kolmafia/lib/jar/svnkit-javahl16-1.10.1.jar:/Users/mcroft/projects/kolmafia/lib/jar/jsch.agentproxy.core-0.0.7.jar:/Users/mcroft/projects/kolmafia/lib/jar/trilead-ssh2-1.0.0-build222.jar:/Users/mcroft/projects/kolmafia/lib/jar/jsch.agentproxy.pageant-0.0.7.jar:/Users/mcroft/projects/kolmafia/lib/jar/jsch.agentproxy.sshagent-0.0.7.jar:/Users/mcroft/projects/kolmafia/lib/jar/jsch.agentproxy.usocket-nc-0.0.7.jar:/Users/mcroft/projects/kolmafia/lib/jar/jsch.agentproxy.usocket-jna-0.0.7.jar:/Users/mcroft/projects/kolmafia/lib/jar/jsch.agentproxy.connector-factory-0.0.7.jar:/Users/mcroft/projects/kolmafia/lib/jar/jsch.agentproxy.svnkit-trilead-ssh2-0.0.7.jar:/Users/mcroft/projects/kolmafia/lib/testjar/junit-4.12.jar net.sourceforge.kolmafia.KoLmafia

    KoLmafia v20.7 r20452
    Released on July 30, 2020

    Currently Running on Mac OS X
    Local Directory is /Users/mcroft/Library/Application Support/KoLmafia
    Using Java 13.0.2
    Last edited by MCroft; 10-23-2020 at 03:23 AM.

  6. #6
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default

    So my two guesses are
    1: needs to be the Application Template
    2: needs to use the Build command in the Before Launch section
    3: needs to use classpath of module

  7. #7
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default

    This is the only other place I can think there might be a difference.

    If it matters, I'm using IntelliJ IDEA 2020.2.3 (Community Edition)
    Build #IC-202.7660.26, built on October 6, 2020
    Project Structures.png

  8. #8
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,671

    Default

    OK. I am having a lot more success with a brand new svn checkout.
    One thing I notice is that we have in our source tree a ".classpath" file - used by Eclipse - with obsolete and incomplete info, which is imported by IntelliJ to create an obsolete and incomplete classpath for me. That caused build errors for me.

    I fixed .classpath, removed .idea and kolmafia.iml, and re-created the project, build configuration, etc. - and it works like a charm.
    I tested from my command line and ran ant to build the .jar and executed the .jar from the command line - and it worked fine.

    I'll submit an updated .classpath and build.xml

    And it is done - in revision 20453.

    Thanks for all your work!

  9. #9
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,671

    Default

    I have If it matters, I'm using IntelliJ IDEA 2020.2.2 (Community Edition), by the way, which might explain why I had a .classpath issue and you did not.

  10. #10
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default

    I don't know if I started with 2020.2.2 or .3. The test one I did today I definitely stated with .3, but it's recent and I've worked on this change for a few days.

    I do know that at some point I added classpath="" to my build.properties because target compile, test-compile, ant test show errors if I don't. Is that part of the eclipse stuff as well?

    I don't think just having that there causes the issue, but I think in my soon-to-be-less-than-hypothetical Wiki IDE guide, I'll recommend starting with a fresh checkout, which not only keeps a new user from screwing up any current manual environment they have, but also makes it a lot easier for helpers to help figure out what went wrong if something goes wrong.

    The last time I submitted significant build.xml changes started with a dmg target issue in October of 2010, around revision 8728. Some of this is my own fault.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •