Apache Karaf feature prerequisite - osgi

Karaf 4.0.3
I have the following pseudo-feature:
<features name="my-feature" xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.3.0 http://karaf.apache.org/xmlns/features/v1.3.0">
<feature name="C" version="${project.version}" start-level="25" install="auto">
<bundle start-level="25">...BundleC1...</bundle>
</feature>
<feature name="A" version="${project.version}" start-level="30" install="auto">
<feature prerequisite="true">C</feature>
<bundle start-level="30">...BundleA1...</bundle>
</feature>
<feature name="B" version="${project.version}" start-level="35" install="auto">
<feature prerequisite="true">C</feature>
<bundle start-level="35">...BundleB1...</bundle>
</feature>
C is independant
A depends on C
B depends on C
In this example the bundle 'BundleB1' imports wrong major version of 'BundleC1' and we get the "missing requirement" error (as expected). However if I log into the karaf console and run 'feature:list' I will see that C is Started, A is Uninstalled and B is Uninstalled.
I expect A to be Started since it only has dependencies to C. A will start fine if I comment out the entire C feature or if I afterwards run feature:install A
If I put each of these three features in seperate feature.xml files I get the expected outcome of C+A as Started and B as Uninstalled.
What am I doing wrong?
Am I misunderstanding how the prerequisite attribute works? As a sidenote, if I skip the prerequisite attribute all together then no feature will get installed whatsover...

This is the expected behavior in Karaf 4 : Karaf creates one subsystem with all the features to install. This subsystem is resolved in one pass : either it success or it fails, as a whole.
The prerequisite attribute tells Karaf to install this feature in an independent subsystem : All the bundles are installed and started before trying to resolve the others features.
In your case :
C is installed/started ;
A+B is resolved, but it fails

Related

Visual Studio pré build event delete reference

I'm going to spare you the trouble of explaining why I want to do this, but I'm looking for a way to remove a reference to a dll when a project is build. I'm not talking about an unused reference, but a reference that might contain the same namespaces and the same classes which my project is using. I was thinking of a pré build event command line, but I don't know what the command will look like.
PS: For those of you who do care why I want this. I have a template project A that contains classes that use base classes defined in another project B. This template project (A) its only function is to be packed up in a Nuget package to then be deployed in multiple other projects, for simplicity sake imagine 3 projects C, D and E. Using the Nuget in projects C, D & E will generate all the classes and put a reference to the dll of project B, because we need the Base classes. At the moment I also get a reference to the DLL of template project (A). This is what should not happen because all classes with the same namespaces will exist in project A and in projects C, D & E. This is why I want to automatically remove the reference to the template project (A).
Thanks in advance.
Kind regards,
Yannick
Visual Studio pré build event delete reference
Do you want to delete the reference project A in the build event command line when you build the project? If yes, I am afraid there is no directly build event command line to do this, you can create a power shell script to delete the reference, then execute this power shell script in the build event.
However, just as imp said "Why do you need a reference to the Package A, if it's not going to be used at all?". So as a workaround, you can not add reference project A to the project C, D and E, To accomplish this, you can target the dll files to the tools folder instead of lib folder in the .nupsec file:
<files>
<file src="bin\Debug\ProjectA.dll" target="Tools\ProjectA.dll" />
</files>
The .nuspec of Project A should be:
<?xml version="1.0"?>
<package >
<metadata>
<id>MyModels</id>
<version>1.0.0</version>
<authors>Tester</authors>
<owners>Tester</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package description</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2018</copyright>
<tags>Tag1 Tag2</tags>
</metadata>
<files>
<file src="bin\Debug\ProjectB.dll" target="lib\Net45\ProjectB.dll" />
<file src="bin\Debug\ProjectA.dll" target="Tools\ProjectA.dll" />
</files>
</package>
Then pack this .nuspec file, generate the nuget package, install this package to the project, the reference Project A will not be added to the project.
Hope this helps.

How to run Vaadin 7 applications in Karaf?

