Skip to content

Commit

Permalink
#37 add support for 'lib' classpath entries
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Läubrich <laeubi@laeubi-soft.de>
  • Loading branch information
laeubi committed May 20, 2021
1 parent 236fcd3 commit 71ff6c4
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public synchronized Collection<ProjectClasspathEntry> getEntries() throws IOExce
} else {
list.add(new JDTContainerClasspathEntry(path, attributes));
}
} else if ("lib".equals(kind)) {
String path = classpathentry.getAttribute("path");
list.add(new JDTLibraryClasspathEntry(new File(file.getParentFile(), path), attributes));
}
}
entries = Collections.unmodifiableList(list);
Expand Down Expand Up @@ -216,9 +219,9 @@ public String getContainerPath() {

private static final class JDTSourceFolder implements SourceFolderClasspathEntry {

private File path;
private Map<String, String> attributes;
private File output;
private final File path;
private final Map<String, String> attributes;
private final File output;

public JDTSourceFolder(File path, File output, Map<String, String> attributes) {
this.path = path;
Expand All @@ -243,4 +246,26 @@ public Map<String, String> getAttributes() {

}

private static final class JDTLibraryClasspathEntry implements LibraryClasspathEntry {

private final File path;
private final Map<String, String> attributes;

public JDTLibraryClasspathEntry(File path, Map<String, String> attributes) {
this.path = path;
this.attributes = attributes;
}

@Override
public Map<String, String> getAttributes() {
return attributes;
}

@Override
public File getLibraryPath() {
return path;
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*******************************************************************************
* Copyright (c) 2021 Christoph Läubrich and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christoph Läubrich - initial API and implementation
*******************************************************************************/
package org.eclipse.tycho.core.dotClasspath;

import java.io.File;

public interface LibraryClasspathEntry extends ProjectClasspathEntry {

/**
*
* @return the library path name
*/
File getLibraryPath();

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.eclipse.tycho.core.TychoProject;
import org.eclipse.tycho.core.dotClasspath.ClasspathParser;
import org.eclipse.tycho.core.dotClasspath.JUnitClasspathContainerEntry;
import org.eclipse.tycho.core.dotClasspath.LibraryClasspathEntry;
import org.eclipse.tycho.core.dotClasspath.ProjectClasspathEntry;
import org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils;
import org.eclipse.tycho.core.ee.StandardExecutionEnvironment;
Expand Down Expand Up @@ -478,6 +479,13 @@ private void addExtraClasspathEntries(List<ClasspathEntry> classpath, ReactorPro
}
}
}
for (ProjectClasspathEntry entry : pdeProject.getClasspathEntries()) {
if (entry instanceof LibraryClasspathEntry) {
LibraryClasspathEntry libraryClasspathEntry = (LibraryClasspathEntry) entry;
ArtifactKey projectKey = getArtifactKey(project);
classpath.add(new DefaultClasspathEntry(project, projectKey, Collections.singletonList(libraryClasspathEntry.getLibraryPath()), null));
}
}
}

protected DefaultClasspathEntry addBundleToClasspath(ArtifactDescriptor matchingBundle, String path) {
Expand Down
12 changes: 12 additions & 0 deletions tycho-its/projects/compiler.libentry/my.bundle/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/osgi.annotation-7.0.0.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: My Bundle
Bundle-SymbolicName: my.bundle
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: my.bundle
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: my.bundle;version="1.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
Binary file not shown.
20 changes: 20 additions & 0 deletions tycho-its/projects/compiler.libentry/my.bundle/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>my.bundle</artifactId>
<groupId>org.eclipse.tycho.it</groupId>
<packaging>eclipse-plugin</packaging>
<version>1.0.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package my.bundle;

import org.osgi.annotation.versioning.ProviderType;

@ProviderType
public interface SampleClass1 {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@Version("1.0.0")
package my.bundle;

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@
import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
import org.junit.Test;

public class CompilerJunitContainerTest extends AbstractTychoIntegrationTest {
public class CompilerClasspathEntryTest extends AbstractTychoIntegrationTest {

@Test
public void testJUnit4Container() throws Exception {
Verifier verifier = getVerifier("compiler.junitcontainer/junit4-in-bundle", true);
verifier.executeGoal("test");
verifier.verifyErrorFreeLog();
}

public void testLibEntry() throws Exception {
Verifier verifier = getVerifier("compiler.libentry/my.bundle", false);
verifier.executeGoal("compile");
verifier.verifyErrorFreeLog();
}
}

0 comments on commit 71ff6c4

Please sign in to comment.