Apache NetBeans (Incubating)

Monday January 28, 2019

Enterprise Cluster Integrated into Apache NetBeans

Hurray, the 'enterprise' cluster, constituting all the modules in Apache NetBeans GitHub that provide features for Java/Jakarta EE development, provided in the 2nd Oracle donation of NetBeans to Apache, has been integrated into the daily builds.

Now, for the first time, out of the box, you'll have the support that was part of NetBeans IDE 8.2 for Java EE development directly available in Apache NetBeans, that is, without you needing to install any plugins.

However, aside from the point that this means we do not yet have Java EE 8 support, since 8.2 did not (could not, because of being released some time prior to Java EE 8) have support for Java EE 8, another question now presents itself—whether we really want to have two categories in the New Project dialog, one named "Java EE" and the other named "Java Web", as shown below, with the former containing project types relating to EJBs and EARs, which are not (should not) be very current anymore, as shown below in the screenshots.

My suggestion would be to either relabel the above to "Modern Java EE" and "Vintage Java EE". (I like the word "Vintage", which I've learned about from JUnit, i.e., that's how they refer to JUnit 4.) Once there is Java EE 8 support, we could use the name "Jakarta" instead of "Modern Java EE". Or, maybe the EJB and EAR support should simply be removed?

Sunday January 27, 2019

Junit 5, Apache Ant, and Apache NetBeans

Junit 5 is, architecturally, so different to previous versions, that it should really be called Jupiter, instead. However, this is not a problem when you're using Maven, since Maven resolves all transitive dependencies for you, and is supported in that way from Apache NetBeans 10 onwards. Not so with Apache Ant, of course, where you need to set each and every JAR you need on a classpath of one form or another.

That is not a pretty picture in the end, when compared to JUnit 4, where you had just that JAR, plus Hamcrest. With JUnit 5, you need, in addition to junit-jupiter-api, junit-jupiter-params, and junit-jupiter-engine, to also declare the transitive dependency apiguardian-api, while in the case of Apache Ant, you need to deal with the JUnitLauncher, if you want to make use of the new junitlauncher Ant task, in addition to four other JARs, which need to be on Ant's classpath, as explained here.

An alternative approach is to use org.junit.platform.console.ConsoleLauncher, as shown here, which looks like this in my build.xml, i.e., it is named test, so that it will run automatically at the end of the test run when the Test Project action is invoked:

<target name="test" depends="compile-test,-pre-test-run">
    <java dir="${work.dir}" 
          classpath="${run.test.classpath}"  
          classname="org.junit.platform.console.ConsoleLauncher">
        <arg value="--scan-classpath"/>
        <arg line="--reports-dir build/test/results"/>
    </java>
    <junitreport todir="build/test/results">
        <fileset dir="build/test/results">
            <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames" todir="build/test/results/html"/>
    </junitreport>
</target>

The above means that the JUnit tasks set by default in the build-impl.xml file will simply fail silently, since I don't have JUnit 4 on my classpath. At the end of the process, the above will be run, org.junit.platform.console.ConsoleLauncher will be found on my classpath, and then the JUnit 5 tests will be run.

What is the advantage of the above over using JUnitLauncher? Well, JUnitLauncher has requirements relating to Ant's path, which has advantages too, of course, i.e., simply set everything up once (which can also be done inside Apache NetBeans, in the Ant tab in the Options window). But, for right now, I'd prefer to work with just one path, i.e., the application's path.

Another downside is that, so far, the above solution doesn't integrate with the Test Results window, though it does produce some nice reports via the junitreport task above, in the build folder.

The key problem seems to me to be that the JUnit Ant task no longer exists in JUnit 5, which was for Ant-based projects the basis of the integration with the Test Results window in Apache NetBeans. If the JUnit task could continue to be used, in whatever way, that would solve a lot of the problems, though the question of the many JARs needed on the classpath would remain. Maybe library providers should reach out to tools providers when putting these kinds of new solutions together, since the only reason that JUnit 5 now works with Maven in Apache NetBeans is that Surefire is used, i.e., in the case of Maven the completely new approach JUnit has taken can simply be avoided there. Here is some relevant discussion in Apache NetBeans GitHub, and the Launcher API looks interesting.

Probably the best solution for Ant users in Apache NetBeans would be to be able to continue to use JUnit 4, rather than JUnit 5, since the latter is a total nightmare to set up in the context of Ant, as described above. In the world of JUnit, "vintage" is the cool name they have for "legacy", and if you're using Ant at all, you're probably best described as "vintage" and hence only having support for JUnit 4 is not a big deal for you. However, not sure at all how that would work, we'd need to investigate how/if when JUnit tests are added to Maven projects, JUnit 5 tests and dependencies would be set, while when adding JUnit tests to Ant projects JUnit 4 tests and dependencies would be set.

Thursday January 24, 2019

Master Your Scripting Skills with the New Tutorial!

Enhanced scripting tutorial has just become part of Apache NetBeans documentation. It contains various examples showing how to communicate from Java with JavaScript, Python and other languages. The following topics are covered:

While the primary use-case for this enhanced scripting API is to simplify usage of scripting languages in NetBeans based applications, the API itself is standalone and can be used outside of NetBeans in any project. We are working on making it available in the Maven central repository.

Read more in the online tutorial.

Calendar

Search

Hot Blogs (today's hits)

Tag Cloud

Categories

Feeds

Links

Navigation