Skip to content

Commit 11f7c9d

Browse files
committed
Improve handling of 'none' EE configuration
Signed-off-by: Christoph Läubrich <laeubi@laeubi-soft.de>
1 parent e01db7e commit 11f7c9d

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/ee/ExecutionEnvironmentResolutionHandler.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2012, 2014 SAP SE and others.
2+
* Copyright (c) 2012, 2022 SAP SE and others.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -9,6 +9,7 @@
99
*
1010
* Contributors:
1111
* SAP SE - initial API and implementation
12+
* Christoph Läubrich - #519 - Provide better feedback to the user about the cause of a failed resolution
1213
*******************************************************************************/
1314
package org.eclipse.tycho.p2.target.ee;
1415

@@ -22,16 +23,17 @@ public abstract class ExecutionEnvironmentResolutionHandler {
2223

2324
public static ExecutionEnvironmentResolutionHandler adapt(ExecutionEnvironmentConfiguration eeConfiguration) {
2425
if (eeConfiguration.ignoreExecutionEnvironment()) {
25-
return new StandardEEResolutionHandler(NoExecutionEnvironmentResolutionHints.INSTANCE);
26+
return new StandardEEResolutionHandler(NoExecutionEnvironmentResolutionHints.INSTANCE, eeConfiguration);
2627
}
2728
if (eeConfiguration.isIgnoredByResolver()) {
28-
return new StandardEEResolutionHandler(new AllKnownEEsResolutionHints(eeConfiguration.getAllKnownEEs()));
29+
return new StandardEEResolutionHandler(new AllKnownEEsResolutionHints(eeConfiguration.getAllKnownEEs()),
30+
eeConfiguration);
2931
} else if (eeConfiguration.isCustomProfile()) {
3032
// TODO consider whether custom and standard EE couldn't build their "hints" the same way
3133
return new CustomEEResolutionHandler(eeConfiguration);
3234
} else {
3335
return new StandardEEResolutionHandler(
34-
new StandardEEResolutionHints(eeConfiguration.getFullSpecification()));
36+
new StandardEEResolutionHints(eeConfiguration.getFullSpecification()), eeConfiguration);
3537
}
3638
}
3739

tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/ee/StandardEEResolutionHandler.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2012, 2014 SAP SE and others.
2+
* Copyright (c) 2012, 2022 SAP SE and others.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -9,22 +9,34 @@
99
*
1010
* Contributors:
1111
* SAP SE - initial API and implementation
12+
* Christoph Läubrich - #519 - Provide better feedback to the user about the cause of a failed resolution
1213
*******************************************************************************/
1314
package org.eclipse.tycho.p2.target.ee;
1415

1516
import java.util.Collection;
17+
import java.util.Collections;
1618

1719
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
20+
import org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration;
1821
import org.eclipse.tycho.p2.util.resolution.ExecutionEnvironmentResolutionHints;
1922

2023
class StandardEEResolutionHandler extends ExecutionEnvironmentResolutionHandler {
2124

22-
public StandardEEResolutionHandler(ExecutionEnvironmentResolutionHints resolutionHints) {
25+
private ExecutionEnvironmentConfiguration environmentConfiguration;
26+
27+
public StandardEEResolutionHandler(ExecutionEnvironmentResolutionHints resolutionHints,
28+
ExecutionEnvironmentConfiguration environmentConfiguration) {
2329
super(resolutionHints);
30+
this.environmentConfiguration = environmentConfiguration;
2431
}
2532

2633
@Override
2734
public void readFullSpecification(Collection<IInstallableUnit> targetPlatformContent) {
35+
if (environmentConfiguration.ignoreExecutionEnvironment()) {
36+
//if it is ignored not setting the specification leads to strange errors in downstream mojos...
37+
environmentConfiguration.setFullSpecificationForCustomProfile(Collections.emptyList());
38+
return;
39+
}
2840
// standard EEs are fully specified - no need to read anything from the target platform
2941
}
3042

tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentConfigurationImpl.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
public class ExecutionEnvironmentConfigurationImpl implements ExecutionEnvironmentConfiguration {
2626
// Most likely best to always be the latest known supported EE
27-
private static final String DEFAULT_EXECUTION_ENVIRONMENT = "JavaSE-" + Integer.toString(Runtime.version().feature());
27+
private static final String DEFAULT_EXECUTION_ENVIRONMENT = "JavaSE-"
28+
+ Integer.toString(Runtime.version().feature());
2829

2930
private static final int PRIMARY = 0;
3031
private static final int SECONDARY = 1;
@@ -128,7 +129,8 @@ public void setFullSpecificationForCustomProfile(List<SystemCapability> systemCa
128129
public ExecutionEnvironment getFullSpecification() throws IllegalStateException {
129130
if (isCustomProfile()) {
130131
if (customExecutionEnvironment == null) {
131-
throw new IllegalStateException("Full specification of custom profile is not (yet) determined");
132+
throw new IllegalStateException(
133+
"Full specification of custom profile '" + getProfileName() + "' is not (yet) determined");
132134
}
133135
return customExecutionEnvironment;
134136
}

tycho-its/src/test/java/org/eclipse/tycho/test/compiler/TestErrorMessages.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.apache.maven.it.VerificationException;
1818
import org.apache.maven.it.Verifier;
1919
import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
20-
import org.junit.Ignore;
2120
import org.junit.Test;
2221

2322
/**
@@ -60,16 +59,14 @@ public void testMissingBREEWithPlainProfile() throws Exception {
6059
* @throws Exception
6160
*/
6261
@Test
63-
@Ignore("This currently fails with an strange error in validate-classpath we should improve this")
6462
public void testMissingBREEWithJustJProfile() throws Exception {
6563
Verifier verifier = getVerifier("compiler.messages/missing-bree", false);
6664
verifier.addCliOption("-Pjustj");
6765
try {
6866
verifier.executeGoal("compile");
6967
fail();
7068
} catch (VerificationException e) {
71-
verifier.verifyTextInLog("java17.bundle 1.0.0 requires Execution Environment that matches");
72-
verifier.verifyTextInLog("but the current resolution context uses");
69+
verifier.verifyTextInLog("Unresolved requirement: Require-Capability: osgi.ee; filter:=");
7370
}
7471
}
7572
}

0 commit comments

Comments
 (0)