I have been looking for days now, with lots of experiments, for an answer to this question. What do I need to do to be able to run applications, using version 7 of Vaadin Web framework, inside Karaf?
There are some information about it but none of the solutions I read worked. The only related question I found on SO (How to integrate Vaadin 7 with OSGi?) does not really have an valid answer, at least for my question. Every time I follow a solution found by googling I always get lots of missing dependencies and I found myself indefinitely searching and installing bundles in order to satisfy all the imports.
This cannot be so hard to achieve. Is there anyone that can give me some guidelines or indicate a good source with the answer to my question?
This is a working features.xml:
<?xml version="1.0" encoding="UTF-8"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0 http://karaf.apache.org/xmlns/features/v1.0.0"
name="vaadin7-feature">
<feature install="true" name="vaadin7-feature" version="1.0.0-SNAPSHOT">
<feature>vaadin7-common</feature>
<bundle>mvn:com.vaadin/vaadin-themes/7.3.0</bundle>
<bundle>mvn:com.vaadin/vaadin-shared/7.3.0</bundle>
<bundle>mvn:com.vaadin/vaadin-server/7.3.0</bundle>
<bundle>mvn:com.vaadin/vaadin-client/7.3.0</bundle>
<bundle>mvn:com.vaadin/vaadin-client-compiled/7.3.0</bundle>
<bundle>mvn:com.vaadin/vaadin-push/7.3.0</bundle>
<bundle>mvn:com.vaadin/vaadin-sass-compiler/0.9.2</bundle>
</feature>
<feature name="vaadin7-common" version="1.0.0-SNAPSHOT">
<bundle>mvn:com.vaadin.external.google/android-json/0.0.20131108.vaadin1</bundle>
<bundle>mvn:org.jbundle.util.osgi.wrapped/org.jbundle.util.osgi.wrapped.c3p0/0.9.1.2</bundle>
<bundle>mvn:org.quartz-scheduler/quartz/2.2.1</bundle>
<bundle>mvn:joda-time/joda-time/2.4</bundle>
<bundle>wrap:mvn:org.springframework/spring-core/3.2.6.RELEASE$Bundle-SymbolicName=Spring-Framework&Bundle-Version=3.2.6.RELEASE</bundle>
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xpp3/1.1.4c_7</bundle>
<bundle>mvn:com.google.guava/guava/16.0.1</bundle>
<bundle>mvn:io.netty/netty/3.9.0.Final</bundle>
<bundle>mvn:org.apache.commons/commons-lang3/3.3.2</bundle>
<bundle>mvn:com.vaadin.external.flute/flute/1.3.0.gg2</bundle>
<bundle>mvn:com.vaadin.external.streamhtmlparser/streamhtmlparser-jsilver/0.0.10.vaadin1</bundle>
<bundle>mvn:com.vaadin.external.google/guava/16.0.1.vaadin1</bundle>
<bundle>mvn:org.eclipse.jetty.orbit/javax.servlet/3.0.0.v201112011016</bundle>
<bundle>wrap:mvn:org.w3c.css/sac/1.3$Bundle-SymbolicName=org-w3c-css-sac&Bundle-Version=1.3</bundle>
<bundle>mvn:org.jsoup/jsoup/1.6.3</bundle>
<bundle>mvn:com.vaadin.external.slf4j/vaadin-slf4j-jdk14/1.6.1</bundle>
<bundle>mvn:com.vaadin.external.atmosphere/atmosphere-runtime/2.1.2.vaadin3</bundle>
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.gwt-dev/2.4.0_1</bundle>
<bundle>mvn:org.apache.commons/commons-jexl/2.1.1</bundle>
<bundle>mvn:com.vaadin.external.json/json/0.0.20080701</bundle>
<bundle>wrap:mvn:javax.validation/validation-api/1.0.0.GA$Bundle-SymbolicName=validation-api&Bundle-Version=1.0.0.GA</bundle>
<bundle>wrap:mvn:net.sourceforge.cssparser/cssparser/0.9.11$Bundle-SymbolicName=cssparser&Bundle-Version=0.9.11</bundle>
</feature>
</features>
Let me know if it helps you.
This method will install Vaadin 7.6.8 to your Karaf 2.4.3.
Save below file somewhere
Open the Karaf shell
features:addurl file:///path/to/your/features.xml
features:install vaadin
This will install Vaadin as a feature to your Karaf installation.
features.xml
<?xml version="1.0" encoding="UTF-8"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0 http://karaf.apache.org/xmlns/features/v1.0.0"
name="vaadin">
<feature install="true" name="vaadin" version="7.6.8">
<feature>vaadin-common</feature>
<bundle>mvn:com.vaadin/vaadin-themes/7.6.8</bundle>
<bundle>mvn:com.vaadin/vaadin-server/7.6.8</bundle>
<bundle>mvn:com.vaadin/vaadin-sass-compiler/0.9.13</bundle>
<bundle>mvn:com.vaadin/vaadin-shared/7.6.8</bundle>
<bundle>mvn:com.vaadin/vaadin-push/7.6.8</bundle>
<bundle>mvn:com.vaadin/vaadin-client/7.6.8</bundle>
<bundle>mvn:com.vaadin/vaadin-client-compiled/7.6.8</bundle>
</feature>
<feature name="vaadin-common" version="7.6.8">
<bundle>mvn:com.vaadin.external.flute/flute/1.3.0.gg2</bundle>
<bundle>mvn:com.vaadin.external.streamhtmlparser/streamhtmlparser-jsilver/0.0.10.vaadin1</bundle>
<bundle>mvn:com.vaadin.external.google/guava/16.0.1.vaadin1</bundle>
<bundle>mvn:com.vaadin.external.atmosphere/atmosphere-runtime/2.2.7.vaadin1</bundle>
<bundle>mvn:com.vaadin.external.flute/flute/1.3.0.gg2</bundle>
<bundle>mvn:org.jsoup/jsoup/1.8.3</bundle>
<bundle>mvn:javax.portlet/portlet-api/2.0</bundle>
<bundle>mvn:com.vaadin.external.slf4j/vaadin-slf4j-jdk14/1.6.1</bundle>
<bundle>wrap:mvn:javax.validation/validation-api/1.0.0.GA$BundleSymbolicName=javax-validation-api&Bundle-Version=1.0.0.GA</bundle>
<bundle>wrap:mvn:com.google.appengine/appengine-api-1.0-sdk/1.7.7$BundleSymbolicName=com-google-appengine-api-1.0-sdk&Bundle-Version=1.7.7</bundle>
<bundle>wrap:mvn:com.liferay.portal/portal-service/6.0.2$Bundle-SymbolicName=com-liferay-portal-service&Bundle-Version=6.0.2</bundle>
<bundle>wrap:mvn:org.w3c.css/sac/1.3$Bundle-SymbolicName=org-w3c-css-sac&Bundle-Version=1.3</bundle>
<bundle>wrap:mvn:com.yahoo.platform.yui/yuicompressor/2.4.8$Bundle-SymbolicName=com-yahoo-platform-yui-compressor&Bundle-Version=2.4.8</bundle>
</feature>
</features>
The easiest option for me was simply to use karaf's war deployer. It allows to simply deploy war into karaf, without having to write XML or other osgi whatnot. I have described the steps here: http://mavi.logdown.com/posts/7813065-deploying-vaadin-app-on-karaf

