Which feature to include for bundle org.junit - eclipse-rcp

I'm refactoring my RCP app, and I'm going to use tycho as building system.
In the process, I had to rewrite my target platform so to depend on online repositories. Currently, my target is something like:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.6"?>
<target name="MyRcpApp" sequenceNumber="12">
<locations>
<location includeAllPlatforms="false" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="org.eclipse.rcp.feature.group" version="0.0.0"/>
<unit id="org.eclipse.equinox.executable.feature.group" version="0.0.0" />
<repository location="http://download.eclipse.org/releases/indigo/"/>
</location>
</locations>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
</target>
However, this target does not provide the bundle for junit tests (org.junit)... hence my eclipse has a lot of errors (due to the missing junit) and my build fails.
Does somebody know which unit should I include? (or, better, how can I get the list of all the unit available at a given repository?)

you will need the JDT feature (unfortunately there is no smaller feature I know of which includes junit)
<unit id="org.eclipse.jdt.feature.group" version="0.0.0"/>
Another option is to include single bundle IUs (the .target file format supports this but the target editor UI does not). In this case you need to make sure that transitive dependencies are also added. Try adding
<unit id="org.junit" version="0.0.0"/>
<unit id="org.hamcrest.core" version="0.0.0"/>

Related

Tycho cannot download from official p2 repository

I have a Eclipse E4 application that is already build by Tycho. Now we are migrating the application to use Java 12. Herefore we also need to update our target file.
The latest target file looks like:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target includeMode="feature" name="Running Platform">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="http://download.eclipse.org/nattable/releases/1.5.0/repository/"/>
<unit id="org.eclipse.nebula.widgets.nattable.core.feature.feature.group" version="1.5.0.201703192131"/>
<unit id="org.eclipse.nebula.widgets.nattable.extension.e4.feature.feature.group" version="1.1.0.201703192131"/>
<unit id="org.eclipse.nebula.widgets.nattable.extension.glazedlists.feature.feature.group" version="1.5.0.201703192131"/>
<unit id="org.eclipse.nebula.widgets.nattable.extension.nebula.feature.feature.group" version="1.1.0.201703192131"/>
<unit id="org.eclipse.nebula.widgets.nattable.extension.poi.feature.feature.group" version="1.5.0.201703192131"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="http://download.eclipse.org/releases/2019-06/"/>
<unit id="org.eclipse.equinox.sdk.feature.group" version="3.18.0.v20190528-1257"/>
<unit id="org.eclipse.platform.sdk" version="4.12.0.I20190605-1800"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="http://download.eclipse.org/nebula/releases/latest"/>
<unit id="org.eclipse.nebula.widgets.pshelf.css.feature.feature.group" version="1.0.0.201812241324"/>
<unit id="org.eclipse.nebula.widgets.pshelf.feature.feature.group" version="1.0.0.201812241324"/>
</location>
</locations>
<environment>
<arch>x86_64</arch>
<os>win32</os>
<ws>win32</ws>
<nl>en_US</nl>
</environment>
</target>
When we run the build with tycho using Jenkins we are getting following error:
[INFO] Fetching p2.index from http://download.eclipse.org/nattable/releases/1.5.0/repository/
[INFO] Fetching p2.index from http://download.eclipse.org/nattable/releases/1.5.0/repository/
[INFO] Adding repository http://download.eclipse.org/nattable/releases/1.5.0/repository
[INFO] Fetching p2.index from http://download.eclipse.org/releases/2019-06/
[INFO] Fetching p2.index from http://download.eclipse.org/releases/2019-06/
[INFO] Adding repository http://download.eclipse.org/releases/2019-06
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.ecf.provider.filetransfer.httpclient4.SNIAwareHttpClient$1 (file:/C:/Users/PTITDevTools_svc/.m2/repository/org/eclipse/tycho/tycho-bundles-external/1.1.0/eclipse/plugins/org.eclipse.ecf.provider.filetransfer.httpclient4_1.1.200.v20170314-0133.jar) to method sun.security.ssl.SSLSocketImpl.setHost(java.lang.String)
WARNING: Please consider reporting this to the maintainers of org.eclipse.ecf.provider.filetransfer.httpclient4.SNIAwareHttpClient$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[ERROR] Failed to resolve target definition D:\Software\x64\Jenkins\workspace\ture_ILMV-490-migrate-to-java-12\neon\neon.target: Failed to load p2 metadata repository from location http://download.eclipse.org/releases/2019-06/: Unable to read repository at http://download.eclipse.org/releases/2019-06. Unable to read repository at https://download.eclipse.org/technology/epp/packages/2019-06/content.xml. Connection reset -> [Help 1]
With our old Target file the build was working but the old file was a PDE target file. Can someone tell me why this is failing?
The url of the Eclipse p2 repo was not specific enough.
I changed http://download.eclipse.org/releases/2019-06/ to http://download.eclipse.org/releases/2019-06/201906191000

