IDE features in NetBeans platform application - netbeans

I am developing application based on the NetBeans platform. I use Maven to build it and I need to provide IDE features in my app (text editing, syntax highliting for XML files and so on).
Which libraries do I need to declare as dependencies to be able to provide the editor support? And what about XML syntax highliting (or full XML files support)? I am kinda lost in those dozens of JARs. Is there any way to include whole NB cluster? (To make sure everyone gets it, once again, I use Maven.)
Thanks for any help.

Have a look at the NetBeans API index in the content section there is a short description about what each API provides. At a guess I think you're wanting to use the Editor Module and maybe the XML API
I think that if you include the following dependency you will get the entire NetBeans (This is not something that I've tried) IDE as a dependecy
<dependency>
<groupId>org.netbeans.cluster</groupId>
<artifactId>ide</artifactId>
<version>RELEASE70</version>
<type>pom</type>
</dependency>

Related

How to add java source code for AspectJ in eclipse

I am learning AOP with Spring framework and I want to set the javadoc for AOP in eclipse. So what I did I downloaded aspectj-1.8.10.jar from eclipse web site https://eclipse.org/aspectj/downloads.php#install then I installed that jar and got 4 new jar files: aspectjrt.jar, aspectjtools.jar, aspectjweaver.jar, org.aspectj.matcher.jar which I added to my class path in eclipse. Now what I want is to add source files for these jars so, for example, when I hover over #Aspect I want to be able to see what this annotation represents. Unfortunately I can not find the source files for these jars, on the eclipse website mentioned above there is a file aspectj-1.8.10-src.jar but I'm not sure what to do with it, I tried to attach this file directly in the build path for each of the jars mentioned above but it didn't do the trick. Also I thought that maybe I had to install aspectj-1.8.10-src.jar the way I installed aspectj-1.8.10.jar so I would get 4 source files, but I'm not sure how (if possible) to install it, when I double click aspectj-1.8.10-src.jar, installation does not get triggered.
So can you please help me out to add javadoc for AspectJ 1.8.10 in Eclipse?
Select the library in your Eclipse project explorer window, click right button, select properties, select javasource attachment or javadoc location and enter the path to the source or javadoc file.
But I would suggest to use maven to maintain the dependencies of your project. It makes getting javadoc much easier, because libraries, source code and javadoc are fetch from a central repository. You just add the library you need in your project configuration (pom.xml file) and the other files are fetched for you.
You do not need all those libraries. Please first learn which one serves which purpose. E.g. aspectjrt is the runtime. When using Spring AOP you actually do not really use AspectJ, only a subset of its syntax. Thus, the runtime is needed for identifying some of the annotation classes. However, aspectjweaver is only needed if you want to use full AspectJ in a load-time weaving (LTW) scenario, with or without Spring. The weaver lib is a superset of the runtime, so you only need one of them. Last, but not least, aspectjtools again is a superset of the weaver lib and contains the AspectJ compiler (among other tools). This is only needed for compile-time weaving as part of your toolchain.
I do not think that source code and Javadoc will help you much in learning AspectJ. I suggest you read the Spring manual's AOP chapter describing both proxy-based Spring AOP and full AspectJ integration via LTW. If you want to learn AspectJ basics and maybe just use AspectJ without Spring (which is what I do), read the AspectJ documentation.
If you are still not convinced and want to add source and JavaDoc to your Eclipse project, why don't you follow jaysee's advice and use Maven? Then you get all the source/javadoc libs for free. But anyway, you can also load those JARs directly from Maven Central, e.g. the source and javadoc for AspectJ runtime 1.8.10. Good luck! But I assume you will be disappointed because the AspectJ JavaDoc is really bad for learning purposes and not suited to understanding how to actually use AspectJ.

How to package only the necessary libs in Google App Engine Project(Java)?

Let me explain first what I mean by necessary libs. I'm creating my first project using the Google App Engine for Java with the official Google Maven Plugin, the main problem that have Maven as a packaging solution (or maybe the Java development as a whole) is that if the dependency tree grows too much, the release process may be harder.
Let me illustrate it with an example. Let's start with the Jackson JSON library (it's a good starting point since it has no parent dependencies), now someone makes a JSON-RPC library and uses Jackson for the JSON serialization/deserialization. Imagine that this library not just provides a JSON-RPC client implementation, but also a server, that means that the POM of this lib will add some Java EE related libraries such us Jetty as dependencies.
Probably the guidelines say that the application should be either divided into modules or mark the server related deps as optional, but you know that many people don't follow the standards.
Now someone need a JSON-RPC client for his/her project, call it Project X, and uses the lib mentioned above, at compile time there will be no problems, Maven will successfully download the required libs and the application will compile fine, but the problem comes when that person wants to release the application. Which dependencies should be distributed along with the package (in a lib folder for example)?
Actually that's something that happened to me, I wasn't too much familiar with Maven so I used the Eclipse Runnable Jar Exporter, that produced jar file with all the maven libs copied to a lb subfolder, so the workaround that I did then was to just delete the libs that looked unnecessary and then tested if the application was still working. If there are classes that are not executed, as far as I know they are not loaded by the ClassLoader so they could be omitted and are unnecessary
I can't use the same trick now since the scenario is much more complex, we are talking of a Java Web Application, not a desktop application like the other one, and the library that I want to include is a Liquid Template Engine, which uses the ANTLR framework to generate the parsers plus Jackson for the JSON handler and Jsoup for HTML parsing.
Which libs should be packaged inside the WEB-INF/lib folder? I'm sure that I will need Jackson for JSON parsing but I'm not so sure about Jsoup, and what about ANTLR, it is necessary or is used just at compile time?
Update: I think I need to re-formulate my question, actually what I want is to determine which dependencies are really necessary for the application, and package those into the app WEB-INF/lib folder
Solution: It seems that the POM file that is packaged in the WAR file of the web app is used once the app is in the Google App Engine production environment to retrieve the necessary dependencies, and probably the appengine:update goal only packages those dependencies that can't be retrieved from the maven central repo, so there is no need to worry about that.
Thanks to David to point this.
You should check Maven's dependency scopes. Here's an extract from the documentation :
There are 6 scopes available:
compile This is the default scope, used if none is specified. Compile
dependencies are available in all classpaths of a project.
Furthermore, those dependencies are propagated to dependent projects.
provided This is much like compile, but indicates you expect the JDK
or a container to provide the dependency at runtime. For example, when
building a web application for the Java Enterprise Edition, you would
set the dependency on the Servlet API and related Java EE APIs to
scope provided because the web container provides those classes. This
scope is only available on the compilation and test classpath, and is
not transitive.
runtime This scope indicates that the dependency is
not required for compilation, but is for execution. It is in the
runtime and test classpaths, but not the compile classpath.
test This
scope indicates that the dependency is not required for normal use of
the application, and is only available for the test compilation and
execution phases.
system This scope is similar to provided except that
you have to provide the JAR which contains it explicitly. The artifact
is always available and is not looked up in a repository.
import (only
available in Maven 2.0.9 or later) This scope is only used on a
dependency of type pom in the section. It
indicates that the specified POM should be replaced with the
dependencies in that POM's section. Since they
are replaced, dependencies with a scope of import do not actually
participate in limiting the transitivity of a dependency.
So in a Maven project, the developer indicates which dependencies should be bundled in the application and which should not.
Basically there are two cases here :
If you're building a web application (WAR or EAR format) and want to deploy it, or if you're building an actual runnable jar, then you will need to bundle it with all the dependencies with scope compile and runtime.
If you're building a library, then you do not package any dependency with your library. Instead you include the pom.xml so that others know what dependency your library requires. For Maven to know how to find the associated POM for a given jar, the best and most common solution is to deploy the library to a Maven repository. Repos have a directory structure that helps Maven find the right version of a library, and find the POM that indicates the required dependencies.
Depending on wether your library is open source or not, you will be able to be hosted for free by some repositories such as Sonatype (complete list here). But you can also setup your own repository either by installing a dedicated software such as Nexus or by configuring a Github project as the repo, as is explained on this blog.
You can exclude any transitive dependency.
For your case, to remove jetty from this json-rpc-library, you need:
<dependency>
<groupId>com.somecomp</groupId>
<artifactId>jsonrpclib</artifactId>
<version>1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</exclusion>
</exclusions>
</dependency>
See docs: http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

EAR modules in m2e

I'm converting an existing project structure to Maven where there's EJBs and JARs contained in EARs that are deployed. My issue is with making EARs. It seems obvious to use the Maven EAR plugin, which either takes an existing application.xml or generates one on basis of configuration.modules. I feel I'm not entirely leveraging Maven if I would not use the modules configuration (although it would allow developers to reuse the existing application.xml editor), but I'm thinking about many of our developers who love to click around in RAD/Eclipse to get things configured. So I took a look at RAD/Eclipse in full expectation to see some m2e support that would allow me to point-and-pick my EAR modules, and then see the modules in the POM file being populated accordingly. But I'm not able to find such thing. I believe I installed m2e (1.3.0) and m2e-wtp (0.17.0) although it seems to bring me very little in terms of WTP/EAR support. Also I spent most of tonight googling around, to no avail. Should I forget about it and have devs just manually edit the POM file, or am I overlooking some nifty UI for this purpose? Thanks for your pointers!
Seeing a comment and an answer that drive me to elaborate. I do appreciate that when using Maven, Maven is leading. No argument there. And I know that I can take control over the application.xml back using generateApplicationXml, but that's not even what I'm after, again Maven can be leading. But as I can use the "Maven POM Editor" to edit the basic structure of the POM, would there be any UI available to edit the configuration.modules? Our devs are very acustomed to IDE-centric development, and them having to start editing POM file XML in order to manage modules is something that scares me slightly...
If you want to configure your application.xml manually you can include the file to your source folder and set the generateApplicationXml property to false so maven will not overwrite it.
See for details: http://maven.apache.org/plugins/maven-ear-plugin/generate-application-xml-mojo.html#generateApplicationXml

