Eclipse RCP Fragment How to Build library.jar - maven

I have a plug-in fragment which contributes a jar file to the host plug-in, following these instructions. It works by creating a file library.jar which is specified in build.properties and associated with a directory which contains the source to be built.
It all works as expected, except I can't figure out how to cause library.jar to be created in Eclipse. When I run a Maven build that points to my fragment project and includes it as a module, the file library.jar shows up in the project directory. But building or cleaning the project in eclipse does not create the file.
I want other developers to be able to generate library.jar in their Eclipse workspace without running the Maven build. I'm really surprised that the Maven build creates libary.jar in the plug-in project itself, and not just in the product created in the build target. There should be a way to get Eclipse to do this without running the Maven build.
EDIT:
build.properties:
bin.includes = META-INF/,\
library.jar
source.library.jar = src/
MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Custom
Bundle-SymbolicName: org.python.pydev.custom
Bundle-Version: 1.0.0.qualifier
Fragment-Host: org.python.pydev;bundle-version="5.1.2"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-PatchFragment: true
Bundle-ClassPath: library.jar,
.
Require-Bundle: org.python.pydev.debug;bundle-version="5.5.0",
org.eclipse.cdt.debug.core;bundle-version="8.0.0",
org.apache.log4j

Eclipse will build the library.jar rather than putting the class files in the normal place when the build.properties file looks like:
bin.includes = META-INF/,\
library.jar
source.library.jar = src/
The library.jar entry in the bin.includes replaces the normal . entry.
The source.library.jar entry says that the Java files in the src directly should be put in the library.jar.
The Bundle-Classpath entry in your MANIFEST.MF should be:
Bundle-ClassPath: library.jar
(so no '.' entry)

Related

How to add a xml a file as dependency using gradle?

I have a project build on gradle and it has a directory src/main/dist/deploy. In deploy folder there is a xml file. This xml file i want to add as a dependency in the jar file which my build.gradle is generating. This jar i am adding in the lib folder of another project that has a dependency on my gradle project. The other project is built using ant. When classes bundled in gradle jar are loaded from ant project they are unable to read that xml file from the gradle jar.
The standard java plugin does not look in src/main/dist/deploy for resources.
You should either move the xml file into java plugin's standard resource folder src/main/resources, or add the dist/deploy folder to your main sourceSet's resource list.

Wrong MANIFEST.MF in war file

