NetBeans (maven) project: checkstyle-beans vs maven-checkstyle-plugin - java

There are at least two ways of using the checkstyle in the NetBean maven project
(at the time of 2019-07-24):
using the NetBeans's plugin checkstyle-beans
v4.1.0, last Update: 2016-02-09, uses Checkstyle v6.15.
The last declared supported version is NetBeans v8.1
*although it works with v8.2
using the Maven's plugin maven-checkstyle-plugin
v3.1.0, last Update: 2019-05-12, uses Checkstyle v8.19
The last version of the github.com/checkstyle itself is v8.22
Questions:
Can I update them both to the last checkstyle?
Does they completely independent ?
the checkstyle-beans shows the marks beside the line numbers in the IDE
the maven-checkstyle-plugin can be used for the manual launch in the console, outside the IDE (mvn -e checkstyle:check).
Can it be configured and used inside the IDE ?

As a Netbeans user, you are stuck with Checkstyle-Beans as far as in-IDE support goes.
Maven and Checkstyle-Beans are completely independent of each other, but both depend on Checkstyle, of which they should use the same version.
This means you are also stuck with Checkstyle 6.15 (no upgrade unless Checkstyle-Beans gets a new version), which you must consequently use everywhere else also, or your Checkstyle configuration will not work (for example Checkstyle 6.15 config XMLs won't work with Checkstyle 8.22).
So, you have three options:
Use a different IDE, such as IntelliJ or Eclipse. Both have up-to-date Checkstyle support, so you can use the latest Checkstyle both in Maven and in the IDE.
Continue with Netbeans, and use Checkstyle 6.15. This is actually feasible imho. Checkstyle docs are versioned these days, so you can see the correct docs at https://checkstyle.sourceforge.io/version/6.15/. This will get you Checkstyle 6.15 support in Maven and in the IDE.
Continue with Netbeans, and use latest Checkstyle. Then you can only run it via Maven, but I suppose you can configure a button in NetBeans to make this easy.

Related

Not all Gradle projects are created equal, according to Netbeans

I'm checking whether we'd be able to migrate from Ant to Gradle, but got confused right at the very beginning of these checks - Apache Netbeans 12 LTS (+ Gradle plugin from official repo) refuses to properly open Gradle projects that were created by a another Netbeans instance, which is a major pain.
I tried to open (in Netbeans) one of the Java library project examples from Gradle docs, only to find out the IDE immediately spews out errors (missing imports for tests) that are unjustified and offers a very limited amount of IDE integration - forget running specific tests, even debugging is all grayed out. Gradle and Netbeans also see different classpaths.
If I create a Gradle project inside Netbeans, everything works fine - no errors, Projects Tree shows an additional tree node, called "Configurations", like in the image below, I'm able to debug and everything just works.
However, even if I just copy/paste this project's directory to a different location, everything breaks after the project is reopened (I also get this issue, same thing happens for example projects found in Gradle docs).
What is going on here? Netbeans seems to know more about a project it created, than about projects that were created outside it or were just relocated. How do I force it to treat all Gradle projects equally (so that they work as expected)?
I used Gradle 7.0.1 and let the New Projects wizard "Initialize the Gradle wrapper" for the project created inside Netbeans 12 LTS. The setting to prefer existing wrappers is enabled in settings if relevant.
Enabling an "experimental" option in Gradle options, called Enable 'lazy' Source Group Initialization does help with simple projects that were created by Netbeans, so they open as expected.
But this does not work for Gradle projects that contain subprojects, such as the example project from Gradle docs:
The issue tracker for this Netbeans plugin has been quite active recently, mentioning issues like this, so perhaps there is hope.
At least part of the problem is that the LTS release of Netbeans (at the time of this writing) doesn't support gradle 7. The latest release, Netbeans 12.4, is the first version that supports gradle 7.

Java category missing in Apache Netbeans

So I installed Apache Netbeans. Installed some of the plugins and instead of just seeing the Java folder in the categories when I want to create a new Project, I see this:
What is Gradle, Ant, and Maven? I am not familiar with Java and wanted to study the language, but I have no idea of what these are.
I keep seeing that I need to have certain plug ins installed and active.
Here they are.
Ant, Maven and Gradle are Java build tools. You don't really need to know the exact differences though.
Java with Ant
The "Java with Ant" option uses NetBeans' own internal project format (based on Ant). In older NetBeans versions this category was simply called "Java"
If you don't need to share your project with non-NetBeans users, use that option.
You will have to manage dependent libraries yourself (download, add them to the project) unless you are only using libraries and frameworks that are bundled with NetBeans. The turnaround times (the time it takes between you hit "Run" and the application actually starts) are the shortest with this option, as Maven and Gradle add substantial overhead to that.
Java with Maven
Maven is a standardized dependency and build management tool. A project defined with Maven can be used by everybody else as it automatically manages (and downloads) any dependency.
Use that option if you know you need to share your project with other people (e.g. hand it in your school or university).
Java with Gradle
Gradle is yet another build tool, which also manages dependencies for your and has more flexibility than Maven. However the build scripts are less standardized than in Maven. But that is also a good option if you know that you need to share your project with other people.
Unless you are using NetBeans 11.1 (which is currently in Beta) I would not use this option as Gradle support in older versions is not as good as Ant or Maven support.
You might want to go through the tutorials on the NetBeans homepage:
http://netbeans.apache.org/help/index.html

How do Maven and m2e-Eclipse-Plugin cooperate

I have some questions about the m2e-Eclipse-Plugin. Version of m2e is 1.6 and the version of Eclipse is 4.5 (Mars).
In my Eclipse-workspace I have a Maven-Project (Java web application) that is deployed on a local Tomcat server.
I really would like to know how m2e-Plugin and Maven work together. If I change a Java-file and save it, the corresponding Class-file in the mvn-target-directory is immediately updated.
Is this compilation done by the default Java-Builder in Eclipse or is it done by Maven ? (i.e. the mvn-compile-plugin does the compilation). If the latter case is true, how is the compile-goal executed ?
Can I configure which mvn-goals are executed if a Java-file is changed and saved? If the compilation is done by the Java Builder, how does the Builder know that it has to copy the compiled
file to the mvn-target-directory
?
I found two posts:
How do Java and Maven builders work together in eclipse?
How do I start Maven "compile" goal on save in Eclipse?
that deal with similar issues. But most of the proposed configuration settings didn't work in my Eclipse.
The compilation in your scenario is done by the Eclipse compiler and not by Maven nor the maven-compiler-plugin. M2E Maps all things to Eclipse internals to handle most of the things needed to work inside Eclipse.
During an initial import of a Maven project into Eclipse using M2E (creating .project/.classpath/.settings) the life cycle will be run till generate-resources and therefore some plugins are run and can create other stuff (things like ANTLR/JAXB generators etc.).
Eclipse handles the correct target folders by reading the pom.xml files and by M2E it is translated into configuration for Eclipse etc. The things you are referencing about configuration is simply not working cause those posts are too old...

Setting different compiler levels for different source folders in eclipse in same project

I have a project that is build using ant and now i am trying to convert into one that is build in eclipse.
The ant files describes different compiler versions for different course folders i.e few are compiled using jdk 5, few using 6 and still few using 4.
How can we configure the project in eclipse to use different compiler levels in eclipse for different folders in same project.
I noticed that they had this bug lined up in eclipse and they said to release it on 3.5 and i am using 4.3. So it think the feature should be there.
Such feature does not exist. You will need to create multiple Eclipse projects.
I would suggest that you think twice before making a change in that direction.
ANT might not be the best build tool, but switching to Eclipse is way worse as you tight yourself not only to an IDE, but also to a specific configuration of both your instance and your project, making it less portable and more fragile than before.
I would rather suggest that you split your project into different modules/projects and use maven (integration with Maven and Eclipse is ok for simple builds) to organize both you CLI and Eclipse build procedures.

Why does M2Eclipse complain about missing artifact when mvn command line doesn't?

I've just set up a brand new installation of Eclipse Helios and have configured M2Eclipse to use an external (v 2.2.1) installation of Maven.
The system compiles fine on the command line, but from within M2Eclipse several of my project modules have an error:
Missing artifact javax.jms:jms:jar:1.1:test
I can get past the error by excluding the jms artifact from the Atomikos dependencies. But my main question is how can the two provide different results!
Even more odd is that I have another installation of Eclipse Helios and everything works fine.
The dependency resolver in m2eclipse is not using the external Maven installation, it has to use the embedded Maven version. So, I'd recommend to get the latest version of m2eclipse, as well as Maven 3.x version to minimize the difference in dependency resolution.
Additionally, it is possible that you had some alternative repositories defined in your maven 2.2.1 conf/settings.xml file. If you use the embedded maven3 these will be ignored.
You also can specify your maven 2.2.1 installation as the maven installation for m2eclipse.
I posted a similar question and finally found an answer. See m2eclipse says "Missing artifact" but I can build from cmdline!
You can find a different solution at http://getsatisfaction.com/sonatype/topics/_missing_artifact_from_m2eclipse_but_it_is_not_true
Same problem here: I use maven 2.2.1 as the installation to use from eclipse, as it is the one which works on the command line. Maven 3 does not work for this concrete project, complaining about some missing dependencies which, after much research, in my case turned out to come from old maven 1 repositories with legacy layout. Maven 3 hates these and will burst burst into cry when it finds them.
So maven 2 works just fine on the command line, but maven 3 does not. The problem with eclipse is that even if you specify maven 2 as the installation to build your projects, it uses maven 3 (the embedded installation) for dependency resolution, so if you are so unlucky to require a legacy repository you are screwed (I mean, eclipse won't help).

Categories

Resources