Eclipse plugin for spring

IDEA allow to find bean definition, declared in xml, right from Java code. For example if I've got interface SomeIntrfaceImpl IDEA allow me to find out instances of SomeIntrfaceImpl in .xml contextes files, pointing me to .xml file to line of code where bean is created
Is there any Eclipse plugin, that allow me to do the same ?
Yes there is different Eclipse provided by SpringFramework makers itself. They have extended the eclipse to provide easy development for Spring web application and other products like Spring ROO also.
Its is called SpringSourceToolSuit. You can download its latest version from here after providing some basic information about you asked in a form there.
Its the best IDE to develop Spring applications. I am currently using it.
Hope this helps you. Cheers.

JDT without Eclipse?

Some time ago I wrote an Eclipse plugin which makes use of JDT to do some parsing. Now I am thinking of making a command-line version of this app. Naturally, I hope to reuse the parsing code, so I need to get JDT to work outside Eclipse. Is there any way I can accomplish this (maybe build some wrappers, etc)? Are there any ports of the JDT library that provide the same API / functionality but work independently of Eclipse?
Any help will be greatly appreciated. Thanks.
The JDT is divided into two distinct parts. The parsing parts should all be in plugins which have no UI-dependencies at all. I think they do have a dependency on the Eclipse runtime, which means that you more or less need to create a "headless RCP application".
You can use JDT Core in the command line. Parsing, AST, rewriting everything can be done without the UI.
In order to be able to use AST classes in a stand alone application you have to use such libraries (where xx stands for version):
org.eclipse.core.contenttype_xx.jar
org.eclipse.core.jobs_xx.jar
org.eclipse.core.resources_xx.jar
org.eclipse.core.runtime_xx.jar
org.eclipse.equinox.common_xx.jar
org.eclipse.equinox.preferences_xx.jar
org.eclipse.jdt.core_xx.jar
org.eclipse.osgi_xx.jar
If you installed eclipse with JDT all those jars are in eclipse's plugin folder for example in Windows it could be in C:\Program Files\eclipse\plugins\