Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion java/java.openjdk.project/release/scripts/build-generic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ SUPPORTED_ACTIONS: build,build-fast,clean,rebuild
<target name="build">
<exec executable="make" dir="${basedir}" failonerror="true">
<arg value="images" />
<arg line="${nb.extra.make.targets}" />
<env key="CONF" value="${CONF}" />
</exec>
</target>
<target name="build-fast">
<exec executable="make" dir="${basedir}" failonerror="true">
<arg value="default" />
<arg value="exploded-image" />
<arg line="${nb.extra.make.targets}" />
<env key="CONF" value="${CONF}" />
</exec>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ public class BuildUtils {

private BuildUtils() {}

public static File findTargetJavaHome(FileObject file) {
public static File findTargetJavaHome(FileObject file, boolean fullImage) {
File buildDir = getBuildTargetDir(file);

if (buildDir != null) {
File candidate = new File(buildDir, "images/j2sdk-image");

if (candidate.isDirectory()) {
return candidate;
} else if (fullImage) {
return new File(new File(buildDir, "images"), "jdk");
} else {
return new File(buildDir, "jdk");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ public void invokeAction(String command, Lookup context) throws IllegalArgumentE
createAndRunTest(context, command);
}

private static final String COMMAND_BUILD_FAST = "build-fast";
private static final String COMMAND_BUILD_GENERIC_FAST = "build-generic-fast";
static final String COMMAND_BUILD_FAST = "build-fast";
static final String COMMAND_BUILD_GENERIC_FAST = "build-generic-fast";

//public for test
@Messages({"# {0} - simple file name",
Expand Down Expand Up @@ -191,12 +191,15 @@ public void run() {
redebug.disable();
Project prj = FileOwnerQuery.getOwner(file);
ActionProvider prjAP = prj != null ? prj.getLookup().lookup(ActionProvider.class) : null;
if (prjAP != null) {
Settings settings = prj != null ? prj.getLookup().lookup(Settings.class) : null;
boolean useAntBuild = settings != null ? settings.isUseAntBuild(): false;
boolean useFullImage = settings != null ? settings.isTestUseImage() : false;
if (prjAP != null && (settings == null || settings.getRunBuildSetting() != Settings.RunBuild.NEVER)) {
Lookup targetContext = Lookup.EMPTY;
Set<String> supported = new HashSet<>(Arrays.asList(prjAP.getSupportedActions()));
String toRun = null;
for (String command : new String[] {idealBuildTarget(file), ActionProvider.COMMAND_BUILD}) {

for (String command : beforeTestProjectBuildTargets(file, useAntBuild, useFullImage)) {
if (supported.contains(command) && prjAP.isActionEnabled(command, targetContext)) {
toRun = command;
break;
Expand Down Expand Up @@ -257,7 +260,7 @@ public String[] getExtraMakeTargets() {
ClassPath extraSourcePath = allSources(file);
final ClassPath fullSourcePath = ClassPathSupport.createProxyClassPath(testSourcePath, extraSourcePath);
List<String> options = new ArrayList<>();
File targetJavaHome = BuildUtils.findTargetJavaHome(file);
File targetJavaHome = BuildUtils.findTargetJavaHome(file, useFullImage);
options.add(new File(new File(targetJavaHome, "bin"), "java").getAbsolutePath());
options.add("-jar");
options.add(jtregJar.getAbsolutePath());
Expand Down Expand Up @@ -347,7 +350,6 @@ public String[] getExtraMakeTargets() {
case 5: //error
//check if it is a version error:
if (errorOutput.toString().contains("jtreg version")) {
Settings settings = prj.getLookup().lookup(Settings.class);
String jtregLocation = settings.getJTregLocation();
InputLine nd = new InputLine(Bundle.LBL_IncorrectVersionSelectJTReg(), Bundle.TITLE_IncorrectVersionSelectJTReg(), NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.ERROR_MESSAGE);
nd.setInputText(jtregLocation);
Expand Down Expand Up @@ -604,14 +606,19 @@ public void outputLineCleared(OutputEvent ev) {}
}
}

static String idealBuildTarget(FileObject testFile) {
static String[] beforeTestProjectBuildTargets(FileObject testFile, boolean useAntBuild, boolean useFullImage) {
Project prj = FileOwnerQuery.getOwner(testFile);
FileObject repo = prj.getProjectDirectory().getParent().getParent();
String repoName = ShortcutUtils.getDefault().inferLegacyRepository(prj);
if (ShortcutUtils.getDefault().shouldUseCustomTest(repoName, FileUtil.getRelativePath(repo, testFile))) {
return COMMAND_BUILD_FAST;
if (ShortcutUtils.getDefault().shouldUseCustomTest(repoName, FileUtil.getRelativePath(repo, testFile)) && useAntBuild) {
//make "ant" build override the "useFullImage" w.r.t. building;
//if useFullImage == true, tests will run using a full JDK image,
//but will still patch in the custom built classes:
return new String[] {COMMAND_BUILD_FAST, COMMAND_BUILD};
} else if (useFullImage) {
return new String[] {COMMAND_BUILD};
} else {
return COMMAND_BUILD_GENERIC_FAST;
return new String[] {COMMAND_BUILD_GENERIC_FAST, COMMAND_BUILD};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,6 @@ public void invokeAction(String command, Lookup context) throws IllegalArgumentE
}
}
if (COMMAND_BUILD_GENERIC_FAST.equals(command)) {
switch (settings.getRunBuildSetting()) {
case NEVER:
ActionProgress.start(context).finished(true);
return;
case ALWAYS:
default:
break;
}
scriptFO = genericScript;
command = COMMAND_BUILD_FAST; //XXX: should only do this if genericScript supports it
}
Expand All @@ -222,7 +214,7 @@ public void invokeAction(String command, Lookup context) throws IllegalArgumentE
: repository.getParent();
props.put("basedir", FileUtil.toFile(basedirFO).getAbsolutePath());
props.put("CONF", project.configurations.getActiveConfiguration().getLocation().getName());
props.put("nb.jdk.project.target.java.home", BuildUtils.findTargetJavaHome(project.getProjectDirectory()).getAbsolutePath());
props.put("nb.jdk.project.target.java.home", BuildUtils.findTargetJavaHome(project.getProjectDirectory(), false).getAbsolutePath());
props.put("nb.extra.make.targets", extraTargets);
RootKind kind = getKind(context);
RunSingleConfig singleFileProperty = command2Properties.get(Pair.of(command, kind));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class Settings {

private static final String KEY_BUILD_BEFORE_TESTS = "build-before-test";
private static final String KEY_JTREG_LOCATION = "jtreg-location";
private static final String KEY_TEST_USE_IMAGE = "test-use-image";
private static final String KEY_USE_ANT_BUILD = "use-langtools-ant-build";
private static final String KEY_ANT_BUILD_LOCATION = "langtools-ant-build-location";

Expand Down Expand Up @@ -76,6 +77,14 @@ public void setUseAntBuild(boolean useAntBuild) {
getPrivatePreferences().putBoolean(KEY_USE_ANT_BUILD, useAntBuild);
}

public boolean isTestUseImage() {
return getPrivatePreferences().getBoolean(KEY_TEST_USE_IMAGE, false);
}

public void setTestUseImage(boolean useImage) {
getPrivatePreferences().putBoolean(KEY_TEST_USE_IMAGE, useImage);
}

public String getAntBuildLocation() {
return getPrivatePreferences().get(KEY_ANT_BUILD_LOCATION, DEF_ANT_BUILD_LOCATION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ TestCategory.jtregLocation.text=
BuildCategory.antBuildLocation.text=
BuildCategory.useAntBuild.text=Use ant build for langtools
BuildCategory.antBuildLocationLabel.text=Ant build location:
TestCategory.useFullImage.text=Use full JDK image to run tests
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buildBeforeTestLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buildBeforeTest" pref="173" max="32767" attributes="0"/>
<Component id="jtregLocation" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buildBeforeTestLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buildBeforeTest" pref="173" max="32767" attributes="0"/>
<Component id="jtregLocation" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="useFullImage" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
Expand All @@ -63,7 +71,9 @@
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jtregLocation" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="227" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="useFullImage" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="187" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down Expand Up @@ -107,5 +117,12 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="useFullImage">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/java/openjdk/project/customizer/Bundle.properties" key="TestCategory.useFullImage.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form>
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ public class TestCategory extends javax.swing.JPanel {
/**
* Creates new form TestCategory
*/
public TestCategory(RunBuild runBuild, String jtregLocation) {
public TestCategory(RunBuild runBuild, String jtregLocation, boolean testUseImage) {
initComponents();
this.buildBeforeTest.getModel().setSelectedItem(runBuild);
this.jtregLocation.setText(jtregLocation);
this.useFullImage.setSelected(testUseImage);
}

/**
Expand All @@ -63,6 +64,7 @@ private void initComponents() {
buildBeforeTest = new javax.swing.JComboBox<>();
jLabel1 = new javax.swing.JLabel();
jtregLocation = new javax.swing.JTextField();
useFullImage = new javax.swing.JCheckBox();

buildBeforeTestLabel.setLabelFor(buildBeforeTest);
org.openide.awt.Mnemonics.setLocalizedText(buildBeforeTestLabel, org.openide.util.NbBundle.getMessage(TestCategory.class, "TestCategory.buildBeforeTestLabel.text")); // NOI18N
Expand All @@ -75,19 +77,26 @@ private void initComponents() {

jtregLocation.setText(org.openide.util.NbBundle.getMessage(TestCategory.class, "TestCategory.jtregLocation.text")); // NOI18N

org.openide.awt.Mnemonics.setLocalizedText(useFullImage, org.openide.util.NbBundle.getMessage(TestCategory.class, "TestCategory.useFullImage.text")); // NOI18N

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buildBeforeTestLabel)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buildBeforeTest, 0, 173, Short.MAX_VALUE)
.addComponent(jtregLocation))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buildBeforeTestLabel)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buildBeforeTest, 0, 173, Short.MAX_VALUE)
.addComponent(jtregLocation)))
.addGroup(layout.createSequentialGroup()
.addComponent(useFullImage)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
Expand All @@ -101,7 +110,9 @@ private void initComponents() {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jtregLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(227, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addComponent(useFullImage)
.addContainerGap(187, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents

Expand All @@ -111,6 +122,7 @@ private void initComponents() {
private javax.swing.JLabel buildBeforeTestLabel;
private javax.swing.JLabel jLabel1;
private javax.swing.JTextField jtregLocation;
private javax.swing.JCheckBox useFullImage;
// End of variables declaration//GEN-END:variables

private ListCellRenderer<Object> runBuildRenderer() {
Expand Down Expand Up @@ -153,10 +165,11 @@ public Category createCategory(Lookup context) {
@Override
public JComponent createComponent(Category category, Lookup context) {
Settings settings = context.lookup(Settings.class);
TestCategory panel = new TestCategory(settings.getRunBuildSetting(), settings.getJTregLocation());
TestCategory panel = new TestCategory(settings.getRunBuildSetting(), settings.getJTregLocation(), settings.isTestUseImage());
category.setOkButtonListener(evt -> {
settings.setRunBuildSetting((RunBuild) panel.buildBeforeTest.getSelectedItem());
settings.setJTregLocation(panel.jtregLocation.getText());
settings.setTestUseImage(panel.useFullImage.isSelected());
});
category.setStoreListener(evt -> settings.flush());
return panel;
Expand Down
Loading
Loading