hi i am using eclipse as IDE for the development of my application. I have one doubt.
I have one plugin that is capable to creating a class on from one xml file. Now, the problem is that i have many xml files and classses to generate..
can anyone please tell me how to invoke the plugin from my java test class, so that i can create classes all together..
Please help me.
I'm not sure which plugin you have in mind, but considering that Eclipse is written in Java itself, you are likely to be able to find a suitable jar file that implement what you need. How its API is documented depends on the plugin (in some cases, you might even be able to find its source code). It's possible that using such a plugin may require using OSGi, since it's what Eclipse uses for its plugins.
However, if your goal is to generate classes from XML (presumably XML shemas) there are libraries for this that you can use directly, for example:
JAXB
Apache XML Beans
Relaxer (for Relax-NG, not for XML shema, with some brief documentation in English within the zip file)
The Eclipse Dali Plugin is able to generate Java classes from an XML schema. In the link below see the section on "JAXB Class Generation".
ttp://www.eclipse.org/webtools/releases/3.2.0/NewAndNoteworthy/jpa.php
Related
I'm attempting to write an IntelliJ plugin for a DSL which references Java classes and methods. The DSL is exposed in *.conf files within a Java project. A typical snippet of the DSL looks like this:
TASK taskClass=com.example.Foo taskMethod=someMethod;
I've been working through the IJ 'Simple' plugin tutorial to learn about plugins and am able to implement a fair bit of my own plugin. Currently, however, I'm stuck on trying to understand how I can provide auto-completion for the taskClass and taskMethod keywords. Having worked through the Simple tutorial all my completion shows is 'Hello'. Now I want to be able to extend my CompletionContributor to show java classes and methods that exist in the project. This doesn't seem to be addressed in the tutorial, but perhaps I'm just missing it.
What do I need, in order to do this? I would guess that there is already some cached info about all the existing java code in a project that my Contributor could leverage.
I think you are looking for the existing stub indices.
For example, to get all class names in your project, you can use
val classNames = JavaFullClassNameIndex.getInstance().getAllKeys(project)
When using indices - your own or already existing ones - it is often useful to use the Index Viewer plugin so you can have a look at which things are in which index.
To add it as a dependency of your plugin (so you don't have to install it manually each time you build your plugin) add the following to intellij block of your build.gradle.kts:
plugins.set(listOf("java", "com.jetbrains.hackathon.indices.viewer:1.19"))
It should appear as a tool window on the right.
Don't forget to remove it once you are done with debugging the indices.
I also found the PsiShortNamesCache which might be useful.
I'm using Maven Java API to configure Maven in a custom Java project.
In particular I need to configure some Maven settings, among which there are proxy settings.
How can i do this? I googled a lot, but I found no examples on how to use Maven from Java.
Can You give me an example or a guide, a snippet of code, whatever you want to clarify HOW TO USE (AND CONFIGURE) Maven by Java API, i.e from Java code?
I found this maven reference, but what do I specifically need?
Thanks in advance.
I've already seen this question, but unfortunately there is no mention on how to edit settings.xml from maven api, I suppose it is possible, but I'm not sure of it, so I asked a new question, wider than that one, how can I manage Maven from Java? settings, run, properties, whatever... is it possible?
For example, about settings management, I found this API maven-settings, it can be useful? It's "read-only" API? I guess it isn't, but I've found no way how to "write" modifications to file, there are no examples on how to use it.
Well, yes, you are a bit crazy. You can take a look at some plug-ins which modify pom.xml files. For example, the versions-set facility shown here:
http://www.mojohaus.org/versions-maven-plugin/set-mojo.html
The source code for that plug-in will show you how to modify pom.xml files, but you also want to modify the settings.xml file.
All of these files are XML. Basically, you want to obtain a DOM for the .xml file. So, you can use generic XML tools to (1) read the file, (2) modify the document model, (3) write the data back to disk.
Note well: Maven caches the .xml files. You have to stop the maven executable and restart it to force it to re-read the .xml files. It sounds like you'll probably be doing this as a matter of course. :-)
I am trying to create a stand alone Java application that accepts an xmi model and an OCL file containing constraints applied to the model's meta-model. The application then validates the model against the ocl.
I have managed to do this inside eclipse using the EMF. However when I start to create the java app, many libraries are missing. Some of which I was able to locate in the plugins directory but some seem to be missing.
For example
org.eclipse.ocl.examples.library.oclstdlib.OCLstdlib;
cannot be found.
Is there a straight forward way, using the EMF to accomplish what I am trying to do. I have been trying to create something very much like the following:
http://subversion.assembla.com/svn/da_sw_tf/trunk/OCL/src/ocl/OCLEvaluator.java
Something missing, usually means something bad configured. Without more information I can only point you out to the OCL Help, where it explains why and how you need to do some manual registrations in order to execute OCL code in standalone mode.
Taken from the help:
"If you use Eclipse OCL within Eclipse you should find that the
appropriate registrations are provided for you automatically by the
plugin registration mechanisms.
However if you use Eclipse OCL outside Eclipse, for instance in JUnit
tests, you must provide the corresponding registrations in your code."
The eclipse plugins were located in my personal folder under .eclipse. I had completely forgotten about the personal instances of the plugins. Instead I re-installed everything only to realise the the libraries were not in the install directory plugins folder.
Installing the EMF and OCL plugins from the following link were correct.
http://download.eclipse.org/releases/kepler
note: you may have to change the above url to suit your particular eclipse version.
I started looking into MoDisco. So far I can discover a java model from an existing java project and write transformations using ATL to modify my java model. However I was unable to generate java code for that modified java model. In this demo there is java code generated from a modified model. An Acceleo launch configuration called JPAProject_Regeneration is used for that as can be seen in this screenshot:
Does anyone know how that launch configuration looks like? Is there a tutorial that explains the creation of this launch configuration?
The mentioned launch configuration can be found in the eclipse svn. However it isn't that helpful, because it heavily depends on a very specific local setup that includes hard coded absolute paths.
MoDisco also provides a discoverer in the plugin org.eclipse.gmt.modisco.java.generation. However this discoverer is registered under the wrong extension point and therefore unavailable from within the UI. See the filed bug.
Also note that once the discoverer is registered correctly it is only applicable if the java model is within a file ending with .javaxmi.
EDIT:
The whole plugin org.eclipse.gmt.modisco.java.generation seems deprecated, because there is a new API for discovery. I built a new plugin that does the same as the mentioned MoDisco plugin based on the new API.
Just a little background:
I have a wsdl and schema files with a lot of hierarchy, meaning there are a lot of import/include tags in the schema. I have a netbeans project and used wsimport to generate the client code. I’m successfully calling the web service operations and getting data.
What I need:
I'm looking to get access to the model the xjc compiler uses to generate the java code from the schema. I would like to do this without writing my own plugin if possible. I want to use this model to generate my own code with codemodel.
The question is:
Is there a way to get access (preferably from my client project described above) to the model or 'outline' without writing a xjc plugin?
I’m new to java and jaxb so any direction and detailed instructions are much appreciated.
You can invoke the xjc compiler directly by using Ant or Maven. Just point it at the schemas referenced. If you need some control over the code generated, you could look at custom binding in JAXB.
What exactly are you trying to accomplish?