How to tweak / customize the Visual Studio / MS Build process to execute my new target after a successful build?

I've created a custom task to get me a three-part version number of my assembly that was built in MSBuild.
I've created a custom <Target Name="GetVersion"> for this, and it works nicely - the three-part version number(1.5.2) is stored into a ThreePartBuildNumber property in MSBuild.
But how do I tell MSBuild inside Visual Studio 2010 to call this target once it's compiled my assembly, and before creating my WiX Setup project (where I'd like to set the WiX install script's Product/#Version to this three-part version number automatically)?
How can I "plug" this new target into the usual VS 2010 build process?
Update:
OK, I've managed to get this into the *.wixproj file which is also a MSBuild file, really. In the <Target Name="BeforeBuild">, I can successfully determine the three-part version number, and it's stored inside a MSBuild property called ThreePartVersionNumber.
But how on earth can I now access this properly filled MSBuild property in my WiX setup? I tried setting <Product Version="$(var.ThreePartVersionNumber) ...>, but that doesn't work - it doesn't seem to find the variable.... neither works with the sys. or env. prefixes, either....
So how do I make this MSBuild property that has the information I need "visible" to the WiX installer script/XML ?!?!?!? I can't seem to see the forest for all those angle brackets .....
Use the /verbosity:d switch to get a full view of all the targets that were performed and their rough reason for being called (dependent-on). Identify the exact thing you want to be before or after or dependent upon. Besides using the depends attributes on your Target, there are also various properties that are used to collect dependencies for various purposes. You can identify these by using /preprocess and then looking up the Targets that catch your eye from the previous step.
I've found that specific answers often don't work, as the build situation is different for my language or the exact inclusion order matters or other minor things; so this is how I've found the real triggers in my case.
What I've done in the end:
inside my WiX setup project, in the myproject.wixproj MSBuild file, I've added a new custom task like this:
<UsingTask TaskName="GetThreePartVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<AssemblyPath ParameterType="System.String" Required="true" />
<ThreePartVersion ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.Diagnostics" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Log.LogMessage("Getting version details of assembly at: " + this.AssemblyPath, MessageImportance.High);
Version v = Version.Parse(FileVersionInfo.GetVersionInfo(this.AssemblyPath).FileVersion);
this.ThreePartVersion = v.ToString(3);
]]>
</Code>
</Task>
</UsingTask>
and then in the BeforeBuild target, I added these lines to call this task and define a WiX constant with the results:
<Target Name="BeforeBuild">
<GetThreePartVersion AssemblyPath="$(SolutionDir)Plugin\$(OutputPath)Swisscom.Vidia.Plugin.dll">
<Output TaskParameter="ThreePartVersion" PropertyName="ThreePartVersionNumber" />
</GetThreePartVersion>
<PropertyGroup>
<DefineConstants>ThreePartBuildVersion=$(ThreePartVersionNumber)</DefineConstants>
</PropertyGroup>
<Message Text="Three-part version: $(ThreePartVersionNumber)" />
</Target>
and now in my WiX project.wxs file, I can reference that constant that's been defined, and use it for the <Product Version="..." ... /> attribute:
<Product Id="*" Name="MyProject" Language="1033"
Version="$(var.ThreePartBuildVersion)" ......>
It took a bit of twiddling and a lot of trial & mostly error until I finally got it right - but this is the way it works for me now. Hope this might help some other soul some day....

