Eclipse RCP built by Tycho includes unwanted optional dependencies - dependency-management

This is a question which has been frequently asked in the Tycho community:
I migrated my Eclipse RCP build from [previous technology, e.g. eclipse-application/ PDE headless build / ...] to the new recommended way of building products with Tycho using the packaging type eclipse-repository. Now my distribution contains more bundles than before.
The problem seems to be that Tycho pulls in the optional dependencies of the bundles included in my product. How can I prevent this?

Tycho's eclipse-repository packaging type builds product distributions with the same technology (called p2) you also use when, for example, installing a new feature into your Eclipse IDE. This has the advantage that, unlike with other build technologies, you don't need to manually specify all dependencies of the bundles you want in your product, but Tycho/p2 will automatically include them for you. (This is important because otherwise the bundles would not start at runtime.)
On the other hand, this may also be a disadvantage: Tycho/p2 also includes certain optional dependencies that you would rather want to exclude from your product.
There is no option to tell Tycho to not include any optional dependencies (because p2 doesn't have this option). However you can identify the optional bundles you don't want, and explicitly exclude them from the target platform with the following configuration:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<filters>
<filter>
<type>eclipse-plugin</type>
<id>unwanted.bundle.id</id>
<removeAll />
</filter>
</filters>
</configuration>
</plugin>
Then the product build can no longer see the excluded bundle, and will omit it from the installation.
Note: If you get a dependency resolution error after adding the above configuration, there is something that non-optionally requires the bundle. Although it is a bit tricky to read, the error message will tell you the chain of dependencies that leads from something you are building to the removed bundle.

I stumbled upon this answer to exclude com.ibm.icu from my RCP build and wanted to post an update.
Tycho can be configured to ignore optional dependencies since a while, see https://wiki.eclipse.org/Tycho/Release_Notes/0.14
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tychoVersion}</version>
<configuration>
<dependency-resolution>
<optionalDependencies>ignore</optionalDependencies>
</dependency-resolution>
</configuration>

Related

How to make bit ignore a dependency file?

We have a current ReactJS project and we build a custom grid, input, error handler, etc for it.
now we start a new project and we want to share our components code between projects. we do some research and find bit platform bitsrc.io
so pleasant and good and we actually share some code between our projects with it.
the only problem is bit has a dependency checker for the import statement.
we add most of the dependency to bit lifeCycle but some of them is a config file and we want them to be different in our projects.
can anyone know the way we could ignore config import dependency to the bit?
//make bit ignore this file in dependency checking
import GeneralConfig from 'Modules/GeneralConfig/GeneralConfig'
Generally speaking, if you ignore a dependency in bit, the component will not be truly reusable. This is becasue other projects may lack a dependency for the component to function.
To ignore a missing dependency, use the --ignore-missing-dependencies for the bit tag command.
What I suggest is for you to inject the configuration to the component, rather than having the component depending on the configuration.

Recommended way to find out what Liferay module provides a class

