How to setup bundle development environment (Eclipse Equinox Maven) - eclipse

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.

Related

Mavan deploy goal rewrites even the unmodified files in the repository

I am assigned to implement an incremental deploy of a multimodule maven( Maven 3.5.3) project. Whenever I am trying to deploy the project using "deploy -DaltDeploymentRepository=internal.repo::default::file:///home/Example", from eclipse IDE even the unmodified jars and pom are also getting replaced with new ones. Which is not considered as a incremental deploy. Is there any way to only upload the modified jars to the local repository home/Example.(I am using TFS for CI but after the testing the application is physically distributed to customers.)
I tried takari plug-in to do that but its only effective for compile/jar/testCompile goals.I can't see any incremental install or deploy.
I can't use deploy: file list, its not an automated process.
<plugin>
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-lifecycle-plugin</artifactId>
<version>1.13.10</version>
<configuration>
<proc>proc</proc>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>deploy</id>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
I can see incremental build in compile phase but not in deploy. Anyone have a solution to do the incremental deployment using any plug-ins or anything?
I tried takari plug-in to do that but its only effective for compile/jar/testCompile goals. I can't see any incremental install or deploy.

Include scala classes in the sources jar generated by maven package

The following plugin added to the pom.xml allows source-jar to be created when performing mvn package:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
The usage of the scala-maven-plugin is :
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmArgs>
<jvmArg>-Xmx12g</jvmArg>
</jvmArgs>
<args>
<arg>-feature</arg>
<arg>-deprecation</arg>
<arg>-target:jvm-1.7</arg>
</args>
</configuration>
</plugin>
However only the java sources are being included: the scala sources are left out. Note that we are using the standard maven directory layout. In particular we have scala sources here:
src/main/scala
So - are there additional options to the maven-source-plugin to encourage it to invite the scala classes to participate? Or a different scala-specific plugin and/or option to get them onboard?
The jar goal of the Maven Source Plugin will bundle all of the sources of the Maven project into a JAR. You can select what to include or exclude in those source folders (with the includes and excludes parameters), but you cannot add whole new source folders to it; they must be added as source folders of the Maven project itself.
When you have a pure Scala project, src/main/scala and src/test/scala are declared as source folders, because you would have:
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
in your POM, overriding the default src/main/java and src/test/java. So the Maven Source Plugin would correctly add the sources present in those two folders without additional configuration.
But when you have a mixed Java / Scala project, the <sourceDirectory> and <testSourceDirectory> element are typically left in to their default values. This does not create any problems with regard to compiling or running Scala code with the plugin, as it looks up the files by default in ${project.build.sourceDirectory}/../scala. However, other unrelated Maven plugins can't know about those new folders.
To fix this, the plugin provides the add-source goal, which adds src/main/scala and src/test/scala as source and test source directory to the Maven project, and, thus, makes them available for the other plugins relying on the source directories, like the Maven Source Plugin. You should therefore change your POM to:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<!-- rest of configuration -->
</plugin>

mvn gwt:i18n too slow

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>

Tycho puts "p2" folder in the product with eclipse-repository and tycho-p2-director-plugin plugins