What is the proper way to remove/uninstall specific packages from my WiX Burn bundle?

I have packages that I would like to remove from subsequent releases. What is the proper way to have this package uninstalled from user machines during future updates? (IE: Remove Package_B below).
I have tried removing the package entry from the bundle and progressed the bundle version, which was the answer in this SO question, but that did not work for me.
<?xml version="1.0">
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Bundle>
<Chain>
<ExePackage
Id='Program_A'
SourceFile='$(var.Program_A.TargetDir)\Program_A.exe'
Cache='no'
Permanent='yes'
PerMachine='yes'
Vital='yes'
/>
</ExePackage>
<ExePackage
Id='Program_B'
SourceFile='$(var.Program_B.TargetDir)\Program_B.exe'
Cache='no'
Permanent='yes'
PerMachine='yes'
Vital='yes'
/>
<RollbackBoundary/>
<MsiPackage
Id='Microsoft_InstallerPkg1'
SourceFile='$(var.Microsoft_InstallerPkg1)'
Cache='yes'
Permanent='yes'
Vital='yes'
>
</MsiPackage>
<RollbackBoundary/>
<Chain>
</Bundle>
</Wix>
Try this
Include same exe packages inside new bundle.
Set DetectCondition to
detect existence of to be deleted package. //It must be evaluates to
true.
Provide UninstallCommand. //It is also necessary otherwise
the package will be executed with default params (which are normally
install by default)

How to call a MSI file from another MSI?

I am using WIX for my application's setup project, I have to install device drivers along with my application setup. so I have two driver installer files for each x86 and x64 platforms (since I have to use difxapp_x64/difxapp_86 reference file I need to have two separate installation projects), and one application setup project. now based on the platform I want to call either one of the driver installer msi file and the application installer file from one Msi file ( Bootstrapper !?). How can I accomplish this ?
after a bit of search i come to know in wix 3.6 there is a new tool know as 'Burn', this will help me to call collection of installation packages that are chained together.. so I have created a new setup project as Bootstrapper. but when I build its creating the msi file successfully but could not able to run it.. here is the code:
<?xml version="1.0" encoding="UTF-8"?>
<?define version="1.3.0.3"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Bundle Name="Bootstrap" Version="1.0.0.0" Manufacturer="Bootstrap" UpgradeCode="58A81C66-C066-4CA1-9712-D884C11C88BD">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
<Chain>
<ExePackage Id="ExeProject"
SourceFile="../../../CCSetupProject/bin/Release/CCSetupProject.exe"
InstallCommand="/q /ACTION=Install"
Name="iCConnectInstaller"
Vital="yes"
PerMachine="yes"/>
</Chain>
</Bundle>
</Wix>
when I click the Bootstrapper.msi file it says "Preparing to install" and then "This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package."
dont know what I am missing here!, anybody got this error before ?
You can't by having two separate packages.
To solve the problem you have to build a merge module for the drivers, and then merge it with the main installation.
By having a separate merge module, you can create an additional package which install only the drivers, or you can use product features to select what is gettin installed.

Resources