1
votes

In my tycho test project, I have an optional transitive dependency that I need to exclude for the test execution to work. That transitive dependency is part of the same reactor build.

What I have tried:

<build>
    <plugins>
        <plugin>
                    <groupId>org.eclipse.tycho</groupId>
                    <artifactId>tycho-surefire-plugin</artifactId>
                    <version>${tycho-version}</version>
                    <configuration>
                        <dependencies>
                            <plugin>
                               <groupId>org.eclipse.tycho</groupId>
                               <artifactId>target-platform-configuration</artifactId>
                               <version>${tycho-version}</version>
                               <configuration>
                                  <filters>
                                     <filter>
                                        <type>eclipse-plugin</type>
                                        <id>my.transitive.dependency</id>
                                        <removeAll />
                                     </filter>
                                  </filters>
                               </configuration>
                            </plugin>
                        </dependencies>
            </configuration>
        </plugin>
    </plugins>
  </build>

But this seems syntactically incorrect:

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:1.1.0:test (default-test) on project com.conti.xcit.generation.tests: Unable to parse configuration of mojo org.eclipse.tycho:tycho-surefire-plugin:1.1.0:test for parameter configuration: Cannot find 'configuration' in class org.apache.maven.model.Dependency -> [Help 1]

How do I achieve this exclusion?

2

2 Answers

0
votes

You can check the following link.

https://www.eclipse.org/tycho/sitedocs/tycho-surefire/tycho-surefire-plugin/test-mojo.html#excludes

You have to use exclude option.

<plugin>
  <groupId>org.eclipse.tycho</groupId>
  <artifactId>tycho-surefire-plugin</artifactId>
  <configuration>
    <excludes>
      <exclude>**/Test*.class</exclude> 
    </excludes>
  </configuration>
</plugin>
0
votes

It needs to be filtered from the target. It works both for external dependencies and dependecies that are from the build reactor.

            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>target-platform-configuration</artifactId>
                <configuration>
                    <dependency-resolution>
                        <optionalDependencies>ignore</optionalDependencies>
                    </dependency-resolution>
                    <filters>
                        <filter>
                            <type>eclipse-plugin</type>
                            <id>myExternalOptionalDependencyArtifactId</id>
                            <removeAll />
                        </filter>
                        <filter>
                            <type>eclipse-plugin</type>
                            <id>myOptionalReactorDependencyArtifactId</id>
                            <removeAll />
                        </filter>
                    </filters>
                </configuration>
            </plugin>