How can i package an eclipse-plugin with maven as a folder? - maven

When i export my eclipse rcp product with eclipse, then it creates my plugin as a folder and everthing works fine. but when i build my product with maven, i can't access images and audio files who are saved in the plugin jar file.
Is it's possible to package a eclipse-plugin as a folder?

Specify:
Eclipse-BundleShape: dir
in the MANIFEST.MF file for the plug-in to say you want a directory (folder) rather than a jar.
Note: If you use a Feature based build the unpack option in the feature.xml will override this.
See also the Eclipse help
Eclipse does also provide APIs to allow you to access files in the plug-in jar (mainly FileLocator).

Related

Maven: generate MANIFEST in custom location

I am trying to retrieve the implementation title and version for a maven jar module. If I use Myclass.class.getPackage().getImplementationVersion() on the built jar, it works, but the same does not work in a debugging environment where the jar is not built, but classes are available.
I am aware of using the Maven JAR plugin to generate the MANIFEST for a maven jar module. So one approach I am considering is to somehow create a copy of the MANIFEST in the generated sources output folder, which I include in my debug classpath. To achieve this:
Is it possible to generate the MANIFEST file in a custom location? If so, what is the plugin and execution configuration necessary?
If not, in which location is the file generated, so I may copy it my custom location using the maven-resources-plugin?
The Manifest file is created dynamically when the archive is assembled. There is no default way to do this.
The easiest I would come up with is to put a MANIFEST.MF in a resource directory, let Maven filter it and add the directory with a profile. This would mimic the way Maven Archiver creates your MANIFEST.MF. The hard way would be to create a custom plugin around Maven Archiver and pass the very same config as to the JAR plugin and enable it with a profile again.

Maven - Which build phase?

I have a Jetty embedded project.
I configured the package phase, using maven-shade-plugin, to create a jar file. It creates a jar file on target folder.
I need to copy some a folter, containing some javascript/html. Which phase do i have to use? the same package phase?
thanks
It depends on what you trying to archive - building a jar containing ressources such as javascript and html files Maven will automaticially include those resources if you place them under /src/main/resources unless excluded in the pom.xml in the phase package (the same and only non-plugin available phase package of the default lifecycle of Maven).
If you on the other hand want to build a webapplication you normally specify the packaging to be a war leading to a *.war web archive. In this case you would normaly place script and html files somewhere under src/main/webapp/WEB-INF as described here: http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

include source files in war maven

I want to include source files also in Maven - War file . Some plugins in maven will do that but they are including source files in classes folder. But my requirement is that when I import the same war file again into eclipse I should be able to work on that war like any other normal war.
Basically I should be able to work on the same war after importing it to eclipse when I build maven project. (I'm using maven3. )
I remember that's not trivial because the war-plugin doesn't support the handy includes-configuration-element you know from the jar-plugin by default.
Therefore I suggest you to use the maven-assembly-plugin to configure the inclusion of your sourcefiles. You only need to define an assembly descriptor, where you list includes and excludes of your war-package. Maybe you can reuse one of the predefinied assembly descriptors to save some time.

Maven build - include classes in projects /src/main/webapp/WEB-INF/classes

We have to build ontop of an application that we did not develop and we need to include some classes from the Jar's WEB-INF directory. How do we get maven to do this? The eclipse deployment directory includes this for local deploy but the built war looks different and does not include the files we place in the source.
You can use the dependency plugin unpack dependency option to unpack from a dependency and output it to a location you desired.
http://maven.apache.org/plugins/maven-dependency-plugin/unpack-dependencies-mojo.html
Or alternatively, you can use the maven assembly plugin's unpack describtor to achieve the same thing.

IntelliJ: Including jars in a jar artifact

Developing on the Mac with IntelliJ 9.0.2 Community Edition.
I have a program which depends on two library jars. I have figured out how to get IntelliJ to make me a jar of my source (with the Artifact tab), and even to include the two jars in it.
However, if I get a listing of the jar file it produces, it looks like this:
com/acme/MyClass1.class
com/acme/MyClass2.class
...
mylib1.jar
myLib2.jar
And, no surprises, if I double-click the jar file, it gets a NoClassDefFoundError the first time it tries to access a class in one or other library jar.
It seems I need to tell IntelliJ to "inline" the library jars -- but this menu option is always greyed out!
Does anyone have any idea how to get jars inlined in a jar artifact?
IDEA doesn't support it yet, you can use Ant integration to package your jar (either by unpacking all the jars into the temp folder and then packaging the project output plus this temp folder into the single jar or by using some Ant task like jarjar).
If you want this feature to appear in the future IDEA versions, please vote for the request.
Having the dependency JARs included in your JAR should allow yoru code to run successfully. You probably don't have the JARs on your classpath.
I will use Maven Assembly plugin. Its simple and will give you a neat little jar file..

Resources