-vmargs Goes Missing During Tycho Build - eclipse-rcp

I've a problem with my Tycho build. I've got a standard RCP product that starts the application. And a Tycho configuration like this:
<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>
<execution>
<id>archive-products</id>
<goals>
<goal>archive-products</goal>
</goals>
</execution>
</executions>
<configuration>
<products>
<product>
<id>${project.artifactId}</id>
<attachId>${project.artifactId}</attachId>
<archiveFileName>${archiveName}</archiveFileName>
</product>
</products>
</configuration>
</plugin>
This is the entire configuration, and it's probably the most minimalistic one possible.
Which makes what happens during the Tycho build even weirder. The product file defines the following program arguments:
-clean
-persistState false
-vmargs --add-modules=ALL-SYSTEM
After the build the -vmargs is missing, so the INI file looks like this:
-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.551.v20171108-1834
-clean
-persistState
false
--add-modules=ALL-SYSTEM
This means the application does not work with this file, because --add-modules somehow needs -vmargs to work.
I have no idea where to even start debugging this problem. Why does Tycho remove the -vmargs argument and how do I prevent this from happening?

Related

increase scala stack size during maven build

While compiling a scala project using maven (mvn compile) , I am getting error: java.lang.StackOverflowError.
I got the same from eclipse as well, but could solve it by giving Additional command line parameters: -J-Xss256m for scala compiler , as given here How to increase scala stack size
But I am getting the same error while doing "mvn compile". How can I solve this ? Basically how to increase scala stack size while building via maven
You can configure the scala-maven-plugin in the pom.xml like bellow
<project>
...
<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>-Xms256m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
</jvmArgs>
</configuration>
</plugin>
...
</project>
For more see http://davidb.github.io/scala-maven-plugin/example_compile.html

GWT dev mode not refreshing when client code changes

Dev mode works fine, but if I change client code and refresh the browser it doesn't see the code changes. I'm using maven, with the following gwt plugin config.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.6.0</version>
<executions>
<execution>
<goals>
<goal>browser</goal>
<goal>run</goal>
<goal>debug</goal>
<goal>compile</goal>
<goal>test</goal>
<goal>i18n</goal>
<goal>generateAsync</goal>
<goal>resources</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>simmapp/simmapp/template/Login.vm</runTarget>
<hostedWebapp>${war}</hostedWebapp>
<servicePattern>redangus/client/**/*Service.java</servicePattern>
<generateDirectory>${target}/generated-sources/gwt</generateDirectory>
<modules>
<module>redangus.Inventory</module>
</modules>
<deploy>${target}/extra</deploy>
<!--war>${war}</war-->
<!-- If you don't have this, an empty JspFactory sneaks in and
breaks the tests. -->
<gwtSdkFirstInClasspath>true</gwtSdkFirstInClasspath>
<runClasspathExcludes>
<runClasspathExclude>javaee-web-api-6.0.jar</runClasspathExclude>
</runClasspathExcludes>
<sourceLevel>1.7</sourceLevel>
<persistentunitcache>true</persistentunitcache>
<persistentunitcachedir>${basedir}/persistent</persistentunitcachedir>
</configuration>
</plugin>
The command line produced and run by netbeans with the classpath hacked out:
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/bin/java -Xmx1024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y -classpath whatever -Dgwt.persistentunitcache=true -Dgwt.persistentunitcachedir=/Users/tom/git/reds_gwt/persistent com.google.gwt.dev.DevMode -deploy /Users/tom/git/reds_gwt/target/extra -gen /Users/tom/git/reds_gwt/target/.generated -war /Users/tom/git/reds_gwt/target/simmapp-1.0-SNAPSHOT -logLevel WARN -port 8888 -codeServerPort 9997 -startupUrl simmapp/simmapp/template/Login.vm -logdir /var/log/tomcat redangus.Inventory

How can I get tycho materialize-product and archive-product to use a directory prefix for my RCP app archive file