"Missing requirements" when defining an Eclipse target platform with RAP and Teneo

I created a target file and added the RAP target platform and a local folder with some proprietary bundles. When I tried to add the other dependencies for Teneo and Hibernate as stated in this tutorial, some dependencies for Teneo are not satisfied.
This is my target definition file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?><target name="server.platform" sequenceNumber="222">
<locations>
<location path="<My_bundles_dir>" type="Directory"/>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.rap.examples.feature.feature.group" version="2.3.0.20140602-1108"/>
<unit id="org.eclipse.rap.feature.feature.group" version="2.3.0.20140610-0925"/>
<unit id="org.eclipse.rap.sdk.feature.feature.group" version="2.3.0.20140610-0925"/>
<unit id="org.eclipse.rap.equinox.target.feature.feature.group" version="2.3.0.20140608-1653"/>
<repository location="http://download.eclipse.org/rt/rap/2.3/R-20140610-0925/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.hibernate.feature.group" version="4.1.1.201310261216"/>
<unit id="org.hsqldb.feature.group" version="2.2.8.201310261216"/>
<unit id="com.db4o.feature.group" version="7.4.155.v20120928-1733"/>
<unit id="org.apache.log4j.feature.group" version="1.2.16.201310261216"/>
<unit id="org.dom4j.feature.group" version="1.6.1.201310261216"/>
<unit id="org.apache.commons.logging.feature.group" version="1.1.1.201310261216"/>
<unit id="org.postgresql.feature.group" version="9.0.0.201310261216"/>
<unit id="com.mysql.jdbc.feature.group" version="5.1.11.201310261216"/>
<unit id="javax.persistence.feature.group" version="2.0.1.201310261216"/>
<unit id="com.microsoft.sqlserver.jdbc.feature.group" version="3.0.1301.201310261216"/>
<repository location="http://www.elver.org/eclipse/2.0.0/update"/>
</location>
</locations>
</target>
I'm getting the following error:
Missing requirement: EMF Common UI 2.9.0.v20140519-0339 (org.eclipse.emf.common.ui.feature.group 2.9.0.v20140519-0339) requires 'org.eclipse.ui 0.0.0' but it could not be found
... requires 'org.eclipse.ui 0.0.0' but it could not be found
The problem with your target definition is that you don't specify any p2 repository that contains this dependency. So you e.g. need to add Luna release train repository: http://download.eclipse.org/releases/luna
The PDE editor is not particularly helpful when it comes to adding p2 repositories which are only needed for dependencies. But you can resort to using a text editor to modify the target file. Here is what you need to do to add a p2 repository for adding dependencies:
Copy one of the location lines with type="InstallableUnit" and paste it below the last closing location tag (</location>).
Add the repository, e.g. with
<repository location="http://download.eclipse.org/releases/luna"/>
Add a closing repository tag.
Increment the sequenceNumber attribute in the root element.
Save the file and open it with the Target Definition Editor again. Dependencies to artifacts in the newly added repository can now be resolved.

