I'm building a Maven+Tycho Eclipse RCP application and I would like to run my codesign maven-exec-plugin on OS X before the product is being compressed to zip and before the binary gets compressed for distribution in repository/binary.
So I suppose that the step should be somewhere between the compiling and packaging but I'm having a hard time just by trial and error.
Which lifecycle build phase should it be tied to?
My maven-exec-plugin looks like this at the moment (the app gets codesigned but after the zip has already been created):
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>exec</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>codesign</executable>
<workingDirectory>/tmp</workingDirectory>
<arguments>
<argument>-s</argument>
<argument>"My Developer ID"</argument>
<argument>-vvv</argument>
<argument>${project.build.directory}/products/${product-id}/macosx/cocoa/x86/MyApp/MyApp.app"</argument>
</arguments>
</configuration>
</plugin>
Use the prepare-package lifecylce phase in your execution block instead of the package lifecycle phase.
Related
I am trying to executing a powershell script that writes to a file during a maven build.
I am invoking the build with mvn clean install through Eclipse IDE.
This is the plugin in my pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${project.basedir}/.my-file.ps1</executable>
</configuration>
</plugin>
</plugins>
The powershell script is a hidden file so that's why I have a . in front of the file name.
However, the plugin is not executing and I am following the instructions in the official documentation.
You are running mvn clean install which will go through various build phases, but your exec plugin execution is not attached to any phase. You'll have to either:
Attach your execution to a phase by adding the <phase> element to your execution, for example to attach it to the pre-integration-test phase:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>my-exec</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${project.basedir}/.my-file.ps1</executable>
</configuration>
</plugin>
Or call specifically the exec goal using mvn exec:exec command.
If you are not familiar with the Maven lifecycle and various phases of a build, read the Introduction to the Build Lifecycle guide, or specifically the Plugins part to learn more about plugins executions and phases attachment.
I am trying to code sign my Eclipse RCP application using a Maven+Tycho build system.
I added this piece of code to my pom.xml in order to sign the .app that gets created on the OS X box:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>exec</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>codesign</executable>
<workingDirectory>/tmp</workingDirectory>
<arguments>
<argument>-s</argument>
<argument>"My Developer ID"</argument>
<argument>-vvv</argument>
<argument>${project.build.directory}/products/${product-id}/macosx/cocoa/x86/MyApp/MyApp.app"</argument>
</arguments>
</configuration>
</plugin>
But it keeps giving me this error:
"My Developer ID": no identity found
I read about unlocking the keychain but it really had no effect on my build. And yes, I'm running the build as mvn clean install from the same account owning that certificate.
Is there anyone who managed to solve this issue?
Thanks!
Thanks to Martin Ellis, removing the double quotes around my developer ID did the trick.
We have a relatively large project. One of the modules has 30 generated GWT message bundles.
It takes 2 seconds to generate each bundle, so 2*30 = 1 minute.
I think it's because of big classpath, because the project has a lot of dependencies and they all added to gwt.
In fact, only the src/main/java is needed for the generation. Can I somehow configure the plugin's classpath? For example, the Surefire plugin has classpathDependencyExcludes and additionalClasspathElement, but there's no universal option for all plugins. Right?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.mvn.plugin}</version>
<executions>
<execution>
<goals>
<goal>i18n</goal>
</goals>
</execution>
</executions>
<configuration>
<generateDirectory>${basedir}/src/main/java</generateDirectory>
<i18nMessagesBundles>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.SmpMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.PrepaymentFormMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.DebitorFinanceStateMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.AttributeAnalyticAccountsMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.SearchCustomerAccountsMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.LoanRatingQualityMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.RegistrationOfContractMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.BalancesAccountTurnoverMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.RegistrationClientAccountsMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.PackTermsDialogMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.OtherLoansMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.RatingQualityControlMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.ActualDebitorPacksTableMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.RegCredDecisionMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.PaymentGrafsMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.RestructuringRegistrationMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.CancelFinishContractAccountingMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.CompletionOfContractAccountingMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.PackInfoMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.RenewalRegistrationMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.ReserveLoanAccountMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.RatingWithDeprecMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.ReserveLoanAccaOrderMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.LoanAccountAttributesMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.EkkEndorsementsMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.ReportHeadingsMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.DocumentDetailsMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.ContractChoiceMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.ZvaWObspRaspPrintListMessages</i18nMessagesBundle>
<i18nMessagesBundle>ru.sbrf.iask.client.i18n.TransmitToProcessAlkLimitsMessages</i18nMessagesBundle>
</i18nMessagesBundles>
</configuration>
</plugin>
When the build is ready i have p2 folder in all build archives for different platforms.As i understand it's imposible to exclude p2 directory from archives on building stage. So I try pack archive myself instead of using archive-products execution.
The problem is if i want to make archives for others platform or architecture I will need to change pom.
Now i have the following build schema:
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>materialize-products</id>
<goals>
<goal>materialize-products</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>pack-zip-files</id>
<phase>package</phase>
<configuration>
<target>
<zip basedir="${project.build.directory}/products/xxx/win32/win32/x86"
destfile="${project.build.directory}/products/xxx-1.0.${BUILD_NUMBER}-win32.win32.x86.zip"
excludes="${exclude_p2}" />
<zip basedir="${project.build.directory}/products/xxx/linux/gtk/x86"
destfile="${project.build.directory}/products/xxx-1.0.${BUILD_NUMBER}-linux.gtk.x86.zip"
excludes="${exclude_p2}" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
The quiestion is how to remove p2 folder from all zip files?
What you are doing now is really the only way to do it. You could change the packaging type to eclipse-application and that directory won't be created, but it is a deprecated packaging type and has a whole slew of problems.
The only way to help with multiple POM support would be to put that POM configuration into a profile and have your projects that build products inherit from it. You can also use the osgi.os osgi.arch properties in place of hard-coding things like win32 and linux.
I'am trying to setup eclipse environment to develop bundles (With maven-bundle-plugin-bnd)
and run & debug that bundles equinox from eclipse
I created sample bundles with org.apache.felix maven-bundle-plugin and can install and start that bundles from eclipse equinox,
but every time i need to run "install file:C:\path\bundle1.jar","install file:C:\path\bundle2.jar" which causes pain. i searched for run configuration but it only intalls and starts (plugin) projects in workspace not maven projects.
What i have done is create maven project and add dependencies(bundle1,bundle2 etc..) and added maven-dependency-plugin to copy all depended bundles in one folder (another problem is equinox use "_" delimeter to determine version of bundles but maven uses "-" as delimeter) if i do not strip version in standalone equinox application i need to give version of bundle in config.ini file but i dont want that, is this proper way to solve this problem?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${bundleDirectory}</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<stripVersion>true</stripVersion>
</configuration>
</execution>
</executions>
</plugin>
To sum up , i have bundles in folder, which is created with org.apache.felix maven-bundle-plugin , how can i run and debug them from eclipse?
I wouldn't say this is a "proper" solution, but it may work for you.
The antrun plugin can be used to modify the dependencies to replace the final hyphen with an underscore, so the dependency plugin doesn't need to strip the version.
My regex is rusty, but from a little testing the following configuration appears to apply the required name change to the files in the bundleDependency directory.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${bundleDirectory}</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<!-- move within same directory is preferred method for a rename-->
<move todir="${bundleDirectory}">
<fileset dir="${bundleDirectory}"/>
<mapper type="regexp" from="([a-zA-Z0-9\.-]+)(-)([0-9\.]+.jar)"
to="\1_\3"/>
</move>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
</plugin>
I wrote a tool called auto-builder (http://code.google.com/p/auto-builder). It introspects PDE-based projects and generates Ant build files; it supports transitive closure over dependencies and all that jazz.
I posted a write-up: http://empty-set.net/?p=9. I wrote it because the Maven tools I played with, when integrated with PDE, didn’t “just work.” Basically, I wanted to do coding in PDE and have a Hudson-based CI without any fuss in between.
Generating Ant files is nice because it gives you all the benefits of a declarative build tool, but it leaves you with a procedural description of what it is doing.
I am looking for more PDE-based projects to test it on. There are a couple RFC-0112 Bundle repositories around, and I have some code for downloading dependencies. If anyone is interested, then I could integrate dependencies download with auto-builder.