How can I add a prefix directory so when I unpack the zip containing my RCP app I get a directory containing the contents?
When tycho materalizes and archives my rcp app it zips up target/products/my.rcp.app/linux/gtk/x86_64/ contents without a directory prefix.
Current zip contents:
./features
./plugins
...
Desired zip contents:
./myapp/features
./myapp/plugins
...
When a user unpacks the zip, I'd like the app directory to be created. I looked through the tycho docs but neither archive nor materialize seems the right place to configure this. I could always use antrun or assembly plugin to do the work but that doesn't feel like the right maven way to solve the problem.
Please let me know how to add a prefix directory.
The configuration is really a bit messed up and not really documented. Since you (currently) can have multiple product files in one eclipse-repository module, you need to select the product ID for which you want to apply the configuration.
So to set the archive root folder for the product with ID product.id, you need the following configuration:
<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>
<execution>
<id>archive-products</id>
<goals>
<goal>archive-products</goal>
</goals>
</execution>
</executions>
<configuration>
<products>
<product>
<id>product.id</id>
<rootFolder>myapp</rootFolder>
</product>
</products>
</configuration>
</plugin>
</plugins>
</build>
Thanks but I needed to use the rootFolder option to add the extra directory. I tried injecting achivePrefix into the .product file but that didn't work. I finally broken down, grabbed tycho source and worked backwards to find rootFolder. After this journey, I saw it in the doc and grocked the meaning.
Doc: http://wiki.eclipse.org/Tycho/Packaging_Types#Creating_Product_Zip_Files
Related: https://issues.sonatype.org/browse/TYCHO-507
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<products>
<product>
<id>match-product-uid-field-from-foo.product-file</id>
<rootFolder>workbench</rootFolder>
</product>
</products>
</configuration>
<executions>
<execution>
<!-- install the product using the p2 director -->
<id>materialize-products</id>
<goals>
<goal>materialize-products</goal>
</goals>
</execution>
<execution>
<!-- create zip file with the installed product -->
<id>archive-products</id>
<goals>
<goal>archive-products</goal>
</goals>
<configuration>
<formats>
<linux>tar.gz</linux>
<win32>zip</win32>
</formats>
</configuration>
</execution>
</executions>
</plugin>

Need to run a batch file inside Eclipse workspace

I have a workspace with multiple projects. All are Maven projects. The target directory of one of the projects contains a batch file after it is built. Now, I need one of the other projects in the workspace to run this batch file. So, I want to get the path to the current workspace programmatically without introducing new dependencies to accomplish this. Does anybody know of a way to do this?
Edit 1: I have a parent Maven project in the workspace. One of its children's target directory contians the batch file. A different child of the parent (which is a testing project) needs to run the batch file. I can use the Maven basedir variable to get the batch file which isn't pretty and doesn't work if I am running individual tests with Eclipse. So I'd like to avoid that solution.
The problem you'll have is that projects in Eclipse aren't necessarily stored in the workspace directory; they could be anywhere on the file system. This means that simply knowing where the workspace is won't necessarily help you find the batch file.
For example: my workspace is $HOME/workspace, but all my projects (the working copies) are in $HOME/code/project. Being able to determine the workspace isn't very helpful. Projects can exist outside the workspace, and still appear in Eclipse by using File -> Import.
Your best bet is probably to 'attach' the batch file to the build using the attach-artifact goal of build-helper-maven-plugin. There's an example of how to do that here.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>script.bat</file>
<type>bat</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
Then, your other project can use the copy goal of maven-dependency-plugin to resolve the script into its own directory and run it from there.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<type>bat</type>
<overWrite>true</overWrite>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/scripts</outputDirectory>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
How about the maven-antrun-plugin? It's not pretty, but it gets the job done:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id><!-- insert an id --></id>
<phase><!-- insert a maven lifecycle phase --></phase>
<configuration>
<tasks>
<exec
dir="${basedir}"
executable="${basedir}/src/main/sh/your-script.sh"
failonerror="true">
<arg line="arg1 arg2 arg3" />
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Ref: http://maven.apache.org/plugins/maven-antrun-plugin/usage.html

How to remove directories from final build zip archive using maven 3

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.