Google Guice update site

I am trying to use com.google.inject in my application. Initialy I added as a jar, but now that I am building my application I need Guice to be part of my target definition. What is Google Guice update site URL that I can use in my target definition?
You could use the xtext 'orbit' update-site, which contains google inject :
<location includeAllPlatforms="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="com.google.guava" version="0.0.0"/>
<unit id="com.google.inject" version="0.0.0"/>
<unit id="org.apache.log4j" version="0.0.0"/>
<unit id="org.aopalliance" version="0.0.0"/>
<unit id="org.easymock" version="0.0.0"/>
<unit id="org.antlr.runtime" version="0.0.0"/>
<unit id="org.junit" version="0.0.0"/>
<unit id="javax.inject" version="0.0.0"/>
<unit id="org.apache.ant" version="0.0.0"/>
<unit id="org.objectweb.asm" version="0.0.0"/>
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20180606145124/repository/"/>
</location>
If you're using a build tool like maven or gradle, you can include it as a dependency. For example, here's how you could do it with gradle:
compile 'com.google.inject:guice:4.0'
This will pull in javax.inject which has the standard inject annotation, as a dependency.

Eclipse Ant task p2.composite.repository not honoring append=false

I'm using the docs at
http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fp2_repositorytasks.htm
I'm trying to setup a build file like this
<?xml version="1.0" encoding="UTF-8"?><project name="osgi.composite.p2">
<target name="osgi.composite.p2">
<p2.composite.repository>
<repository append="false" location="/d01/osgi/DS_5000_10_0_0" name="DS_5000_10_0_0 Composite"/>
<add>
<repository location="DS_5000_10_0_0.HEAD.1308021100.8500"/>
<repository location="thirdparty"/>
<repository location="e4"/>
<repository location="../nebula/"/>
<repository location="../integration/FUSION_DS_5000_8_3_0_SSO/"/>
</add>
</p2.composite.repository>
</target>
</project>
to overwrite the P2 composite index by running
/d01/sandboxes/baron/eclipse/4.3/eclipse -nosplash -application org.eclipse.ant.core.antRunner -buildfile composite.p2-8500.xml osgi.composite.p2
And instead of creating a new composite index it's appending the new entries listed in the build file to the compositeContent.jar, but properly replacing the entries in the compositeArtifacts.jar.

Ivy resolves jersey-servlet from Ant but not IvyDE

