I have a plugin project which I am trying to create a test plugin for. The packages in my plugin project are available to other plugins in my workspace, including the test plugin, but when I try and build my projects using tycho the test plugin is throwing an error stating that the import cannot be resolved.
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.25.0:compile (default-compile) on project REDACTED.tests: Compilation failure: Compilation failure:
[ERROR] REDACTED/PlanImportTest.java:[7]
[ERROR] import REDACTED.pluginname.Argument;
[ERROR] ^^^^^^^^^^^^
[ERROR] The import REDACTED.pluginname cannot be resolved
I am new to Tycho so I think there is probably an issue with my project layout, but I can't find a solution to my problem online. Does anyone know why this import is working in eclipse but not when running a maven/tycho build on the command line? Relevant files below.
Plugin manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: REDACTED.pluginname
Bundle-SymbolicName: REDACTED.pluginname;singleton:=true
Bundle-Version: 1.0.0.qualifier
Export-Package: REDACTED
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-BuddyPolicy: registered
Eclipse-RegisterBuddy: REDACTED
Plugin POM:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>REDACTED</groupId>
<artifactId>REDACTED</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>REDACTED</relativePath>
</parent>
<groupId>REDACTED</groupId>
<artifactId>REDACTED.pluginname</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
Test class
import static org.junit.Assert.*;
import org.junit.Test;
import REDACTED.pluginname.Argument;
public class PlanImportTest {
@Test
public void test() {
Argument a = null;
assertTrue(true);
}
}
Test project manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: REDACTED
Bundle-SymbolicName: REDACTED.tests
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: REDACTED
Fragment-Host: REDACTED.pluginname;bundle-version="1.0.0.qualifier"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.junit;bundle-version="4.12.0"
Test project POM:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>REDACTED</groupId>
<artifactId>REDACTED</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>REDACTED</relativePath>
</parent>
<groupId>REDACTED</groupId>
<artifactId>REDACTED.tests</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<configuration>
<testClass>REDACTED.Test</testClass>
<dependencies>
<dependency>
<type>eclipse-plugin</type>
<groupId>REDACTED</groupId>
<artifactId>REDACTED.pluginname</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>
It turns out the problem was that my plugin to be tested was not exporting the source directory correctly. A change to the build.properties file fixed this:
Before:
bin.includes = META-INF/,\
src/
output.. = bin
After:
bin.includes = META-INF/,\
src/
source.. = src
output.. = bin
So simple but I got there in the end.