I changed my Tycho+Maven build (RCP application) to use Tycho 0.13 and eclipse-repository plus tycho-p2-director-plugin (instead of my old "eclipse-application" in Tycho 0.10).
I managed to get the build working (producing the ZIP files), but they are 2 times bigger than they used to be.
I see Tycho puts a lot of additional stuff my product does not need:
1) "p2" folder at the root level - 35 Mb.
2) a lot of useless plugins, like
plugins/org.eclipse.jdt.debug_3.6.1.v20100715_r361
plugins/org.eclipse.pde.build_3.6.2.R36x_20110203
plugins/org.junit_4.8.1.v4_8_1_v20100427-1100
......etc.........
how to configure "eclipse-repository" and "tycho-p2-director-plugin" to avoid this? At least to not put "p2" folder in the product. My software does not use "p2 update" mechanism for auto-updates.
your product may drag in transitive optional dependencies.
See [1] for how to avoid this.
The p2/ folder is always created but should not be 35MB.
If you can provide a sample project to reproduce the problem, open a bug [2] and attach it along with steps how to reproduce.
[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=342704
[2] https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Tycho&rep_platform=All&op_sys=All
I ended up removing "archive-products" completely - it's not flexible and requires a lot of horrible hacking with unpacking/repacking/renaming. I'm packing the ZIP files myself now:
<properties>
<distributive.prefix>${project.build.directory}/products/taskadapter</distributive.prefix>
<exclude_p2>**/p2/**</exclude_p2>
</properties>
<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>create-zip-files</id>
<phase>package</phase>
<configuration>
<target>
<zip basedir="${distributive.prefix}/win32/win32/x86"
destfile="${project.build.directory}/taskadapter-win-${project.version}.zip"
excludes="${exclude_p2}" />
<zip basedir="${distributive.prefix}/linux/gtk/x86"
destfile="${project.build.directory}/taskadapter-linuxgtk-${project.version}.zip"
excludes="${exclude_p2}" />
<zip basedir="${distributive.prefix}/macosx/cocoa/x86"
destfile="${project.build.directory}/taskadapter-macos-${project.version}.zip"
excludes="${exclude_p2}" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
"p2" folder, the folder is created by p2 itself when materializing the product. if your application doesn't support update itself, you can simply remove it from the built product.
useless plugins. There is no way to remove them from your final materialized product, they are transitively required by your product. See this for detail.

How to copy dependencies to gae war/WEB-INF/lib

I'm coming from Ant perspective, so pardon me. I realise there are quite a few questions here already on how to maven dependencies, but none of them seem to tell how to do what need to do.
Question 1:
Currently, in conjunction with using maven-war-plugin, when I run mvn war:war, it creates a war folder in target folder.
However, I wish copy all the dependencies' jars to war/WEB-INF/lib set up by google eclipse plugin (with gae enabled, gwt disabled), without overwriting the jars that google eclipse plugin placed there.
I don't wish to setup a war file or war directory. I just need to copy/consolidate all the non-gae jars with the gae jars so that when the project is run as a gae web app, Eclipse would not complain ClassNotFoundException.
Question 2:
When using Ant in Eclipse, I could run Ant targets within Eclipse.
Right now, I have to perform mvn commands from a shell window (which is mutually oblivious to the existence of an Eclipse session). It appears that the only thing that is automatically done is whenever I update dependencies.
Is there a way, or any plugin for eclipse that would allow me to run mvn goals within Eclipse?
Additional info:
mvn dependency:copy-dependencies persists in copying to target/dependency directory, with the following:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>process-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/war/WEB-INF/lib/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeArtifactIds>gwt-user,gwt-dev</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
I even tried changing to absolute path
<outputDirectory>
/home/geek/eclipse/workspace/Demo-autoshoppe/holycow
</outputDirectory>
But holycow directory is still empty and mvn still persists in copying to target/dependency directory. My current solution is to softlink target/dependency as war/WEB-INF/lib, which is a very very bad kludge. Why is maven not sensitive to outputDirectory specification? I am using Ubuntu's maven 2.2.
I have the real answer for you, my man.
Use the "default-cli" execution id. Make sure you're using Maven 2.2+. This exec-id applies to command-line executions of the mojo.
<build>
<pluginManagement>
<plugins>
<!-- Copy dependencies to war/WEB-INF/lib for GAE proj compliance. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/war/WEB-INF/lib/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeArtifactIds>gwt-user,gwt-dev</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Cheers.
An associate emailed me this answer which works. Trigger the follow through
mvn build or mvn package
but not directly thro mvn dependency:copy-dependencies.
<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>${basedir}/war/WEB-INF/lib/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeArtifactIds>gwt-user,gwt-dev</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
Regarding #1: I'd suggest creating your maven project based off this plugin and archetype http://code.google.com/p/maven-gae-plugin/ (see the GWT based example if you are writing a GWT app for GAE).
Regarding #2: Check out m2eclipse plugin for full maven integration in eclipse. It's written by Sonatype (the creators of maven): http://m2eclipse.sonatype.org/