I have pack jsp file to war using command "maven compile war:war". When i deploy it on JBoss SA i got view like this:
PK«µgG META-INF/þÊPKPK«µgGMETA-INF/MANIFEST.MFóMÌËLK-.Ñ K-*ÎÌϳR0Ô3àår.JM,IMÑuª XèÄ›˜*hø%&ç¤*8çä%–•kòrñrPK©ÆÐCDPK fµgGWEB-INF/PK1µgGWEB-INF/web.xml•‘QKÃ0…ßÿCÈ{’n}‘’v2Ì'}Ys·f¤iÙÍ–úïÕ©æêë9ß!'çÊYW[r„=šÆåtÂJÀ•6n›Ó§Ç9»¡³âúJX3Õ¶$â³MN+ïÛLˆ)oö[1M’‰x¹_>”ÔŠ‡^¹èGê+±SGÅñàxÙÔ"ZÂa¯Á;‰&Ã>¾lJåûVcä"!>û¯ÒUÂ;Ô”ÓgXßFmqG¿'HãñÄHm°µê•9UCóS)R°ñ1`cYƒ¾—…q:^ùÚJ10þ„G³;lG°6ê`ýØ?ðÐ㪜ã†ÒiOyº^ñPK;¤ÙŸ¯PK«µgG META-INF/þÊPK«µgG©ÆÐCD=META-INF/MANIFEST.MFPK fµgGÂWEB-INF/PK1µgG;¤ÙŸ¯èWEB-INF/web.xmlPKð%
Then same files from eclipse compile fine, but i cant use eclipse at this project. Maven is not adding my manifest.mf, is it my problem?
from maven:
[INFO] WEB-INF\web.xml already added, skipping

Jar Manifest changes getResource() path

I have a critical problem after building a jar file via maven. I told the maven-jar-plugin to use several classpaths. The created jar contains the following manifest:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Build-Jdk: 1.8.0_25
Main-Class: EntryPoint
Class-Path: Launcher-1.0.jar lib/ Introduction-1.0.jar
But when I try to load a resource from a method in EntryPoint.class, the root path is /xx/xx/lib/ and I am not inside the jar file, it is the lib/ folder which was specified in the Manifest.
This is the snippet I use inside the method of EntryPoint:
System.out.println(EntryPoint.class.getResource("").getPath().toString());
BUT: I need to load an xml file inside the jar, how can I get back?
javax.swing.ImageIcon ICONE =new javax.swing.ImageIcon(getClass().getClassLoader().getResource("path/subdir/video.png"));
OR
Icon ic2=new ImageIcon(ThisCurentClassName.class.getResource("/fr/package/someresource/icones/server1.png"));

Combining jars for multi modules maven project in a single jar

I have a parent maven project that includes some child projects and a build/assembly project. The structure looks like this
ParentProj
+ pom.xml
+ ChildProj1
++ pom.xml
+ ChildProj2
++ pom.xml
+ buildProj
++ pom.xml
I want to create an executable jar in the build project, or project that contains all child project jars. Basically the final result should be a jar that includes all child project jars in the classpath.
Your project buildProj should have the other child projects declared as dependencies, you could then configure the maven assembly plugin to use the predefined descriptor jar-with-dependencies which create a jar that contains the dependencies.
How can I create an executable JAR with dependencies using Maven?.
https://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html
EDIT
If you wish to add the dependencies jar in your jar, you could use something like onejar:
Creating a JAR file which contains other library files
http://one-jar.sourceforge.net/
There is a maven plugin for this tool: https://code.google.com/p/onejar-maven-plugin/

Not able to access classes in javamail in OSGi

I have an OSGi bundle and I'm using java mail api in it to add mail functionality.
The problem I'm facing is, the bundle class loader is not adding the entries for mail-1.4.jar and activation.jar in classpath variable which it creates while loading the local or global classes.
I've added the mail-1.4.jar and activation.jar in the bundle classpath in manifest and these jar are simple jars(not the OSGi bundles). And these are in lib directory in my bundle.
Now while loading javax.mail.Address class ClassNotFoundException is thrown.
And this is when I'm running my application using command line.
It works completely fine when I run it in Eclipse.
I'm using equinox as my container.
Any suggestions?
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Workexp
Bundle-SymbolicName: com.gslab.workexp
Bundle-Version: 1.0.0
Bundle-Activator: com.gslab.workexp.Activator
Bundle-Vendor: GSLAB
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.osgi.framework
Bundle-ClassPath: .,
lib/mysql-connector-java-5.1.20-bin.jar,
lib/commons-beanutils-1.8.0.jar,
lib/commons-collections-2.1.1.jar,
lib/commons-digester-2.1.jar,
lib/commons-javaflow-20060411.jar,
lib/commons-logging-1.1.1.jar,
lib/iText-2.1.7.jar,
lib/jasperreports-4.6.0.jar,
lib/jdt-compiler-3.1.1.jar,
lib/log4j-1.2.9.jar,
lib/mail-1.4.jar,
lib/activation.jar
Your use of the bundle classpath is unusual. You should use Import-Package (best practice) or Require-Bundle for dependencies. Bundle classpath is saying all those jars are packaged inside a lib folder inside your bundle archive. I suspect this isn't the case, and even if it was, you'd be totally bypassing all the modularity Eclipse gives you.
Try adding the 'javax.mail' package to your Import-Package header. For an explanation of why this isn't needed in Eclipse, see i/Why_does_Eclipse_find_javax.swing_but_not_Felix%3F.
Make sure you have included your lib folder inside the bin.includes (Build Tab in the Manifest editor) or they won't get exported in the final jar.
This is a very annoying 'bug' that it works in eclipse (because the files are accessible in the file system) but the builder will ignore not included files.

Resources