blob: fefd3a9d43c0c4b6d5a54f8d2a49bce9c004faec [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* derived from corresponding file in org.eclipse.jdt.ui.tests.core
* instead extending TestSetup for junit4 ExternalResource is extended
* to allow use as junit "@Rule"
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.ui.tests.core.rules;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
public class Java9ProjectTestSetup extends ProjectTestSetup {
public Java9ProjectTestSetup() {
super("TestSetupProject9", JavaProjectHelper.RT_STUBS_9);
}
public Java9ProjectTestSetup(String projectname) {
super(projectname, JavaProjectHelper.RT_STUBS_9);
}
@Override
public IClasspathEntry[] getDefaultClasspath() throws CoreException {
IPath[] rtJarPath= JavaProjectHelper.findRtJar(ipath);
return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2],
null,
new IClasspathAttribute[] {JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, "true")},
true) };
}
@Override
protected IJavaProject createAndInitializeProject() throws CoreException {
IJavaProject javaProject= super.createAndInitializeProject();
JavaProjectHelper.set9CompilerOptions(javaProject);
return javaProject;
}
}