Exclude module dependencies in jboss AS 7 (EAP 6) when using MANIFEST.MF - jboss7.x

I know I can make it using jboss-deployment-structure.xml, but Is it doable using MANIFEST.MF?

From the source code, the method: o.j.a.s.d.m.ModuleSpecification.addExclusion is only called by o.j.a.s.d.m.d.DeploymentStructureDescriptorParser, and the o.j.a.s.d.m.ManifestDependencyProcessoronly add modules (no exclusions).
So, the Answer AFAIK is NO, we cannot use MANIFEST.MF to define module exculsions.

Related

Dependencies between plugins

I wrote an app which uses plugins, everything is ok, I made my plugins with the bundle template of Xcode.
Now, I need to write a plugin that depends on another plugin, let's say plugin A depends on plugin B.
I tried to link plugin A with plugin B by adding it to the project (link binary with libraries) but that does not work (tried with the full bundle and with the plugin object file inside the bundle).
The only way I found for the moment is to add source files of plugin B to the plugin A but it is bad because in the application, both plugin A and B contains same code (Class X is implemented in both Y and Z. One of the two will be used. Which one is undefined).
How can I implement that ? Thank you
Ok, I found a way to achieve that.
Just copy or reference the header of the classes I need and then use the -U linker flag (in the Other Linker Flags option) in the following form :
-Wl,-U -Wl,_OBJC_CLASS_$_NameOfTheClass
(Wl option is needed, see here why : http://www.cocoabuilder.com/archive/xcode/264371-ld-undefined-symbols-argument-is-ignored.html )
The -U flag for a class allows to compile without having the definition of the class.
With that, I can compile the plugin without duplicating the code of plugin on which I depend.

How do I change the module type in IntelliJ

I have created a project from maven using mvn idea:idea. I recreate the project whenever there is a significant change to the pom files.
Sometimes after recreating, when I open IntelliJ it tells me that the modules have an unknown type so they will be treated as Unknown Modules.
How do I changes these modules to be the proper type?
Can anyone direct me to documentation about how to specify the module type so that idea:idea will generate the modules properly?
Thanks :)
mvn idea:idea generated projects are not supported, please use the built-in IDEA Maven support instead, it works much better and you have an option to import changed Maven projects automatically or manually.

Maven dependency

Hi i have a quite simple question about maven dependency. I have 2 modules of one project. So first module is dependent on second. Second module has dependencies on some libs. Second module can be itself installed as standalone app. So when i build the project the first war will contain packaged second module as well as all libs that second module depends on.
I need that when i package first module the second module should be included without it's dependencies. How it is possible to manage?
Thx
I need that when i package first module the second module should be included without it's dependencies. How it is possible to manage?
Somehow, this is an hint that the dependencies of the 2nd module are provided when it gets packaged inside the war. IOW, declaring the dependencies of the 2nd module with a provided scope would do it, they wouldn't get pulled transitively.
Depending on how you create the standalone distribution of the 2nd module, you might need to combine dependencies scope with profiles, or not. Can't say since you didn't say anything about this :)
References
Dependency Scope

How to configure IntelliJ IDEA and/or Maven to automatically add directories with Java source code generated using jaxb2-maven-plugin?

In our project we are using jaxb2-maven-plugin to generate Java source code from XML Schema, which causes that our Maven module requires additional source code directory (in our case target/generated/main/java). Up to date I've been using Eclipse and maven-eclipse-plugin to import all the projects into Eclipse workspace. The plugin is (somehow) able to add the directory with generated source code automatically to Eclipse' .classpath file.
Recently I try to switch to (play with?) IntelliJ IDEA 9 (so I am a newbie in this environment) and I've noticed that additional source directory is not added during IDEA's importing process...
Is there any way I can configure IDEA/Maven to make importing directory with generated source code automatically?
The convention with Maven is to generate code in target/generated-sources/<tool>, for example target/generated-sources/jaxb2
Follow this convention and IDEA will add the folder as source folder (see IDEA-53198).
Generated code, using jaxb2-maven-plugin, was missing for me in Intellij 2017.1 whereas Eclipse Neon created it.
Fixed it from context menu of module by selecting 'Maven -> Generate Sources and Update Folders'.
Try with maven-jaxb2-plugin. If it does not work then it's IDEA problem.
In Maven you can add new source roots per configuration. Maven plugins can do this programmatically. This is for sure the case with maven-jaxb2-plugin. Then, if IDEA does not recognize it, then it's a problem on that side.
You can use the Maven Build Helper Plugin. It is located at http://www.mojohaus.org/build-helper-maven-plugin/
It allows to configure additional source roots. And the maven integration of IntelliJ will add the new source root. We are using this feature in quite a few builds and it works just fine. Tested with vers. 13 of IntelliJ IDEA.

Embedding JARs into the OSGi bundle with maven-bundle-plugin

I’m trying to embed some JARs into single OSGi bundle using the feature of maven-bundle-plugin
The thing that worries me is that all packages of embedded JARs are put into the Import-Package header of the generated MANIFEST.MF.
If I specify explicitly to use only the packages I need, like in the following snippet:
Import-Package: org.osgi.framework
The build fails with BND error (unresolved references).
So, the question here is how can I build the bundle with embedded JARs with "Import-Package" header I need?
All the packages that are imported in your classes will be imported by bnd. Perhaps you do not want those packages imported because you know that at runtime you won't be needing them. If you cannot stop bnd from importing them, you can make them optional so that your bundle will still resolve even if they are not supplied by another bundle (at wire time). Try to add this:
<Import-Package>*;resolution:=optional<Import-Package>
To your maven bnd configuration in maven.
One possible reason why you are seeing "unexpected" packages in Import-Package header is the following:
A general good practice that supports collaboration model in OSGi is to import all packages that you export -- see this blog post by Peter Kriens for detailed explanation why. Bnd (and hence also maven-bundle-plugin) follows this practice by default and automatically imports all exported packages. Therefore you should first check your Export-Package header and make sure that you export only the packages you want.
Also if you want to export packages from the embedded dependencies then you should be careful to avoid duplication inside your bundle -- see section Embed-Dependency and Export-Package of the maven-bundle-plugin documentation.
You should use Bundle-ClassPath if you want to make classes available inside a bundle that contains JARs e.g.
Bundle-ClassPath: foo.jar,other.jar
Import-Package: org.osgi.framework,org.other.imported
You'll need to list the classes that foo.jar and other.jar import/use, but you won't need to list any of the packages in foo.jar or other.jar unless you're actually exporting them.
You can remove some packages from import-package scope when you embed a JAR into your bundle:
<Import-Package>![package_name9]<Import-Package>
inside pom.xml or if you use external *.bnd files:
Import-Package: ![package_name]