I'm trying to build a restful server using Apache Jersey. I'm developing in Eclipse Indigo and using Ivy for dependency management with this ivy.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!--=========================================================================-->
<!--
-->
<!--=========================================================================-->
<ivy-module version="2.2">
<info organisation="com.mypackage" module="mymodule"/>
<dependencies>
<dependency org="com.sun.jersey" name="jersey-servlet" rev="1.12"/>
</dependencies>
</ivy-module>
This resolves fine calling ivy from ant, but from IvyDE I get this error
Some projects fail to be resolved
Impossible to resolve dependencies of com.mypackage#mymodule;working#Samsung-Windows
unresolved dependency: org.jboss.weld#weld-spi;1.1.4.Final: not found
unresolved dependency: javax.annotation#jsr250-api;${jsr250.api.version}: not found
unresolved dependency: org.jboss.weld#weld-api;1.1.4.Final: not found
unresolved dependency: javax.inject#javax.inject;${atinject.api.version}: not found
unresolved dependency: org.jboss.spec.javax.interceptor#jboss-interceptors-api_1.1_spec;${interceptor.api.version}: not found
To me the ${atinject.api.version} looks like it is somehow not resolving variables correctly somewhere.
My understanding of Ivy is very superficial, so I don't have any good ideas.
Both IvyDE and ant are using the same ivysettings.xml file (at least, I believe they are).
<?xml version="1.0" encoding="UTF-8"?>
<!--=========================================================================-->
<!--=========================================================================-->
<ivysettings>
<settings defaultResolver="ibiblio"/>
<resolvers>
<ibiblio name="ibiblio" m2compatible="true"/>
<ibiblio name="maven2" m2compatible="true"/>
<ibiblio name="java-net-maven1" root="http://download.java.net/maven/1" pattern="${java.net.maven.pattern}" m2compatible="false"/>
<ibiblio name="java-net-maven2" root="http://download.java.net/maven/2/" m2compatible="true"/>
</resolvers>
</ivysettings>
Any direction would be great.
Thanks a lot in advance.
Edit: Adding portion of Build.xml
I'm using apache-ivy-2.2.0 although the output claims:
[ivy:configure] :: Apache Ivy 2.3.0-rc1 - 20120416000235 :: http://ant.apache.org/ivy/ ::
This is the build.xml:
<?xml version="1.0"?>
<project name="IvyTest" default="ivy.retrieve" xmlns:ivy="antlib:org.apache.ivy.ant">
<description>
IvyTest
</description>
<!--=====================================================================-->
<!-- Properties -->
<!--=====================================================================-->
<!-- General properties. -->
<property name="bin" location="bin" />
<property name="lib" location="lib" />
<property name="lib.ivy" location="${lib}/ivy-managed" />
<property name="ivy.version" value="2.2.0" />
<property name="ivy.home" location="${bin}/apache-ivy-${ivy.version}" />
<available property="ivy.installed" file="${ivy.home}/ivy-${ivy.version}.jar" />
<property name="ant.build.javac.source" value="1.7" />
<property name="ant.build.javac.target" value="1.7" />
<!--=====================================================================-->
<!-- Targets: Ivy -->
<!--=====================================================================-->
<!--============================ ivy.download ===========================-->
<target name="ivy.download" unless="ivy.installed">
<mkdir dir="${ivy.home}"/>
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar" dest="${ivy.home}/ivy-${ivy.version}.jar" usetimestamp="true"/>
</target>
<!--============================ ivy.init ===============================-->
<target name="ivy.init" depends="ivy.download">
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${ivy.home}/ivy-${ivy.version}.jar"/>
</target>
<!--============================ ivy.resolve ============================-->
<target name="ivy.resolve" description="Resolve dependencies with Ivy" depends="ivy.configure">
<ivy:resolve />
</target>
<!--============================ ivy.retrieve ===========================-->
<target name="ivy.retrieve" description="Retrieve dependencies with Ivy" depends="ivy.configure">
<ivy:retrieve log="verbose" pattern="${lib.ivy}/[artifact]-[revision].[ext]" type="jar,bundle" sync="true"/>
</target>
<!--============================ ivy.configure ==========================-->
<target name="ivy.configure" description="Configure Ivy settings file" depends="ivy.init">
<ivy:configure file="ivysettings.xml"/>
</target>
<!--============================ ivy.clean ==============================-->
<target name="ivy.clean" description="Cleans the Ivy cache" depends="ivy.init">
<ivy:cleancache />
</target>
</project>
By default ivy will download dependencies from Maven Central, so unless you're using your own Maven repository manager you won't need an ivy settings file.
Having said that it's good practice to declare one and the following works fine for me:
<ivysettings>
<settings defaultResolver="central"/>
<resolvers>
<ibiblio name="central" m2compatible="true"/>
</resolvers>
</ivysettings>
Notice it's a lot simpler than your example. The old java.net repositories are not really used anymore, most (if not all) of their content has been migrated to Maven Central.
As an update to your original question:
I also had the situation that I could resolve on the console using ant resolve but IvyDe (under Eclipse 4.2) was giving me the error "Impossible to resolve dependencies [...]"
Lead through this post I managed to edit IvyDE's settings (Workspace Preferences -> Ivy -> Settings) and add an ivysettings.properties file with this content:
ivy.home=${user.home}/.ant
ivy.jar.dir=${ivy.home}/lib
ivy.jar.file=${ivy.jar.dir}/ivy.jar
From now on everything worked fine.