In my Liferay module, I want to use Liferay's SomeConvenientClass.
What is the recommended way to find out what module provides that class?
So that I can quickly add it to my build.gradle.
Ideally it should either:
return the module's group/name/version,
or say with certitude that this class does not exist in Liferay or is not exported.
Until now I go by trial-and-error and copy/paste from build.gradle files found in the wild, but I am looking for a more reliable method.
I have Liferay installed, and the source code of the exact same Liferay version, if that helps.
I tried mvnrepository but it does not seem to return anything, example: https://mvnrepository.com/search?q=AuditMessageProcessor
Have you tried http://search.maven.org/#advancedsearch ?
For example:
http://search.maven.org/#search|ga|1|c:"AuditMessageProcessor"
This is more an option than a real thing, but this is how I normally do:
be familiar with package naming conventions used by liferay and
inside apps: api, service, web...
be familiar with the bundle structure used by liferay, as their
use of resource folders, which are not so obvious sometimes...
With that in mind, normally on github is enough to navigate: portal->(kernel/impl/services/apps)->app service/api/web...
But this is a natural process that comes when you spend your day inside the code.
Normally, online jar locators help, but quite often I just rely on my IDE.
On my IDE I have all set-up with Spring dependency management, after I extracted the dependencies using Gogo shell with a running bundle. With Gogo you will not find classes, but modules and packs will be listed. (Gogo is probably what you are looking for btw, as it is able to list with version numbers)
Bottom line, if you need a list as a picture of a running environment, use Gogo.
With regards to the master code, just do not trust it! When it comes to modularity and bundles versioning Liferay is pretty messy (read The dependency management problem here: https://www.e-systems.tech/blog/-/blogs/liferay-digital-experience-platform-review-7-0-ga4).
For your step 7, you will need to chose an api version and code against it. The apis are more stable. You can impose a limit for compatibility on you bnd file, which will cause the system to issue warnings. On your environment, you can catch api changes earlier, let's say, you can ask gradle to use a module with an version number but any patch (using the "+" sing), when you build with a fresh cache or if you change gradle resolution strategy to download you dependencies more frequently, if the build breaks, well, you will see it.
Helpful start point: https://dev.liferay.com/pt/develop/reference/-/knowledge_base/7-0/using-the-felix-gogo-shell
This is how I do, it is slow and manual, so don't hesitate to suggest other methods.
Download Liferay's source code if you don't have it already.
Run find . -name SomeConvenientClass.java. If nothing is found, you can be sure the class is not part of Liferay.
In the path to the class, find the src folder level, and go just under that, so for instance if it is modules/apps/collaboration/document-library/document-library-web/src/main/java/com/liferay/document/library/web/portlet/action/DLViewMVCRenderCommand.java then go to modules/apps/collaboration/document-library/document-library-web/.
Hopefully there is a bnd.bnd file there, open it.
If the package of the class is not in the Export-Package section, then either give up (duplicate Liferay's code into your module), or use some dark tricks. If you believe the class should be exported, you can explain your case at https://issues.liferay.com/browse/LPS-70480 for future generations to enjoy.
Module name is the value of Bundle-SymbolicName.
Version is the value of Bundle-Version.
Group is probably com.liferay, although sometimes it is com.liferay.portal, not sure how to tell.
Build. Sometimes it fails because Maven repositories are missing a version, for instance com.liferay.document.library.web 1.0.11 is not available despite being used by DXP fix pack 30. Not sure what to do in such cases except choosing a "similar" version and hoping for the best.

CombinedResourceHandler excluded resources doesn't recognize resources with query string

I have a couple of CSS files that I don't want to combine, but I also want to bust cache for those resources, so I declared them with:
<h:outputStylesheet name="css/styles.css?version=#{startup.time}" />
It was working fine until I added the CombineResourceHandler. Now the new handler does not recognize the name of the resource, and I cannot use a wildcard to exclude those resources, something like:
<context-param>
<param-name>org.omnifaces.COMBINED_RESOURCE_HANDLER_EXCLUDED_RESOURCES</param-name>
<param-value>css/styles.css*</param-value>
</context-param>
If I remove the version parameter I have to do versioning of those files, which is something I would like to avoid.
Any ideas on how to implement this the easiest way?
OmniFaces identifies resources by the internal ResourceIdentifier class. It didn't take into account any query strings, path parameters nor path fragments. As per this commit, this has been fixed. The fix is available in today's latest 2.2-SNAPSHOT.
Support for wildcard pattern in excluded (and suppressed) resources context param would be a good candidate for a feature request.

I want to use The GATE Predicate-Argument EXtractor Component (PAX)

I want to use The GATE Predicate-Argument EXtractor Component (PAX), but I can't figure out how to load the plugin on GATE developer (ver. 7)
Please help me.
How do I load it?
The MultiPaX plugin is a bit of a complex beast. You need to download the package from the homepage, unpack it (use something like 7-zip if you're on Windows) and then build it using Ant, which you will need to install separately - GATE used to bundle a copy of Ant but that is no longer the case since version 7. Once you have the plugin compiled and packaged you should be able to load it through the plugin manager the same as any other plugin.
However, to get anything useful out of the PR you need to build quite a complex pipeline including at least one of SUPPLE, MiniPar or the Stanford Parser PR. Getting these to work is itself a non-trivial task...
The predicate argument extractor is not developed by the core GATE team, so specific questions are probably better posted in the semanticsoftware.info forum (linked from the bottom of http://www.semanticsoftware.info/pax) rather than the usual GATE user list.

RollingFileAppender: preserve the file extension without log4net patch

M question is related to this one as I have the same problem. How can I make the RollingFileAppender of log4net preserve the file extension without having to actually "patch" (i.e. create an interim build of the current trunk) log4net? How could I achieve the same thing by overriding the RollingFileAppender or creating any other extension with the least effort?
As mentioned in my comment, you're not required to "patch" or change anything in log4net. You cannot use the 1.2.10 release, though. It is a rather old build, but the PreserveLogFileNameExtension is in the current source. You only have to bring down the source and compile the dll yourself and you're good to go.
Update: I see your concern. IMO, the only way is to make a build and test it. To further your confidence you could review the current list of resolved (and unresolved) issues for 1.2.11. I would think that seeing they are not doing a major revision, changes are mainly bug fixes and additional features.

Resources