Hi Scott, Thanks for the interest in Jackpot.
The Maven plugin basically only calls a standalone command line tool, which is also uploaded on Maven central (org.apache.netbeans.modules.jackpot30:tool:13.0), although that's a bit harder to use without the launchers (launchers are part of the release on Apache). Overall, the tool re-uses what's in NetBeans as much as possible, and packs the relevant classes into a single jar file. The main place where the hints (declarative or hardcoded) are ran is around this place: https://github.com/apache/netbeans-jackpot30/blob/13e22c19c583f2ca687f951c64aab9f3f271c0fc/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java#L563 Generally calls to BatchSearch, which is an internal API. It handles various searches through multiple files, and then calls: https://github.com/apache/netbeans/blob/master/java/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/hints/HintsInvoker.java which is the class that runs some list of hints over a single file. It should be possible to open the "cmdline" directory as a module suite in NetBeans, and the "cmdline/tool" directory as a project under it. For building the tool, based on the NPE, it seems nb-javac was not available, possibly not prepended to classpath while the tests were run. It is here in the NB 13 distribution: java/modules/ext/nb-javac-jdk-17-api.jar java/modules/ext/nb-javac-jdk-17.jar And the command line that prepends it on the bootclasspath (for JDK 8), or excludes standard javac (for JDK 11+) is here: https://github.com/apache/netbeans-jackpot30/blob/13e22c19c583f2ca687f951c64aab9f3f271c0fc/cmdline/tool/build.xml#L115 So, probably some of that didn't work well. I tried on my Linux, and it built, I, unfortunately, don't have a Mac to try right now. I'll keep thinking of it. Thanks, Jan On Fri, Jan 27, 2023 at 5:48 AM Scott Palmer <swpal...@gmail.com> wrote: > I haven't been able to get Jackpot to build... (If there is a better place > to ask about this, let me know) > > I followed the instructions in cmdline/README.md > > Using Ant v 1.10.12 > Maven v 3.8.4 > With JAVA_HOME set to JDK 8 > > I ran: > > ant -DNETBEANS_PLATFORM=/Users/scott/dev/netbeans-13 > -DJDK11=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home > -DJDK17=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home > build-and-test > > It chugged away for a bit but then failed a bunch of tests: > > [junit] Testcase: > > testConfigurationFile(org.netbeans.modules.jackpot30.cmdline.CreateToolTest): > Caused an ERROR > [junit] junit.framework.AssertionFailedError: expected:<0> but was:<1> > [junit] java.io.IOException: junit.framework.AssertionFailedError: > expected:<0> but was:<1> > [junit] at > > org.netbeans.modules.jackpot30.cmdline.CreateToolTest.reallyRunCompiler(CreateToolTest.java:77) > [junit] at > > org.netbeans.modules.jackpot30.cmdline.MainTest.doRunCompiler(MainTest.java:1128) > [junit] at > > org.netbeans.modules.jackpot30.cmdline.MainTest.doRunCompiler(MainTest.java:1072) > [junit] at > > org.netbeans.modules.jackpot30.cmdline.MainTest.doRunCompiler(MainTest.java:1068) > [junit] at > > org.netbeans.modules.jackpot30.cmdline.MainTest.testConfigurationFile(MainTest.java:191) > [junit] at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:77) > [junit] at > org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:476) > [junit] at > org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:402) > [junit] at java.lang.Thread.run(Thread.java:750) > [junit] Caused by: junit.framework.AssertionFailedError: expected:<0> > but was:<1> > [junit] at > > org.netbeans.modules.jackpot30.cmdline.CreateToolTest.reallyRunCompiler(CreateToolTest.java:72) > [junit] > [junit] > [junit] Testcase: > > testWarningsAreErrors(org.netbeans.modules.jackpot30.cmdline.CreateToolTest): > FAILED > [junit] expected:<[${workdir}/src/test/Test.java:4: warning: > [Usage_of_Collection_Map_size_equals_0] c.size() == 0 can be replaced with > c.isEmpty() > [junit] boolean b1 = c.size() == 0; > [junit] ^ > [junit] ${workdir}/src/test/Test.java:5: warning: > [Usage_of_Collection_Map_size_equals_0] c.size() == 0 can be replaced with > c.isEmpty() > [junit] boolean b2 = c.size() == 0; > [junit] ^ > [junit] ]> but was:<[]> > > Basically a few like above, and then a lot more that looked like this: > > [junit] Testcase: > testParameterFile(org.netbeans.modules.jackpot30.cmdline.MainTest): Caused > an ERROR > [junit] java.lang.NullPointerException > [junit] java.lang.IllegalStateException: java.lang.NullPointerException > [junit] at > org.netbeans.modules.jackpot30.cmdline.Main.compile(Main.java:357) > [junit] at > > org.netbeans.modules.jackpot30.cmdline.MainTest.reallyRunCompiler(MainTest.java:1155) > [junit] at > > org.netbeans.modules.jackpot30.cmdline.MainTest.doRunCompiler(MainTest.java:1128) > [junit] at > > org.netbeans.modules.jackpot30.cmdline.MainTest.doRunCompiler(MainTest.java:1072) > [junit] at > > org.netbeans.modules.jackpot30.cmdline.MainTest.doRunCompiler(MainTest.java:1068) > [junit] at > > org.netbeans.modules.jackpot30.cmdline.MainTest.testParameterFile(MainTest.java:879) > [junit] at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:77) > [junit] at > org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:476) > [junit] at > org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:402) > [junit] at java.lang.Thread.run(Thread.java:750) > [junit] Caused by: java.lang.NullPointerException > [junit] at > > org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.findOccurrencesLocal(BatchSearch.java:92) > [junit] at > > org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.findOccurrences(BatchSearch.java:85) > [junit] at > org.netbeans.modules.jackpot30.cmdline.Main.handleGroup(Main.java:564) > [junit] at > org.netbeans.modules.jackpot30.cmdline.Main.compile(Main.java:338) > > > Any hints are appreciated. > > Regards, > > Scott > > > On Thu, Jan 26, 2023 at 1:49 PM Ernie Rael <err...@raelity.com> wrote: > > > On 23/01/26 10:25 AM, Scott Palmer wrote: > > > Well, yeah of course.. but is there a documented public API? > > > The maven plugin doesn't actually do refactoring, right? It just > > > identifies hints? > > > > At: https://netbeans.apache.org/jackpot/ > > > > > To apply the changes produced by the declarative hints, run > > > jackpot30:apply: > > > $ mvn -q jackpot30:apply && git diff > > > > Haven't tried it, but sure looks like it does the refactoring. > > > > -ernie > > > > > I was just wondering if there are notes somewhere that go a bit deeper > > than > > > showing how to use it from the command line or NetBeans. > > > > > > I did find a README in the cmdline folder. So at least that's a start > > for > > > getting something to build. > > > > > > Thanks, > > > > > > Scott > > > > > > On Thu, Jan 26, 2023 at 11:22 AM Michael Bien <mbie...@gmail.com> > wrote: > > > > > >> you check how the maven plugin is implemented and adopt it for gradle? > > >> > > >> -mbien > > >> > > >> On 26.01.23 17:13, Scott Palmer wrote: > > >> > > >> I don't use Maven if I can help it. > > >> > > >> But you misunderstand, I want to call Jackpot from my code to get it > to > > >> perform some refactoring from control of my program. Getting a list of > > >> possible hints may happen later. > > >> Or perhaps a more general use... What would I do if I wanted to write > a > > >> Gradle plugin to do the same as the Maven plugin? Assuming I know the > > >> Gradle side, how do I call the Jackpot methods? > > >> > > >> Regards, > > >> > > >> Scott > > >> > > >> > > >> On Thu, Jan 26, 2023 at 10:50 AM Michael Bien <mbie...@gmail.com> > > wrote: > > >> > > >>> On 26.01.23 16:01, Scott Palmer wrote: > > >>>> I wanted to experiment with Jackpot for a project I'm working on. > How > > >>>> dependent on the NetBeans Platform is the Jackpot code at > > >>>> https://github.com/apache/netbeans-jackpot30 ? > > >>>> Is there such a thing as a jackpot library jar that does not depend > on > > >>>> NetBeans classes? > > >>>> If I wanted to make a standalone tool to do certain transformations > > on a > > >>>> Java code base where would I start? > > >>>> > > >>>> Thanks for any help you can provide, > > >>>> > > >>>> Scott > > >>>> > > >>> you should be able to use it from maven in your build: > > >>> > > >>> <plugin> > > >>> <groupId>org.apache.netbeans.modules.jackpot30</groupId> > > >>> <artifactId>jackpot30-maven-plugin</artifactId> > > >>> <version>13.0</version> > > >>> <configuration> > > >>> <configurationFile>jackpot-settings.xml</configurationFile> > > >>> <failOnWarnings>true</failOnWarnings> > > >>> </configuration> > > >>> <executions> > > >>> <execution> > > >>> <id>jackpot</id> > > >>> <phase>compile</phase> > > >>> <goals> > > >>> <goal>analyze</goal> > > >>> </goals> > > >>> </execution> > > >>> </executions> > > >>> </plugin> > > >>> > > >>> > > >>> I use it mostly from within NetBeans itself for refactoring or > > >>> inspection tasks with the help of the ".hint" files. > > >>> > > >>> I sometimes upload the inspections which I think are reusable or more > > >>> generic here: > > >>> > > >>> https://github.com/mbien/jackpot-inspections > > >>> > > >>> readme explains how to use hint files. > > >>> > > >>> -mbien > > >>> > > >>> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org > > For additional commands, e-mail: dev-h...@netbeans.apache.org > > > > For further information about the NetBeans mailing lists, visit: > > https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists > > > > > > > > >