diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d09a1cc088..03288825506 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,13 +36,10 @@ jobs: mvn --batch-mode --global-toolchains ${{ github.workspace }}/.github/toolchains.xml - -Pbuild-individual-bundles -Pbree-libs -Papi-check -Dmaven.test.failure.ignore=true - -Dcompare-version-with-baselines.skip=false - -Dproject.build.sourceEncoding=UTF-8 - -DtrimStackTrace=false + -Dmaven.test.error.ignore=true clean verify - name: Upload Test Results uses: actions/upload-artifact@v3 diff --git a/.github/workflows/updateRelease.yml b/.github/workflows/updateRelease.yml new file mode 100644 index 00000000000..65c0d04541a --- /dev/null +++ b/.github/workflows/updateRelease.yml @@ -0,0 +1,12 @@ +name: Update to next release +on: + milestone: + types: [created] + +jobs: + update: + if: contains(github.event.milestone.description, 'Release') + permissions: + pull-requests: write + contents: write + uses: eclipse-platform/eclipse.platform.releng.aggregator/.github/workflows/updateRelease.yml@master diff --git a/.gitignore b/.gitignore index 8d2a92c638d..5e62e80724a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,5 +12,5 @@ Snap.* # maven /*/*/target/ .DS_Store -.polyglot.META-INF -.polyglot.feature.xml +.polyglot.* +pom.tycho diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index c1ea2a73118..1d69f034cda 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -4,6 +4,6 @@ org.eclipse.tycho tycho-build - 3.0.0 + 3.0.3 \ No newline at end of file diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 00000000000..ffe18b8db09 --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1,4 @@ +-Pbuild-individual-bundles +-Dcompare-version-with-baselines.skip=false +-DtrimStackTrace=false +--fail-at-end diff --git a/Jenkinsfile b/Jenkinsfile index f5151ccbf87..6b999a85690 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,28 +6,29 @@ pipeline { timestamps() } agent { - label "centos-latest" + label 'centos-latest' } tools { maven 'apache-maven-latest' - jdk 'openjdk-jdk17-latest' + jdk 'temurin-jdk17-latest' } stages { stage('Build') { steps { wrap([$class: 'Xvnc', useXauthority: true]) { - sh """ - mvn clean verify --batch-mode --fail-at-end -Dmaven.repo.local=$WORKSPACE/.m2/repository \ - -Pbuild-individual-bundles -Pbree-libs -Papi-check \ - -Dcompare-version-with-baselines.skip=false \ - -Dproject.build.sourceEncoding=UTF-8 \ - -DtrimStackTrace=false - """ + sh ''' + mvn clean verify --batch-mode -Dmaven.repo.local=$WORKSPACE/.m2/repository \ + -Pbree-libs -Papi-check \ + -Dmaven.test.error.ignore=true -Dmaven.test.failure.ignore=true + ''' } } post { always { - archiveArtifacts artifacts: '*.log,*/target/work/data/.metadata/*.log,*/tests/target/work/data/.metadata/*.log,apiAnalyzer-workspace/.metadata/*.log', allowEmptyArchive: true + archiveArtifacts(allowEmptyArchive: true, artifacts: '*.log, \ + */target/work/data/.metadata/*.log, \ + */tests/target/work/data/.metadata/*.log, \ + apiAnalyzer-workspace/.metadata/*.log') publishIssues issues:[scanForIssues(tool: java()), scanForIssues(tool: mavenConsole())] junit '**/target/surefire-reports/*.xml' } diff --git a/README.md b/README.md index 9227479390c..2ee711a59b8 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ How to build on the command line You need Maven 3.3.1 or later installed. Then you can run the build via the following command: -`mvn clean verify -Pbuild-individual-bundles` +`mvn clean verify` Contact: -------- diff --git a/apitools/org.eclipse.pde.api.tools.annotations/.classpath b/apitools/org.eclipse.pde.api.tools.annotations/.classpath index eca7bdba8f0..e801ebfb468 100644 --- a/apitools/org.eclipse.pde.api.tools.annotations/.classpath +++ b/apitools/org.eclipse.pde.api.tools.annotations/.classpath @@ -1,6 +1,6 @@ - + diff --git a/apitools/org.eclipse.pde.api.tools.annotations/.settings/org.eclipse.jdt.core.prefs b/apitools/org.eclipse.pde.api.tools.annotations/.settings/org.eclipse.jdt.core.prefs index c0350f8bf7b..3b7088a180c 100644 --- a/apitools/org.eclipse.pde.api.tools.annotations/.settings/org.eclipse.jdt.core.prefs +++ b/apitools/org.eclipse.pde.api.tools.annotations/.settings/org.eclipse.jdt.core.prefs @@ -15,9 +15,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -33,6 +33,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=error @@ -89,6 +90,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled @@ -121,11 +123,13 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL,HIGH,HIGH org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX,EXPERIMENTAL,CONTEXTLAUNCHING org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -133,17 +137,20 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 @@ -229,11 +236,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert @@ -264,6 +272,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert @@ -288,13 +298,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert @@ -342,6 +356,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert @@ -378,9 +394,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert @@ -406,8 +425,12 @@ org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=false org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore org.eclipse.jdt.core.incompleteClasspath=error diff --git a/apitools/org.eclipse.pde.api.tools.annotations/META-INF/MANIFEST.MF b/apitools/org.eclipse.pde.api.tools.annotations/META-INF/MANIFEST.MF index 05a2bb98fb5..63af07856ce 100644 --- a/apitools/org.eclipse.pde.api.tools.annotations/META-INF/MANIFEST.MF +++ b/apitools/org.eclipse.pde.api.tools.annotations/META-INF/MANIFEST.MF @@ -1,8 +1,8 @@ Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.pde.api.tools.annotations;singleton:=true -Bundle-Version: 1.1.500.qualifier +Bundle-Version: 1.2.0.qualifier Bundle-Vendor: %Bundle-Vendor -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-RequiredExecutionEnvironment: JavaSE-11 Export-Package: org.eclipse.pde.api.tools.annotations Automatic-Module-Name: org.eclipse.pde.api.tools.annotations diff --git a/apitools/org.eclipse.pde.api.tools.tests/.classpath b/apitools/org.eclipse.pde.api.tools.tests/.classpath index a42a828e04a..675a5e2962b 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/.classpath +++ b/apitools/org.eclipse.pde.api.tools.tests/.classpath @@ -1,6 +1,6 @@ - + diff --git a/apitools/org.eclipse.pde.api.tools.tests/.settings/org.eclipse.jdt.core.prefs b/apitools/org.eclipse.pde.api.tools.tests/.settings/org.eclipse.jdt.core.prefs index 9d74d43e411..55f27875490 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/.settings/org.eclipse.jdt.core.prefs +++ b/apitools/org.eclipse.pde.api.tools.tests/.settings/org.eclipse.jdt.core.prefs @@ -19,9 +19,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -137,7 +137,7 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL,HIGH,HIGH org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX,EXPERIMENTAL,CONTEXTLAUNCHING diff --git a/apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF b/apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF index ebd2f71ef14..e44166ca8ea 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF +++ b/apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.pde.api.tools.tests -Bundle-Version: 1.2.800.qualifier +Bundle-Version: 1.3.0.qualifier Bundle-Vendor: %Bundle-Vendor Require-Bundle: org.eclipse.core.runtime, org.junit, @@ -21,7 +21,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.jdt.core.tests.compiler;bundle-version="[3.8.0,4.0.0)", org.eclipse.ant.core, org.eclipse.pde.ui.tests -Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Export-Package: org.eclipse.pde.api.tools.anttasks.tests, org.eclipse.pde.api.tools.apiusescan.tests, org.eclipse.pde.api.tools.applications, diff --git a/apitools/org.eclipse.pde.api.tools.tests/build.properties b/apitools/org.eclipse.pde.api.tools.tests/build.properties index d2e51748a36..9ef2dc2cc6f 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/build.properties +++ b/apitools/org.eclipse.pde.api.tools.tests/build.properties @@ -20,6 +20,7 @@ bin.includes = META-INF/,\ test-jars/,\ test-manifests/,\ test-nested-jars/,\ + test-nested-jars-2/,\ test-plugins/,\ test-source/,\ test-stubs/,\ diff --git a/apitools/org.eclipse.pde.api.tools.tests/pom.xml b/apitools/org.eclipse.pde.api.tools.tests/pom.xml index 96239824869..36cf3b85a3a 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/pom.xml +++ b/apitools/org.eclipse.pde.api.tools.tests/pom.xml @@ -14,11 +14,11 @@ org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT ../../ org.eclipse.pde.api.tools.tests - 1.2.800-SNAPSHOT + 1.3.0-SNAPSHOT eclipse-test-plugin -warn:-discouraged diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/ApiBuilderTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/ApiBuilderTest.java index 1acfe92148d..170a75a53c5 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/ApiBuilderTest.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/ApiBuilderTest.java @@ -72,7 +72,6 @@ import org.eclipse.ui.dialogs.IOverwriteQuery; import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider; import org.eclipse.ui.wizards.datatransfer.ImportOperation; -import org.junit.BeforeClass; import org.osgi.service.prefs.BackingStoreException; import junit.framework.Test; @@ -96,11 +95,6 @@ public abstract class ApiBuilderTest extends BuilderTests { public static final String BIN_ROOT = "bin"; //$NON-NLS-1$ protected final int[] NO_PROBLEM_IDS = new int[0]; - @BeforeClass - public static void beforeClass() { - PDECore.getDefault().getPreferencesManager().setValue(ICoreConstants.RUN_API_ANALYSIS_AS_JOB, false); - } - /** * Describes a line number mapped to the problem id with the given args we * expect to see there @@ -171,11 +165,6 @@ protected ApiTestingEnvironment getEnv() { return (ApiTestingEnvironment) env; } - @BeforeClass - public static void setUpBeforeClass() throws Exception { - ApiTestingEnvironment.setTargetPlatform(); - } - /** * Verifies that the workspace has no problems. */ @@ -1026,10 +1015,12 @@ protected void enableExternalDependencyCheckOptions(boolean enabled) { @Override protected void setUp() throws Exception { FreezeMonitor.expectCompletionInAMinute(); + PDECore.getDefault().getPreferencesManager().setValue(ICoreConstants.RUN_API_ANALYSIS_AS_JOB, false); if (env == null) { env = new ApiTestingEnvironment(); env.openEmptyWorkspace(); env.setAutoBuilding(false); + ApiTestingEnvironment.setTargetPlatform(); } setBuilderOptions(); super.setUp(); diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/ApiTestingEnvironment.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/ApiTestingEnvironment.java index 90c1c6bf048..4f62461798e 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/ApiTestingEnvironment.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/ApiTestingEnvironment.java @@ -36,8 +36,11 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.tests.builder.TestingEnvironment; import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; +import org.eclipse.pde.api.tools.internal.ApiBaselineManager; import org.eclipse.pde.api.tools.internal.builder.ApiAnalysisBuilder; +import org.eclipse.pde.api.tools.internal.model.WorkspaceBaseline; import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; +import org.eclipse.pde.api.tools.internal.provisional.IApiBaselineManager; import org.eclipse.pde.api.tools.internal.provisional.IApiMarkerConstants; import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline; import org.eclipse.pde.api.tools.model.tests.TestSuiteHelper; @@ -507,6 +510,15 @@ protected IApiBaseline getWorkspaceProfile() { return ApiPlugin.getDefault().getApiBaselineManager().getWorkspaceBaseline(); } + public static void dispose(IApiBaseline apiBaseline) { + if (apiBaseline instanceof WorkspaceBaseline) { + IApiBaselineManager apiBaselineManager = ApiPlugin.getDefault().getApiBaselineManager(); + ((ApiBaselineManager) apiBaselineManager).disposeWorkspaceBaseline(); + } else if (apiBaseline != null) { + apiBaseline.dispose(); + } + } + @Override public ApiProblem[] getProblemsFor(IPath path, String additionalMarkerType) { IMarker[] markers = getMarkersFor(path, additionalMarkerType); diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/OSGiLessAnalysisTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/OSGiLessAnalysisTests.java index 377e87697fd..1e00a47ce79 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/OSGiLessAnalysisTests.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/OSGiLessAnalysisTests.java @@ -72,7 +72,7 @@ public void testAnalyzer() throws CoreException { assertEquals( "Mismatch in problems reported by analyzer.getProblems, returned values:" + Arrays.toString(problems), //$NON-NLS-1$ expectedIds, Arrays.stream(problems).map(IApiProblem::getId).collect(Collectors.toSet())); - baseline.dispose(); - current.dispose(); + ApiTestingEnvironment.dispose(baseline); + ApiTestingEnvironment.dispose(current); } } diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/BundleMergeSplitTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/BundleMergeSplitTests.java index ce2b8c1da50..981e260c781 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/BundleMergeSplitTests.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/BundleMergeSplitTests.java @@ -99,11 +99,11 @@ protected void tearDown() throws Exception { IApiBaselineManager manager = ApiPlugin.getDefault().getApiBaselineManager(); manager.setDefaultApiBaseline(null); manager.removeApiBaseline(API_BASELINE); - this.baseline.dispose(); + ApiTestingEnvironment.dispose(this.baseline); this.baseline = null; IApiBaseline wsbaseline = manager.getWorkspaceBaseline(); if (wsbaseline != null) { - wsbaseline.dispose(); + ApiTestingEnvironment.dispose(wsbaseline); } for (IProject project : getEnv().getWorkspace().getRoot().getProjects()) { getEnv().removeProject(project.getFullPath()); diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/BundleVersionTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/BundleVersionTests.java index 4c8df65b3fc..9b06b408394 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/BundleVersionTests.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/BundleVersionTests.java @@ -115,8 +115,8 @@ protected void tearDown() throws Exception { IApiBaselineManager manager = ApiPlugin.getDefault().getApiBaselineManager(); manager.setDefaultApiBaseline(null); manager.removeApiBaseline(API_BASELINE); - this.baseline.dispose(); - manager.getWorkspaceBaseline().dispose(); + ApiTestingEnvironment.dispose(this.baseline); + ApiTestingEnvironment.dispose(manager.getWorkspaceBaseline()); this.baseline = null; for (IProject project : getEnv().getWorkspace().getRoot().getProjects()) { getEnv().removeProject(project.getFullPath()); diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/performance/PerformanceTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/performance/PerformanceTest.java index 55ca69c529a..774ecce5ba9 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/performance/PerformanceTest.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/performance/PerformanceTest.java @@ -20,6 +20,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceDescription; import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -216,8 +217,10 @@ protected void createInitialWorkspace() throws Exception { IEclipsePreferences antuiprefs = InstanceScope.INSTANCE.getNode("org.eclipse.ant.ui"); //$NON-NLS-1$ antuiprefs.put("errorDialog", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - workspace.getDescription().setSnapshotInterval(Long.MAX_VALUE); - workspace.getDescription().setAutoBuilding(false); + IWorkspaceDescription description = workspace.getDescription(); + description.setSnapshotInterval(Long.MAX_VALUE); + description.setAutoBuilding(false); + workspace.setDescription(description); // Get projects directories long start = System.currentTimeMillis(); diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/DependentUsageTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/DependentUsageTests.java index 79dec87c3dc..61a7112be94 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/DependentUsageTests.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/DependentUsageTests.java @@ -87,6 +87,7 @@ protected IPath getTestSource(String test) { * @throws Exception if something bad happens */ protected void deployTest(String test, IPath usepath, IPath refpath, String refname, boolean addtag) throws Exception { + boolean autoBuilding = getEnv().getWorkspace().isAutoBuilding(); try { getEnv().setAutoBuilding(false); //copy source files and build @@ -117,7 +118,9 @@ protected void deployTest(String test, IPath usepath, IPath refpath, String refn } } finally { - getEnv().setAutoBuilding(true); + if (autoBuilding) { + getEnv().setAutoBuilding(true); + } } } diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/comparator/tests/DeltaTestSetup.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/comparator/tests/DeltaTestSetup.java index 53a5e09f202..401457b7a4d 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/comparator/tests/DeltaTestSetup.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/comparator/tests/DeltaTestSetup.java @@ -26,6 +26,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.pde.api.tools.builder.tests.ApiTestingEnvironment; import org.eclipse.pde.api.tools.internal.builder.BuilderMessages; import org.eclipse.pde.api.tools.internal.provisional.comparator.ApiComparator; import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta; @@ -214,12 +215,8 @@ public void setUp() throws Exception { @After public void tearDown() throws Exception { //clean up - if(this.after != null) { - this.after.dispose(); - } - if(this.before != null) { - this.before.dispose(); - } + ApiTestingEnvironment.dispose(this.after); + ApiTestingEnvironment.dispose(this.before); // remove workspace root assertTrue(TestSuiteHelper.delete(new File(WORKSPACE_ROOT.toOSString()))); FreezeMonitor.done(); diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ApiBaselineTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ApiBaselineTests.java index a7b11c6a4b6..f419a666b55 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ApiBaselineTests.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ApiBaselineTests.java @@ -21,7 +21,10 @@ import java.io.FileNotFoundException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; import org.eclipse.core.runtime.CoreException; import org.eclipse.pde.api.tools.internal.BundleVersionRange; @@ -215,6 +218,36 @@ public void testNestedJarComponent() throws CoreException { assertEquals("Wrong type name", "component.a.A", file.getTypeName()); //$NON-NLS-1$ //$NON-NLS-2$ } + /** + * Ensures nested jar file names with identical file names are handled + * correctly + *

+ * https://github.com/eclipse-pde/eclipse.pde/issues/473 + */ + @Test + public void testIdenticalNestedJarFileNamesAreHandledCorrectly() throws CoreException { + IApiBaseline baseline1 = TestSuiteHelper.createTestingBaseline("test-nested-jars"); //$NON-NLS-1$ + IApiBaseline baseline2 = TestSuiteHelper.createTestingBaseline("test-nested-jars-2"); //$NON-NLS-1$ + IApiComponent componentA1 = baseline1.getApiComponent(COMPONENT_A); + IApiComponent componentA2 = baseline2.getApiComponent(COMPONENT_A); + assertNotNull("missing component.a", componentA1); //$NON-NLS-1$ + assertNotNull("missing component.a", componentA2); //$NON-NLS-1$ + Set packages1 = Arrays.stream(componentA1.getApiTypeContainers()).map(ApiBaselineTests::getPackageNames) + .flatMap(Arrays::stream).collect(Collectors.toSet()); + Set packages2 = Arrays.stream(componentA2.getApiTypeContainers()).map(ApiBaselineTests::getPackageNames) + .flatMap(Arrays::stream).collect(Collectors.toSet()); + assertEquals(Set.of("component.a"), packages1); //$NON-NLS-1$ + assertEquals(Set.of("component.a", "component.a2"), packages2); //$NON-NLS-1$ //$NON-NLS-2$ + } + + private static String[] getPackageNames(IApiTypeContainer c) { + try { + return c.getPackageNames(); + } catch (CoreException e) { + throw new RuntimeException(e); + } + } + /** * Tests that an x-friends directive works. Component A exports package * component.a.friend.of.b as a friend for b. Note - the package should diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ApiDescriptionTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ApiDescriptionTests.java index ed370e91cda..2c3ff64748e 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ApiDescriptionTests.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ApiDescriptionTests.java @@ -29,6 +29,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.core.Signature; +import org.eclipse.pde.api.tools.builder.tests.ApiTestingEnvironment; import org.eclipse.pde.api.tools.internal.ApiDescription; import org.eclipse.pde.api.tools.internal.ApiDescriptionProcessor; import org.eclipse.pde.api.tools.internal.ApiDescriptionXmlCreator; @@ -351,7 +352,7 @@ public void endVisitElement(IElementDescriptor element, IApiAnnotations descript component.getApiDescription().accept(visitor, null); assertTrue("Visit incomplete", visitOrder.isEmpty()); //$NON-NLS-1$ - baseline.dispose(); + ApiTestingEnvironment.dispose(baseline); } /** diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ComponentManifestTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ComponentManifestTests.java index 34b18cca22a..1790a39d02e 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ComponentManifestTests.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/ComponentManifestTests.java @@ -23,6 +23,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; +import org.eclipse.pde.api.tools.builder.tests.ApiTestingEnvironment; import org.eclipse.pde.api.tools.internal.BundleVersionRange; import org.eclipse.pde.api.tools.internal.RequiredComponentDescription; import org.eclipse.pde.api.tools.internal.model.ApiModelFactory; @@ -72,7 +73,7 @@ public void testComponentManifest() throws CoreException { assertEquals("Wrong required component", reqs.get(i), requiredComponents[i]); //$NON-NLS-1$ } } finally { - baseline.dispose(); + ApiTestingEnvironment.dispose(baseline); } } @@ -100,7 +101,7 @@ public void testReExport() throws CoreException { assertTrue("org.eclipse.debug.core should be re-exported", debugCoreExport); //$NON-NLS-1$ assertFalse("Other components should not be re-exported", others); //$NON-NLS-1$ } finally { - baseline.dispose(); + ApiTestingEnvironment.dispose(baseline); } } } diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/search/tests/SearchTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/search/tests/SearchTest.java index 1cf0a8a0eaa..41ae1be64d9 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/search/tests/SearchTest.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/search/tests/SearchTest.java @@ -22,6 +22,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.pde.api.tools.builder.tests.ApiTestingEnvironment; import org.eclipse.pde.api.tools.internal.model.ApiModelFactory; import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline; import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent; @@ -175,12 +176,8 @@ public void setUp() throws Exception { @After public void tearDown() throws Exception { - if (this.baseline != null) { - this.baseline.dispose(); - } - if (this.scope != null) { - this.scope.dispose(); - } + ApiTestingEnvironment.dispose(this.baseline); + ApiTestingEnvironment.dispose(this.scope); FreezeMonitor.done(); } } diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/tests/AbstractApiTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/tests/AbstractApiTest.java index 9b3ede8f018..036ca43b945 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/tests/AbstractApiTest.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/tests/AbstractApiTest.java @@ -21,6 +21,7 @@ import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceDescription; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; @@ -34,6 +35,7 @@ import org.eclipse.ltk.core.refactoring.CreateChangeOperation; import org.eclipse.ltk.core.refactoring.PerformChangeOperation; import org.eclipse.ltk.core.refactoring.Refactoring; +import org.eclipse.pde.api.tools.builder.tests.ApiTestingEnvironment; import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline; import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent; @@ -195,7 +197,7 @@ protected void deleteProject(String name) throws CoreException { if (name == null) { return; } - getWorkspaceBaseline().dispose(); + ApiTestingEnvironment.dispose(getWorkspaceBaseline()); IProject pro = getProject(name); if (pro.exists()) { ResourceEventWaiter waiter = new ResourceEventWaiter(new Path(name), IResourceChangeEvent.POST_CHANGE, @@ -227,7 +229,13 @@ protected IApiBaseline getWorkspaceBaseline() { } @BeforeClass - public static void beforeClass() { + public static void beforeClass() throws CoreException { PDECore.getDefault().getPreferencesManager().setValue(ICoreConstants.RUN_API_ANALYSIS_AS_JOB, false); + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + if (workspace.isAutoBuilding()) { + IWorkspaceDescription description = workspace.getDescription(); + description.setAutoBuilding(false); + workspace.setDescription(description); + } } } diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/util/tests/ApiBaselineManagerTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/util/tests/ApiBaselineManagerTests.java index fb063dea66f..533750f0905 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/util/tests/ApiBaselineManagerTests.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/util/tests/ApiBaselineManagerTests.java @@ -57,6 +57,7 @@ import org.eclipse.jdt.core.dom.rewrite.ListRewrite; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; +import org.eclipse.pde.api.tools.builder.tests.ApiTestingEnvironment; import org.eclipse.pde.api.tools.internal.ApiBaselineManager; import org.eclipse.pde.api.tools.internal.model.ApiModelFactory; import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; @@ -895,7 +896,7 @@ public void setUp() throws Exception { @After public void tearDown() throws Exception { deleteProject(TESTING_PLUGIN_PROJECT_NAME); - getWorkspaceBaseline().dispose(); + ApiTestingEnvironment.dispose(getWorkspaceBaseline()); super.tearDown(); } } diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/util/tests/UtilTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/util/tests/UtilTests.java index 442a14c99b5..aba4dbde919 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/util/tests/UtilTests.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/util/tests/UtilTests.java @@ -474,7 +474,7 @@ public boolean isDisposed() { "org.eclipse.equinox.p2.core", //$NON-NLS-1$ "org.eclipse.debug.ui", //$NON-NLS-1$ "org.eclipse.ui.navigator", //$NON-NLS-1$ - "javax.servlet.jsp", //$NON-NLS-1$ + "javax.servlet.jsp-api", //$NON-NLS-1$ "org.eclipse.ui.workbench", //$NON-NLS-1$ "org.eclipse.equinox.event", //$NON-NLS-1$ "org.eclipse.jdt.core", //$NON-NLS-1$ diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-nested-jars-2/component.a_2.0.0.jar b/apitools/org.eclipse.pde.api.tools.tests/test-nested-jars-2/component.a_2.0.0.jar new file mode 100644 index 00000000000..d795bf42728 Binary files /dev/null and b/apitools/org.eclipse.pde.api.tools.tests/test-nested-jars-2/component.a_2.0.0.jar differ diff --git a/apitools/org.eclipse.pde.api.tools.ui/META-INF/MANIFEST.MF b/apitools/org.eclipse.pde.api.tools.ui/META-INF/MANIFEST.MF index 8e6c7a2187a..a1b6a22e333 100644 --- a/apitools/org.eclipse.pde.api.tools.ui/META-INF/MANIFEST.MF +++ b/apitools/org.eclipse.pde.api.tools.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.pde.api.tools.ui; singleton:=true -Bundle-Version: 1.2.700.qualifier +Bundle-Version: 1.2.800.qualifier Bundle-Localization: plugin Eclipse-LazyStart: true Bundle-ActivationPolicy: lazy @@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)", org.eclipse.jdt.core;bundle-version="[3.27.0,4.0.0)", org.eclipse.pde.ui;bundle-version="[3.4.0,4.0.0)", org.eclipse.pde.api.tools;bundle-version="1.0.600", - org.eclipse.ui;bundle-version="[3.4.0,4.0.0)", + org.eclipse.ui;bundle-version="[3.202.0,4.0.0)", org.eclipse.jdt.ui;bundle-version="[3.8.0,4.0.0)", org.eclipse.jface.text;bundle-version="[3.4.0,4.0.0)", org.eclipse.ui.forms;bundle-version="[3.3.100,4.0.0)", diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/ApiQuickFixProcessor.java b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/ApiQuickFixProcessor.java index dae7ca9ac91..3860e8a55af 100644 --- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/ApiQuickFixProcessor.java +++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/ApiQuickFixProcessor.java @@ -27,9 +27,6 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.Signature; @@ -83,19 +80,10 @@ public UnknownAnnotationQuickFix(ICompilationUnit unit, String qualifiedname) { @Override public void apply(IDocument document) { - UIJob job = new UIJob("Update project to use API Tools annotations") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - try { - Change changes = createChange(fUnit, fName); - changes.perform(monitor); - - } catch (CoreException e) { - ApiUIPlugin.log(e); - } - return Status.OK_STATUS; - } - }; + Job job = UIJob.create("Update project to use API Tools annotations", monitor -> { //$NON-NLS-1$ + Change changes = createChange(fUnit, fName); + changes.perform(monitor); + }); job.setPriority(Job.INTERACTIVE); job.schedule(); } diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/ConfigureProblemSeverityForAPIToolsResolution.java b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/ConfigureProblemSeverityForAPIToolsResolution.java index dfb42485b1a..fa6a57fa121 100644 --- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/ConfigureProblemSeverityForAPIToolsResolution.java +++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/ConfigureProblemSeverityForAPIToolsResolution.java @@ -14,15 +14,12 @@ package org.eclipse.pde.api.tools.ui.internal.markers; import java.text.MessageFormat; -import java.util.HashMap; import java.util.HashSet; import java.util.Map; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; @@ -130,52 +127,36 @@ public int getRelevance() { } @Override - public void run(IMarker[] markers, IProgressMonitor monitor) { - - UIJob job = new UIJob("") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - // Configure problem severity for missing baseline - // This doesn't have project specific option - if (fBackingMarker.getAttribute(IApiMarkerConstants.API_MARKER_ATTR_ID, - -1) == IApiMarkerConstants.DEFAULT_API_BASELINE_MARKER_ID) { - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - int id = ApiProblemFactory.getProblemId(fBackingMarker); - String type =ApiBaselinePreferencePage.MISSING_BASELINE_OPTION; - if (id > -1) { - if (id == ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_API_BASELINE, - IElementDescriptor.RESOURCE, IApiProblem.API_PLUGIN_NOT_PRESENT_IN_BASELINE, - IApiProblem.NO_FLAGS)) { - type =ApiBaselinePreferencePage.MISSING_PLUGIN_IN_BASELINE_OPTION; - } - - } - Map data = new HashMap<>(); - - data.put(ApiBaselinePreferencePage.DATA_SELECT_OPTION_KEY, - type); - PreferencesUtil - .createPreferenceDialogOn(shell, IApiToolsConstants.ID_BASELINES_PREF_PAGE, null, data) - .open(); - - return Status.OK_STATUS; + public void run(IMarker[] markers, IProgressMonitor m) { + UIJob job = UIJob.create("", monitor -> { //$NON-NLS-1$ + // Configure problem severity for missing baseline + // This doesn't have project specific option + if (fBackingMarker.getAttribute(IApiMarkerConstants.API_MARKER_ATTR_ID, + -1) == IApiMarkerConstants.DEFAULT_API_BASELINE_MARKER_ID) { + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + int id = ApiProblemFactory.getProblemId(fBackingMarker); + String type = ApiBaselinePreferencePage.MISSING_BASELINE_OPTION; + if (id > -1 && id == ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_API_BASELINE, + IElementDescriptor.RESOURCE, IApiProblem.API_PLUGIN_NOT_PRESENT_IN_BASELINE, + IApiProblem.NO_FLAGS)) { + type = ApiBaselinePreferencePage.MISSING_PLUGIN_IN_BASELINE_OPTION; } - // Configure problem severity for API Error/Warning( Usage Error, API compatibility error, API - // version error, since tag error, analysis option etc ) + Map data = Map.of(ApiBaselinePreferencePage.DATA_SELECT_OPTION_KEY, type); + PreferencesUtil.createPreferenceDialogOn(shell, IApiToolsConstants.ID_BASELINES_PREF_PAGE, null, data) + .open(); + } else { + // Configure problem severity for API Error/Warning( Usage + // Error, API compatibility error, API version error, since tag + // error, analysis option etc ) IJavaProject project = JavaCore.create(fBackingMarker.getResource().getProject()); int id = ApiProblemFactory.getProblemId(fBackingMarker); int tab = -1; String key = null; key = Util.getAPIToolPreferenceKey(id); tab = Util.getAPIToolPreferenceTab(id); - PDEConfigureProblemSeverityAction problemSeverityAction = new PDEConfigureProblemSeverityAction( - project, key , - tab); - problemSeverityAction.run(); - return Status.OK_STATUS; + new PDEConfigureProblemSeverityAction(project, key, tab).run(); } - - }; + }); job.setSystem(true); job.schedule(); } diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/DefaultApiProfileResolution.java b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/DefaultApiProfileResolution.java index 429c7f2ec9d..f7972284f54 100644 --- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/DefaultApiProfileResolution.java +++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/DefaultApiProfileResolution.java @@ -14,13 +14,11 @@ package org.eclipse.pde.api.tools.ui.internal.markers; import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin; import org.eclipse.pde.api.tools.ui.internal.IApiToolsConstants; import org.eclipse.pde.api.tools.ui.internal.SWTFactory; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IMarkerResolution2; import org.eclipse.ui.progress.UIJob; @@ -49,13 +47,10 @@ public String getLabel() { @Override public void run(IMarker marker) { - UIJob job = new UIJob(MarkerMessages.DefaultApiProfileResolution_2) { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - SWTFactory.showPreferencePage(ApiUIPlugin.getShell(), IApiToolsConstants.ID_BASELINES_PREF_PAGE, null); - return Status.OK_STATUS; - } - }; + UIJob job = UIJob.create(MarkerMessages.DefaultApiProfileResolution_2, monitor -> { + Shell shell = ApiUIPlugin.getShell(); + SWTFactory.showPreferencePage(shell, IApiToolsConstants.ID_BASELINES_PREF_PAGE, null); + }); job.setSystem(true); job.schedule(); } diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/OpenPropertyPageResolution.java b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/OpenPropertyPageResolution.java index 46c1da587a3..d07d1a18cfc 100644 --- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/OpenPropertyPageResolution.java +++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/OpenPropertyPageResolution.java @@ -16,15 +16,13 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.osgi.util.NLS; import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin; import org.eclipse.pde.api.tools.ui.internal.IApiToolsConstants; import org.eclipse.pde.api.tools.ui.internal.SWTFactory; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IMarkerResolution2; import org.eclipse.ui.progress.UIJob; @@ -81,13 +79,10 @@ public String getLabel() { @Override public void run(IMarker marker) { - UIJob job = new UIJob(MarkerMessages.OpenPropertyPageResolution_opening_property_page_job_name) { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - SWTFactory.showPropertiesDialog(ApiUIPlugin.getShell(), fPageId, fElement, null); - return Status.OK_STATUS; - } - }; + UIJob job = UIJob.create(MarkerMessages.OpenPropertyPageResolution_opening_property_page_job_name, monitor -> { + Shell shell = ApiUIPlugin.getShell(); + SWTFactory.showPropertiesDialog(shell, fPageId, fElement, null); + }); job.setSystem(true); job.setPriority(Job.INTERACTIVE); job.schedule(); diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/ProblemExplainIncompatibilityResolution.java b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/ProblemExplainIncompatibilityResolution.java index ccc73f5e9a9..5c25266a729 100644 --- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/ProblemExplainIncompatibilityResolution.java +++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/ProblemExplainIncompatibilityResolution.java @@ -19,8 +19,6 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.pde.api.tools.internal.problems.ApiProblemFactory; import org.eclipse.pde.api.tools.internal.provisional.IApiMarkerConstants; import org.eclipse.pde.api.tools.internal.util.Util; @@ -28,6 +26,7 @@ import org.eclipse.pde.api.tools.ui.internal.IApiToolsConstants; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.help.IWorkbenchHelpSystem; import org.eclipse.ui.progress.UIJob; import org.eclipse.ui.views.markers.WorkbenchMarkerResolution; @@ -77,20 +76,15 @@ public String getLabel() { } @Override - public void run(IMarker[] markers, IProgressMonitor monitor) { + public void run(IMarker[] markers, IProgressMonitor m) { // Since only 1 page is made as of now , so for all explain // incompatibilities we can show the same page. However in future if the // pages are split, from marker we can get the type of incompatibility // and show different page URL. - UIJob job = new UIJob("") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - PlatformUI.getWorkbench().getHelpSystem() - .displayHelpResource("/org.eclipse.pde.doc.user/reference/api-tooling/api_evolution.htm"); //$NON-NLS-1$ - - return Status.OK_STATUS; - } - }; + UIJob job = UIJob.create("", monitor -> { //$NON-NLS-1$ + IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); + helpSystem.displayHelpResource("/org.eclipse.pde.doc.user/reference/api-tooling/api_evolution.htm"); //$NON-NLS-1$ + }); job.setSystem(true); job.schedule(); } diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/SinceTagResolution.java b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/SinceTagResolution.java index da4e7bfc332..5bcd15b0ecf 100644 --- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/SinceTagResolution.java +++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/markers/SinceTagResolution.java @@ -16,9 +16,6 @@ import java.util.HashSet; import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.jdt.ui.ISharedImages; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.osgi.util.NLS; @@ -85,20 +82,14 @@ public void run(final IMarker marker) { } else { title = NLS.bind(MarkerMessages.SinceTagResolution_add_since_tag, this.newVersionValue); } - UIJob job = new UIJob(title) { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - SinceTagResolution.this.kind = ApiProblemFactory - .getProblemKind(marker.getAttribute(IApiMarkerConstants.MARKER_ATTR_PROBLEM_ID, 0)); - SinceTagResolution.this.newVersionValue = marker.getAttribute(IApiMarkerConstants.MARKER_ATTR_VERSION, - null); - UpdateSinceTagOperation updateSinceTagOperation = new UpdateSinceTagOperation(marker, otherMarkers, - SinceTagResolution.this.kind, - marker.getAttribute(IApiMarkerConstants.MARKER_ATTR_VERSION, null)); - updateSinceTagOperation.run(monitor); - return Status.OK_STATUS; - } - }; + UIJob job = UIJob.create(title, monitor -> { + this.kind = ApiProblemFactory + .getProblemKind(marker.getAttribute(IApiMarkerConstants.MARKER_ATTR_PROBLEM_ID, 0)); + this.newVersionValue = marker.getAttribute(IApiMarkerConstants.MARKER_ATTR_VERSION, null); + UpdateSinceTagOperation updateSinceTagOperation = new UpdateSinceTagOperation(marker, otherMarkers, + this.kind, marker.getAttribute(IApiMarkerConstants.MARKER_ATTR_VERSION, null)); + updateSinceTagOperation.run(monitor); + }); job.setSystem(true); job.schedule(); } diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/use/ApiUseScanJob.java b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/use/ApiUseScanJob.java index 1e060688cd6..1e691b687dd 100644 --- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/use/ApiUseScanJob.java +++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/use/ApiUseScanJob.java @@ -60,7 +60,6 @@ import org.eclipse.pde.core.target.TargetBundle; import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.progress.UIJob; @@ -184,7 +183,7 @@ protected IStatus run(IProgressMonitor monitor) { } catch (CoreException e) { return e.getStatus(); - } + } return Status.OK_STATUS; } @@ -380,20 +379,11 @@ void performReportCreation(int reportType, boolean cleanh, String hlocation, Str if (openhtml) { final File index = converter.getReportIndex(); if (index != null) { - UIJob ujob = new UIJob(Util.EMPTY_STRING) { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - IEditorDescriptor edesc = null; - try { - edesc = IDE.getEditorDescriptor(index.getName(), true, true); - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - IDE.openEditor(window.getActivePage(), index.toURI(), edesc.getId(), true); - } catch (PartInitException e) { - e.printStackTrace(); - } - return Status.OK_STATUS; - } - }; + UIJob ujob = UIJob.create(Util.EMPTY_STRING, m -> { + IEditorDescriptor edesc = IDE.getEditorDescriptor(index.getName(), true, true); + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IDE.openEditor(window.getActivePage(), index.toURI(), edesc.getId(), true); + }); ujob.setPriority(Job.INTERACTIVE); ujob.setSystem(true); ujob.schedule(); diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/wizards/ApiToolingSetupWizardPage.java b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/wizards/ApiToolingSetupWizardPage.java index eacc3a79fe7..5edf6fb8ec7 100644 --- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/wizards/ApiToolingSetupWizardPage.java +++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/wizards/ApiToolingSetupWizardPage.java @@ -438,16 +438,13 @@ public boolean finish() { */ private void notifyNoDefaultProfile() { if (ApiPlugin.getDefault().getApiBaselineManager().getDefaultApiBaseline() == null) { - UIJob job = new UIJob("No default API profile detected") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - boolean doit = MessageDialog.openQuestion(getShell(), WizardMessages.ApiToolingSetupWizardPage_1, WizardMessages.ApiToolingSetupWizardPage_2 + WizardMessages.ApiToolingSetupWizardPage_3); - if (doit) { - SWTFactory.showPreferencePage(getShell(), IApiToolsConstants.ID_BASELINES_PREF_PAGE, null); - } - return Status.OK_STATUS; + UIJob job = UIJob.create("No default API profile detected", monitor -> { //$NON-NLS-1$ + String msg = WizardMessages.ApiToolingSetupWizardPage_2 + WizardMessages.ApiToolingSetupWizardPage_3; + if (MessageDialog.openQuestion(getShell(), WizardMessages.ApiToolingSetupWizardPage_1, msg)) { + SWTFactory.showPreferencePage(getShell(), IApiToolsConstants.ID_BASELINES_PREF_PAGE, null); } - }; + return Status.OK_STATUS; + }); job.setSystem(true); job.schedule(); } diff --git a/apitools/org.eclipse.pde.api.tools/META-INF/MANIFEST.MF b/apitools/org.eclipse.pde.api.tools/META-INF/MANIFEST.MF index 270771919cd..c2fde7b6e82 100644 --- a/apitools/org.eclipse.pde.api.tools/META-INF/MANIFEST.MF +++ b/apitools/org.eclipse.pde.api.tools/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.pde.api.tools;singleton:=true -Bundle-Version: 1.2.1100.qualifier +Bundle-Version: 1.2.1200.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.25.0,4.0.0)", diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiBaselineManager.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiBaselineManager.java index 4a8b6bc40fc..5804838d4ab 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiBaselineManager.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiBaselineManager.java @@ -648,7 +648,7 @@ public IApiBaseline getWorkspaceBaseline() { * Disposes the workspace baseline such that a new one will be created on * the next request. */ - void disposeWorkspaceBaseline() { + public void disposeWorkspaceBaseline() { if (workspacebaseline == null) { return; } diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiFileGenerationApplication.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiFileGenerationApplication.java index d11276b9739..267d72463e7 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiFileGenerationApplication.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiFileGenerationApplication.java @@ -17,10 +17,17 @@ import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; +/** + * Prefer using the tycho-apitools-plugin to generate the api description file + * + */ +@Deprecated public class ApiFileGenerationApplication implements IApplication { + private static String DEPRECATION_WARNING = "DEPRECATED, PLEASE MOVE TO THE tycho-apitools-plugin TO GENERATE THE API DESCRIPTION FILE"; //$NON-NLS-1$ @Override public Object start(IApplicationContext context) throws Exception { + ApiPlugin.logErrorMessage(DEPRECATION_WARNING); APIFileGenerator generator = new APIFileGenerator(); String[] args = (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS); generator.projectName = find("projectName", args); //$NON-NLS-1$ diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/WorkspaceDeltaProcessor.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/WorkspaceDeltaProcessor.java index 1244833c7fc..e7aeb40d549 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/WorkspaceDeltaProcessor.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/WorkspaceDeltaProcessor.java @@ -18,6 +18,8 @@ import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.ElementChangedEvent; @@ -226,6 +228,12 @@ public void resourceChanged(IResourceChangeEvent event) { System.out.println("processed PRE_BUILD delta for project: [" + resource.getName() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ } } + + if (event.getBuildKind() == IncrementalProjectBuilder.AUTO_BUILD + && !ResourcesPlugin.getWorkspace().isAutoBuilding()) { + return; + } + IResourceDelta delta = event.getDelta(); if (delta != null) { IResourceDelta[] children = delta.getAffectedChildren(IResourceDelta.CHANGED); diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TypeScope.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TypeScope.java index 1888cf1b8fc..a957f7222ad 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TypeScope.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TypeScope.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.pde.api.tools.internal.builder; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -60,22 +59,13 @@ public TypeScope(IApiComponent component, IReferenceTypeDescriptor[] types) { fPackageToTypes = new HashMap<>(); for (IReferenceTypeDescriptor type : types) { String name = type.getPackage().getName(); - Set set = fPackageToTypes.get(name); - if (set == null) { - set = new HashSet<>(); - fPackageToTypes.put(name, set); - } - set.add(type); + fPackageToTypes.computeIfAbsent(name, n -> new HashSet<>()).add(type); } } @Override public String[] getPackageNames() throws CoreException { - Set pkgs = fPackageToTypes.keySet(); - String[] result = new String[pkgs.size()]; - pkgs.toArray(result); - Arrays.sort(result); - return result; + return fPackageToTypes.keySet().stream().sorted().toArray(String[]::new); } @Override diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java index 3d80f654ac1..a7aadcecf78 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java @@ -192,9 +192,8 @@ private void checkSuperclass() { } if (superclassList2 != null) { superclassNames2 = new HashSet<>(); - Iterator iterator = superclassList2.iterator(); - while (iterator.hasNext()) { - superclassNames2.add(iterator.next().getName()); + for (IApiType type : superclassList2) { + superclassNames2.add(type.getName()); } } if (superclassList1 == null) { @@ -352,8 +351,7 @@ private void checkSuperInterfaces() { this.type1, this.type1.getName(), new String[] { Util.getDescriptorName(type1), computeDiff(superinterfacesSet1, superinterfacesSet2, true) }); if (this.type1.isInterface()) { - for (Iterator iterator = superinterfacesSet2.iterator(); iterator.hasNext();) { - IApiType type = iterator.next(); + for (IApiType type : superinterfacesSet2) { IApiMethod[] methods = type.getMethods(); int length = methods.length; if (length != 0) { @@ -399,12 +397,12 @@ private void checkSuperInterfaces() { computeDiff(superinterfacesSet1, superinterfacesSet2, false) }); } else { Set names2 = new HashSet<>(); - for (Iterator iterator = superinterfacesSet2.iterator(); iterator.hasNext();) { - names2.add(iterator.next().getName()); + for (IApiType iApiType : superinterfacesSet2) { + names2.add(iApiType.getName()); } Set names1 = new HashSet<>(); - for (Iterator iterator = superinterfacesSet1.iterator(); iterator.hasNext();) { - names1.add(iterator.next().getName()); + for (IApiType iApiType : superinterfacesSet1) { + names1.add(iApiType.getName()); } boolean contracted = false; for (String name : names1) { @@ -468,8 +466,7 @@ private void checkSuperInterfaces() { this.type1, this.type1.getName(), new String[] { Util.getDescriptorName(type1), computeDiff(superinterfacesSet1, superinterfacesSet2, true) }); if (this.type1.isInterface()) { - for (Iterator iterator = names2.iterator(); iterator.hasNext();) { - String interfaceName = iterator.next(); + for (String interfaceName : names2) { try { IApiTypeRoot interfaceClassFile = getType(interfaceName, this.component2, this.apiBaseline2); if (interfaceClassFile == null) { @@ -488,8 +485,7 @@ private void checkSuperInterfaces() { methodLoop: for (int j = 0; j < length; j++) { IApiMethod method = methods[j]; boolean found = false; - interfaceLoop: for (Iterator iterator2 = superinterfacesSet1.iterator(); iterator2.hasNext();) { - IApiType superTypeDescriptor = iterator2.next(); + interfaceLoop: for (IApiType superTypeDescriptor : superinterfacesSet1) { IApiMethod method3 = superTypeDescriptor.getMethod(method.getName(), method.getSignature()); if (method3 == null) { continue interfaceLoop; @@ -527,15 +523,15 @@ private void checkSuperInterfaces() { private String computeDiff(Set superinterfacesSet1, Set superinterfacesSet2, boolean expand) { Set namesToReturn = new HashSet<>(); if (superinterfacesSet1 == null) { - for (Iterator iterator = superinterfacesSet2.iterator(); iterator.hasNext();) { - namesToReturn.add(iterator.next().getName()); + for (IApiType iApiType : superinterfacesSet2) { + namesToReturn.add(iApiType.getName()); } return processNames(namesToReturn); } if (superinterfacesSet2 == null) { - for (Iterator iterator = superinterfacesSet1.iterator(); iterator.hasNext();) { - namesToReturn.add(iterator.next().getName()); + for (IApiType iApiType : superinterfacesSet1) { + namesToReturn.add(iApiType.getName()); } return processNames(namesToReturn); @@ -667,9 +663,8 @@ private void checkTypeMembers() throws CoreException { } } } - loop: for (Iterator iterator = removedTypeMembers.iterator(); iterator.hasNext();) { + loop: for (IApiType typeMember : removedTypeMembers) { try { - IApiType typeMember = iterator.next(); // check visibility IApiDescription apiDescription = this.component.getApiDescription(); IApiAnnotations memberTypeElementDescription = apiDescription.resolveAnnotations(typeMember.getHandle()); @@ -698,9 +693,8 @@ private void checkTypeMembers() throws CoreException { } // report remaining types as addition // Report delta as a breakage - loop: for (Iterator iterator = added.iterator(); iterator.hasNext();) { + loop: for (String name : added) { try { - String name = iterator.next(); int index = name.lastIndexOf('$'); IApiType typeMember = this.type2.getMemberType(name.substring(index + 1)); // check visibility @@ -810,20 +804,20 @@ private void checkGenericSignature(String signature1, String signature2, IApiMem List interfaceBounds2 = parameterDescriptor2.interfaceBounds; if (interfaceBounds1 == null) { if (interfaceBounds2 != null) { - for (Iterator iterator = interfaceBounds2.iterator(); iterator.hasNext();) { + for (String string : interfaceBounds2) { // report delta added interface bounds this.addDelta(IDelta.TYPE_PARAMETER_ELEMENT_TYPE, IDelta.ADDED, IDelta.INTERFACE_BOUND, this.currentDescriptorRestrictions, element1.getModifiers(), element2.getModifiers(), this.type1, name, new String[] { getDataFor(element1, type1), name, - iterator.next() }); + string }); } } } else if (interfaceBounds2 == null) { // report delta removed interface bounds - for (Iterator iterator = interfaceBounds1.iterator(); iterator.hasNext();) { + for (String string : interfaceBounds1) { // report delta added interface bounds this.addDelta(IDelta.TYPE_PARAMETER_ELEMENT_TYPE, IDelta.REMOVED, IDelta.INTERFACE_BOUND, this.currentDescriptorRestrictions, element1.getModifiers(), element2.getModifiers(), this.type1, name, new String[] { getDataFor(element1, type1), name, - iterator.next() }); + string }); } } else { int size1 = interfaceBounds1.size(); @@ -1222,8 +1216,8 @@ public IDelta getDelta(IProgressMonitor monitor) { getDeltaForField(fields1[i]); } // checks remaining fields (added fields) - for (Iterator iterator = addedFields.iterator(); iterator.hasNext();) { - IApiField field = this.type2.getField(iterator.next()); + for (String addedField : addedFields) { + IApiField field = this.type2.getField(addedField); reportFieldAddition(field, this.type2); } @@ -1241,8 +1235,8 @@ public IDelta getDelta(IProgressMonitor monitor) { getDeltaForMethod(methods1[i]); } // checks remaining methods (added methods) - for (Iterator iterator = addedMethods.iterator(); iterator.hasNext();) { - IMethodDescriptor md = (IMethodDescriptor) iterator.next(); + for (IMemberDescriptor addedMethod : addedMethods) { + IMethodDescriptor md = (IMethodDescriptor) addedMethod; IApiMethod method = this.type2.getMethod(md.getName(), md.getSignature()); reportMethodAddition(method, this.type2); } @@ -1302,8 +1296,7 @@ private void getDeltaForField(IApiField field) { if (this.type1.isInterface()) { Set interfacesSet = getInterfacesSet(this.type2); if (interfacesSet != null) { - for (Iterator iterator = interfacesSet.iterator(); iterator.hasNext();) { - IApiType superTypeDescriptor = iterator.next(); + for (IApiType superTypeDescriptor : interfacesSet) { IApiField field3 = superTypeDescriptor.getField(name); if (field3 == null) { continue; @@ -1322,8 +1315,7 @@ private void getDeltaForField(IApiField field) { } else { List superclassList = getSuperclassList(this.type2); if (superclassList != null && isStatusOk()) { - loop: for (Iterator iterator = superclassList.iterator(); iterator.hasNext();) { - IApiType superTypeDescriptor = iterator.next(); + loop: for (IApiType superTypeDescriptor : superclassList) { IApiField field3 = superTypeDescriptor.getField(name); if (field3 == null) { continue; @@ -1598,8 +1590,7 @@ private void getDeltaForMethod(IApiMethod method) { if (this.type1.isInterface()) { Set interfacesSet = getInterfacesSet(this.type2); if (interfacesSet != null && isStatusOk()) { - for (Iterator iterator = interfacesSet.iterator(); iterator.hasNext();) { - IApiType superTypeDescriptor = iterator.next(); + for (IApiType superTypeDescriptor : interfacesSet) { IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor); if (method3 == null) { continue; @@ -1618,8 +1609,7 @@ private void getDeltaForMethod(IApiMethod method) { } else { List superclassList = getSuperclassList(this.type2, true); if (superclassList != null && isStatusOk()) { - loop: for (Iterator iterator = superclassList.iterator(); iterator.hasNext();) { - IApiType superTypeDescriptor = iterator.next(); + loop: for (IApiType superTypeDescriptor : superclassList) { IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor); if (method3 == null) { continue; @@ -1739,8 +1729,7 @@ private void getDeltaForMethod(IApiMethod method) { if (this.type1.isInterface()) { Set interfacesSet = getInterfacesSet(this.type2); if (interfacesSet != null && isStatusOk()) { - for (Iterator iterator = interfacesSet.iterator(); iterator.hasNext();) { - IApiType superTypeDescriptor = iterator.next(); + for (IApiType superTypeDescriptor : interfacesSet) { IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor); if (method3 == null) { continue; @@ -1758,8 +1747,7 @@ private void getDeltaForMethod(IApiMethod method) { } else { List superclassList = getSuperclassList(this.type2, true); if (superclassList != null) { - loop: for (Iterator iterator = superclassList.iterator(); iterator.hasNext();) { - IApiType superTypeDescriptor = iterator.next(); + loop: for (IApiType superTypeDescriptor : superclassList) { IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor); if (method3 == null) { continue; @@ -1856,8 +1844,8 @@ private void getDeltaForMethod(IApiMethod method) { } else { // check if the exceptions are consistent for both descriptors List removedExceptions = new ArrayList<>(); - for (Iterator iterator = list1.iterator(); iterator.hasNext();) { - String exceptionName = iterator.next().replace('/', '.'); + for (String string : list1) { + String exceptionName = string.replace('/', '.'); if (!list2.remove(exceptionName)) { // this means that the exceptionName was not found // inside the new set of exceptions @@ -2283,8 +2271,7 @@ private void reportMethodAddition(IApiMethod method, IApiType type) { if (this.type1.isInterface()) { Set interfacesSet = getInterfacesSet(this.type2); if (interfacesSet != null && isStatusOk()) { - for (Iterator iterator = interfacesSet.iterator(); iterator.hasNext();) { - IApiType superTypeDescriptor = iterator.next(); + for (IApiType superTypeDescriptor : interfacesSet) { IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor); if (method3 == null) { continue; @@ -2300,8 +2287,7 @@ private void reportMethodAddition(IApiMethod method, IApiType type) { } else { List superclassList = getSuperclassList(this.type2, true); if (superclassList != null && isStatusOk()) { - loop: for (Iterator iterator = superclassList.iterator(); iterator.hasNext();) { - IApiType superTypeDescriptor = iterator.next(); + loop: for (IApiType superTypeDescriptor : superclassList) { IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor); if (method3 == null) { continue; @@ -2343,8 +2329,7 @@ private void reportMethodAddition(IApiMethod method, IApiType type) { if (this.type1.isInterface()) { Set interfacesSet = getInterfacesSet(this.type1); if (interfacesSet != null && isStatusOk()) { - for (Iterator iterator = interfacesSet.iterator(); iterator.hasNext();) { - IApiType superTypeDescriptor = iterator.next(); + for (IApiType superTypeDescriptor : interfacesSet) { IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor); if (method3 == null) { continue; @@ -2361,8 +2346,7 @@ private void reportMethodAddition(IApiMethod method, IApiType type) { } else { List superclassList = getSuperclassList(this.type1, true); if (superclassList != null && isStatusOk()) { - loop: for (Iterator iterator = superclassList.iterator(); iterator.hasNext();) { - IApiType superTypeDescriptor = iterator.next(); + loop: for (IApiType superTypeDescriptor : superclassList) { IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor); if (method3 == null) { continue; diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/AbstractApiTypeContainer.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/AbstractApiTypeContainer.java index 9f00247be60..3d4764e0f6a 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/AbstractApiTypeContainer.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/AbstractApiTypeContainer.java @@ -14,9 +14,10 @@ package org.eclipse.pde.api.tools.internal.model; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; @@ -159,16 +160,13 @@ public IApiTypeRoot findTypeRoot(String qualifiedName, String id) throws CoreExc @Override public String[] getPackageNames() throws CoreException { - List names = new ArrayList<>(); + SortedSet names = new TreeSet<>(); IApiTypeContainer[] containers = getApiTypeContainers(); for (IApiTypeContainer container : containers) { String[] packageNames = container.getPackageNames(); Collections.addAll(names, packageNames); } - String[] result = new String[names.size()]; - names.toArray(result); - Arrays.sort(result); - return result; + return names.toArray(String[]::new); } /** diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java index 20078a126c5..5da3d645343 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java @@ -75,7 +75,6 @@ import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent; import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement; import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer; -import org.eclipse.pde.api.tools.internal.util.FileManager; import org.eclipse.pde.api.tools.internal.util.SourceDefaultHandler; import org.eclipse.pde.api.tools.internal.util.Util; import org.eclipse.pde.internal.core.TargetWeaver; @@ -94,7 +93,6 @@ public class BundleComponent extends Component { static final String TMP_API_FILE_PREFIX = "api"; //$NON-NLS-1$ - static final String TMP_API_FILE_POSTFIX = "tmp"; //$NON-NLS-1$ /** * Dictionary parsed from MANIFEST.MF @@ -698,30 +696,20 @@ protected IApiTypeContainer createApiTypeContainer(String path) throws CoreExcep zip = new ZipFile(fLocation); ZipEntry entry = zip.getEntry(path); if (entry != null) { - File tmpfolder = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$ if (entry.isDirectory()) { // extract the dir and all children - File dir = Util.createTempFile(TMP_API_FILE_PREFIX, TMP_API_FILE_POSTFIX); - // hack to create a temp directory - // see - // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4735419 - if (dir.delete()) { - dir.mkdir(); - FileManager.getManager().recordTempFileRoot(dir.getCanonicalPath()); - } + File dir = Util.createTempDirectory(TMP_API_FILE_PREFIX); extractDirectory(zip, entry.getName(), dir); - if (dir.isDirectory() && dir.exists()) { - return new DirectoryApiTypeContainer(this, dir.getCanonicalPath()); - } + return new DirectoryApiTypeContainer(this, dir.getCanonicalPath()); } else { - File file = extractEntry(zip, entry, tmpfolder); - if (Util.isArchive(file.getName())) { - File parent = file.getParentFile(); - if (!parent.equals(tmpfolder)) { - FileManager.getManager().recordTempFileRoot(parent.getCanonicalPath()); - } else { - FileManager.getManager().recordTempFileRoot(file.getCanonicalPath()); - } + if (Util.isArchive(path)) { + // Create a uniquely named temp-directory and extract the file inside it. + // Without that additional parent directory, this could clash, e.g. + // due to pre-existing files in the temp dir or when comparing with + // a baseline during API analysis: one file would simply overwrite + // the other one and thus a difference cannot be found. + File dir = Util.createTempDirectory(TMP_API_FILE_PREFIX); + File file = extractEntry(zip, entry, dir); return new ArchiveApiTypeContainer(this, file.getCanonicalPath()); } } diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/DirectoryApiTypeContainer.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/DirectoryApiTypeContainer.java index d42a53da7ad..2d6d12bc351 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/DirectoryApiTypeContainer.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/DirectoryApiTypeContainer.java @@ -19,7 +19,6 @@ import java.io.IOException; import java.nio.file.Files; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; @@ -193,11 +192,7 @@ public IApiTypeRoot findTypeRoot(String qualifiedName) throws CoreException { public String[] getPackageNames() throws CoreException { init(); if (fPackageNames == null) { - List names = new ArrayList<>(fPackages.keySet()); - String[] result = new String[names.size()]; - names.toArray(result); - Arrays.sort(result); - fPackageNames = result; + fPackageNames = fPackages.keySet().stream().sorted().toArray(String[]::new); } return fPackageNames; } diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ProjectTypeContainer.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ProjectTypeContainer.java index 2ecf9385d92..c7abc04a3a3 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ProjectTypeContainer.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ProjectTypeContainer.java @@ -14,15 +14,15 @@ package org.eclipse.pde.api.tools.internal.model; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceProxy; -import org.eclipse.core.resources.IResourceProxyVisitor; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -40,38 +40,6 @@ */ public class ProjectTypeContainer extends ApiElement implements IApiTypeContainer { - - /** - * Proxy visitor for collecting package names, etc for our type containers - * - * @since 1.1 - */ - static class ContainerVisitor implements IResourceProxyVisitor { - - List collector = null; - int segmentcount = 0; - - /** - * Constructor - * - * @param collector - * @param root - */ - public ContainerVisitor(List collector, IContainer root) { - this.collector = collector; - this.segmentcount = root.getFullPath().segmentCount(); - } - - @Override - public boolean visit(IResourceProxy proxy) throws CoreException { - if (proxy.getType() == IResource.FOLDER) { - String path = proxy.requestFullPath().removeFirstSegments(this.segmentcount).toString(); - return this.collector.add(path.replace(IPath.SEPARATOR, '.')); - } - return false; - } - } - /** * Root directory of the {@link IApiTypeContainer} */ @@ -182,23 +150,29 @@ public IApiTypeRoot findTypeRoot(String qualifiedName) throws CoreException { @Override public String[] getPackageNames() throws CoreException { if (fPackageNames == null) { - List names = new ArrayList<>(); - collectPackageNames(names, Util.DEFAULT_PACKAGE_NAME, fRoot); - fPackageNames = names.toArray(new String[names.size()]); - Arrays.sort(fPackageNames); + SortedSet names = new TreeSet<>(); + collectPackageNames(names, fRoot); + fPackageNames = names.toArray(String[]::new); } return fPackageNames; } /** - * Traverses a directory to determine if it has {@link IApiTypeRoot}s and - * then visits sub-directories. + * Traverses a directory to determine if it has {@link IApiTypeRoot}s and then + * visits sub-directories. * - * @param packageName package name of directory being visited * @param dir directory being visited */ - private void collectPackageNames(List names, String packageName, IContainer dir) throws CoreException { - dir.accept(new ContainerVisitor(names, dir), IResource.NONE); + private static void collectPackageNames(Set collector, IContainer dir) throws CoreException { + int segmentCount = dir.getFullPath().segmentCount(); + dir.accept(proxy -> { + if (proxy.getType() == IResource.FOLDER) { + IPath relativePath = proxy.requestFullPath().removeFirstSegments(segmentCount); + String packageName = relativePath.toString().replace(IPath.SEPARATOR, '.'); + return collector.add(packageName); + } + return false; + }, IResource.NONE); } @Override diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/StubArchiveApiTypeContainer.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/StubArchiveApiTypeContainer.java index 43fb274b8c7..ba167133548 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/StubArchiveApiTypeContainer.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/StubArchiveApiTypeContainer.java @@ -16,7 +16,6 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; @@ -223,11 +222,7 @@ public String[] getPackageNames() throws CoreException { init(); synchronized (this) { if (fPackageNames == null) { - Set names = fPackages.keySet(); - String[] result = new String[names.size()]; - names.toArray(result); - Arrays.sort(result); - fPackageNames = result; + fPackageNames = fPackages.keySet().stream().sorted().toArray(String[]::new); } return fPackageNames; } diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java index 83520e12818..e823cc8ebbd 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java @@ -2028,14 +2028,24 @@ public static File getEEDescriptionFile() { /** * Creates a new file in the users' temp directory * - * @param prefix - * @param suffix * @return a new temp file * @throws IOException - * @since 1.1 */ public static File createTempFile(String prefix, String suffix) throws IOException { - File file = File.createTempFile(prefix, suffix); + return recordTempFile(Files.createTempFile(prefix, suffix).toFile()); + } + + /** + * Creates a new directory in the users' temp directory + * + * @return a new temp directory + * @throws IOException + */ + public static File createTempDirectory(String prefix) throws IOException { + return recordTempFile(Files.createTempDirectory(prefix).toFile()); + } + + private static File recordTempFile(File file) throws IOException { file.deleteOnExit(); FileManager.getManager().recordTempFileRoot(file.getCanonicalPath()); return file; diff --git a/apitools/pom.xml b/apitools/pom.xml index ce359ef8f13..31ae98d358b 100644 --- a/apitools/pom.xml +++ b/apitools/pom.xml @@ -14,7 +14,7 @@ org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT eclipse.pde.apitools pom diff --git a/build/README.md b/build/README.md new file mode 100644 index 00000000000..1d6ca917d91 --- /dev/null +++ b/build/README.md @@ -0,0 +1,11 @@ +#PDE buld is in deep maintenance mode + +## Compatibility with newer Eclipse versions functionality +Enhancements to make use of new functionality implemented in latest versions of other components are most likely not implemented in pde.build. + +## Bugs +Bugs affecting in IDE Export functionality may still be worked on (until replacement functionality is provided) although with low priority. If you experience issues with headless builds it is highly likely that you would have to investigate and provide a patch fixing it. + +## Alternative headless/standalone builds recommendation +[Tycho project](https://github.com/eclipse-tycho/tycho) is the most common and active project for building Eclipse RCP apps and thus is recommended as a replacement for pde.build. + diff --git a/build/pom.xml b/build/pom.xml index e7d30908042..718ae0dc061 100644 --- a/build/pom.xml +++ b/build/pom.xml @@ -14,7 +14,7 @@ org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT eclipse.pde.build pom diff --git a/ds/pom.xml b/ds/pom.xml index 4d4066d7bc5..b6159903d31 100644 --- a/ds/pom.xml +++ b/ds/pom.xml @@ -14,7 +14,7 @@ org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT eclipse.pde.ds pom diff --git a/features/org.eclipse.pde-feature/feature.xml b/features/org.eclipse.pde-feature/feature.xml index b319c291802..36e469a5b0e 100644 --- a/features/org.eclipse.pde-feature/feature.xml +++ b/features/org.eclipse.pde-feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/pom.xml b/pom.xml index 3b4c90f193a..5e42a142576 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ org.eclipse eclipse-platform-parent - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT ../eclipse-platform-parent diff --git a/releng/org.eclipse.pde.setup/PDE.setup b/releng/org.eclipse.pde.setup/PDE.setup index 2559e44890b..f23dd667b3e 100644 --- a/releng/org.eclipse.pde.setup/PDE.setup +++ b/releng/org.eclipse.pde.setup/PDE.setup @@ -92,8 +92,8 @@ storageURI="scope://Workspace"/> + version="JavaSE-17" + location="${jre.location-17}"/> org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT ../../ org.eclipse.pde diff --git a/ua/pom.xml b/ua/pom.xml index e323ed8097e..5be88470a29 100644 --- a/ua/pom.xml +++ b/ua/pom.xml @@ -14,7 +14,7 @@ org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT eclipse.pde.ua pom diff --git a/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF index abaf27f894d..3eff9f85310 100644 --- a/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.core; singleton:=true -Bundle-Version: 3.16.0.qualifier +Bundle-Version: 3.16.100.qualifier Bundle-Activator: org.eclipse.pde.internal.core.PDECore Bundle-Vendor: %provider-name Bundle-Localization: plugin diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/BundleManifestSourceLocationManager.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/BundleManifestSourceLocationManager.java index 8b4be0372d8..176736b62ef 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/BundleManifestSourceLocationManager.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/BundleManifestSourceLocationManager.java @@ -13,20 +13,26 @@ *******************************************************************************/ package org.eclipse.pde.internal.core; -import java.util.ArrayList; +import java.io.File; +import java.net.URI; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; +import org.eclipse.equinox.frameworkadmin.BundleInfo; import org.eclipse.osgi.util.ManifestElement; import org.eclipse.osgi.util.NLS; import org.eclipse.pde.core.plugin.IPluginBase; import org.eclipse.pde.core.plugin.IPluginModelBase; +import org.eclipse.pde.core.target.TargetBundle; import org.eclipse.pde.internal.core.plugin.PluginBase; import org.osgi.framework.BundleException; import org.osgi.framework.Constants; @@ -45,7 +51,9 @@ public class BundleManifestSourceLocationManager { /** * Maps SourceLocationKeys (plugin name and version) to IPluginModelBase objects representing source bundles */ - private Map fPluginToSourceBundle = new LinkedHashMap<>(0); + private Map fPluginToSourceBundle = Map.of(); + + private Map fPluginToTargetBundle = Map.of(); /** * Returns a source location that provides source for a specific plugin (specified by name and version) @@ -54,13 +62,45 @@ public class BundleManifestSourceLocationManager { * @return a source location or null if no location exists for this plugin */ public SourceLocation getSourceLocation(String pluginName, Version pluginVersion) { - IPluginModelBase plugin = fPluginToSourceBundle.get(new SourceLocationKey(pluginName, pluginVersion)); + return locationOf(new SourceLocationKey(pluginName, pluginVersion)).orElse(null); + } + + private Optional locationOf(SourceLocationKey key) { + return pluginModel(key).or(() -> targetBundle(key)); + } + + private Optional targetBundle(SourceLocationKey key) { + TargetBundle targetBundle = fPluginToTargetBundle.get(key); + if (targetBundle != null) { + BundleInfo bundleInfo = targetBundle.getBundleInfo(); + if (bundleInfo != null) { + URI location = bundleInfo.getLocation(); + if (location != null) { + try { + File file = new File(location); + SourceLocation sourceLocation = new SourceLocation(new Path(file.getAbsolutePath())); + sourceLocation.setUserDefined(false); + return Optional.of(sourceLocation); + } catch (RuntimeException e) { + // cannot be used then... + } + } + } + } + return Optional.empty(); + } + + private Optional pluginModel(SourceLocationKey key) { + IPluginModelBase plugin = fPluginToSourceBundle.get(key); if (plugin != null) { - SourceLocation location = new SourceLocation(new Path(plugin.getInstallLocation())); - location.setUserDefined(false); - return location; + String path = plugin.getInstallLocation(); + if (path != null) { + SourceLocation location = new SourceLocation(new Path(path)); + location.setUserDefined(false); + return Optional.of(location); + } } - return null; + return Optional.empty(); } /** @@ -68,13 +108,8 @@ public SourceLocation getSourceLocation(String pluginName, Version pluginVersion * @return set of source locations, possibly empty */ public Collection getSourceLocations() { - Collection result = new ArrayList<>(fPluginToSourceBundle.size()); - for (IPluginModelBase bundle : fPluginToSourceBundle.values()) { - SourceLocation location = new SourceLocation(new Path(bundle.getInstallLocation())); - location.setUserDefined(false); - result.add(location); - } - return result; + return Stream.concat(fPluginToSourceBundle.keySet().stream(), fPluginToTargetBundle.keySet().stream()) + .distinct().flatMap(key -> locationOf(key).stream()).collect(Collectors.toList()); } /** @@ -86,7 +121,7 @@ public Collection getSourceLocations() { * @return whether this manager has a source location for the the given plugin */ public boolean hasValidSourceLocation(String pluginName, Version pluginVersion) { - return fPluginToSourceBundle.containsKey(new SourceLocationKey(pluginName, pluginVersion)); + return getSourceLocation(pluginName, pluginVersion) != null; } /** @@ -233,4 +268,24 @@ public void setPlugins(IPluginModelBase[] externalModels) { } } } + + public void setTargetBundles(TargetBundle[] bundles) { + fPluginToTargetBundle = new LinkedHashMap<>(); + for (TargetBundle bundle : bundles) { + + if (bundle.isSourceBundle()) { + // collect it in the map ... + BundleInfo sourceTarget = bundle.getSourceTarget(); + if (sourceTarget != null) { + try { + Version version = Version.parseVersion(sourceTarget.getVersion()); + fPluginToTargetBundle.put(new SourceLocationKey(sourceTarget.getSymbolicName(), version), + bundle); + } catch (IllegalArgumentException e) { + // can't parse the version... + } + } + } + } + } } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java index 37bb3dde30d..b7027689871 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java @@ -19,7 +19,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.Dictionary; -import java.util.Hashtable; import java.util.List; import java.util.Map; import org.eclipse.core.resources.IResource; @@ -44,6 +43,7 @@ import org.eclipse.pde.internal.core.util.UtilMessages; import org.osgi.framework.BundleException; import org.osgi.framework.Constants; +import org.osgi.framework.FrameworkUtil; import org.osgi.framework.namespace.ExecutionEnvironmentNamespace; public class MinimalState { @@ -64,12 +64,9 @@ public class MinimalState { protected static StateObjectFactory stateObjectFactory; - protected static String DIR; - protected String fSystemBundle = IPDEBuildConstants.BUNDLE_OSGI; static { - DIR = PDECore.getDefault().getStateLocation().toOSString(); stateObjectFactory = Platform.getPlatformAdmin().getFactory(); } @@ -143,38 +140,25 @@ private boolean hasDeclaredRequiredEE(Map manifest) { if (manifest.containsKey(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)) { return true; } - try { - ManifestElement[] requireCapabilityHeader = ManifestElement.parseHeader(Constants.REQUIRE_CAPABILITY, - manifest.get(Constants.REQUIRE_CAPABILITY)); - if (requireCapabilityHeader == null) { - return false; - } - - for (ManifestElement manifestElement : requireCapabilityHeader) { - if (ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE.equals(manifestElement.getValue())) { - return true; - } - } - + String capability = manifest.get(Constants.REQUIRE_CAPABILITY); + ManifestElement[] header = ManifestElement.parseHeader(Constants.REQUIRE_CAPABILITY, capability); + return header != null && Arrays.stream(header).map(ManifestElement::getValue) + .anyMatch(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE::equals); } catch (BundleException e) { - // ignore + return false; // ignore } - - return false; } public BundleDescription addBundle(Map manifest, File bundleLocation, long bundleId) throws CoreException { try { // OSGi requires a dictionary over any map - Hashtable dictionaryManifest = new Hashtable<>(manifest); + Dictionary dictionaryManifest = FrameworkUtil.asDictionary(manifest); BundleDescription descriptor = stateObjectFactory.createBundleDescription(fState, dictionaryManifest, bundleLocation.getAbsolutePath(), bundleId == -1 ? getNextId() : bundleId); // new bundle - if (bundleId == -1) { - fState.addBundle(descriptor); - } else if (!fState.updateBundle(descriptor)) { + if (bundleId == -1 || !fState.updateBundle(descriptor)) { fState.addBundle(descriptor); } return descriptor; @@ -251,15 +235,12 @@ protected boolean initializePlatformProperties() { if (fEEListChanged) { fEEListChanged = false; - return fState.setPlatformProperties(getProfilePlatformProperties()); + var properties = TargetPlatformHelper.getPlatformProperties(fExecutionEnvironments, this); + return fState.setPlatformProperties(properties); } return false; } - private Dictionary[] getProfilePlatformProperties() { - return TargetPlatformHelper.getPlatformProperties(fExecutionEnvironments, this); - } - public void removeBundleDescription(BundleDescription description) { if (description != null) { fState.removeBundle(description); @@ -280,10 +261,8 @@ private void setExecutionEnvironments() { String[] knownExecutionEnviroments = TargetPlatformHelper.getKnownExecutionEnvironments(); if (knownExecutionEnviroments.length == 0) { String jreProfile = System.getProperty("pde.jreProfile"); //$NON-NLS-1$ - if (jreProfile != null && jreProfile.length() > 0) { - if ("none".equals(jreProfile)) { //$NON-NLS-1$ - fNoProfile = true; - } + if (jreProfile != null && !jreProfile.isEmpty() && "none".equals(jreProfile)) { //$NON-NLS-1$ + fNoProfile = true; } } if (!fNoProfile) { diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEState.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEState.java index c7ccc40dc98..4219eae9957 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEState.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEState.java @@ -38,6 +38,7 @@ import org.eclipse.pde.internal.core.plugin.ExternalPluginModel; import org.eclipse.pde.internal.core.plugin.ExternalPluginModelBase; import org.eclipse.pde.internal.core.util.CoreUtility; +import org.eclipse.pde.internal.core.util.ManifestUtils; import org.osgi.framework.Version; public class PDEState extends MinimalState { @@ -165,7 +166,9 @@ private int versionCompare(Version v1, Version v2) { subMonitor.subTask(file.getName()); addBundle(file, -1); } catch (CoreException e) { - PDECore.log(e); + if (e.getStatus().getCode() != ManifestUtils.STATUS_CODE_NOT_A_BUNDLE_MANIFEST) { + PDECore.log(e); + } } subMonitor.split(1); } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/SourceLocationManager.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/SourceLocationManager.java index 4fd87617df1..71899f02920 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/SourceLocationManager.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/SourceLocationManager.java @@ -43,6 +43,9 @@ import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.plugin.ModelEntry; import org.eclipse.pde.core.plugin.PluginRegistry; +import org.eclipse.pde.core.target.ITargetDefinition; +import org.eclipse.pde.core.target.TargetBundle; +import org.eclipse.pde.internal.core.target.TargetPlatformService; import org.osgi.framework.Version; /** @@ -317,8 +320,13 @@ private IPath searchExtensionLocations(IPath relativePath, IPluginBase plugin) { return fullPath; } } - return getExtensions().locators.stream().map(locator -> locator.locateSource(plugin)).filter(Objects::nonNull) - .findFirst().orElse(null); + return getExtensions().locators.stream().map(locator -> { + try { + return locator.locator.locateSource(plugin); + } catch (RuntimeException e) { + return null; + } + }).filter(Objects::nonNull).findFirst().orElse(null); } /** @@ -423,16 +431,28 @@ private static SourceExtensions processExtensions() { for (IConfigurationElement element : extension.getConfigurationElements()) { if (element.getName().equals("locator")) { //$NON-NLS-1$ try { - result.locators.add((IPluginSourcePathLocator) element.createExecutableExtension("class")); //$NON-NLS-1$ + IPluginSourcePathLocator locator = (IPluginSourcePathLocator) element + .createExecutableExtension("class"); //$NON-NLS-1$ + LocatorComplexity complexity = getComplexity(element); + result.locators.add(new OrderedPluginSourcePathLocator(locator, complexity)); } catch (CoreException e) { PDECore.log(e.getStatus()); } } } } + Collections.sort(result.locators); return result; } + private static LocatorComplexity getComplexity(IConfigurationElement element) { + try { + return LocatorComplexity.valueOf(element.getAttribute("complexity")); //$NON-NLS-1$ + } catch (RuntimeException e) { + return LocatorComplexity.unkown; + } + } + /** * Returns a bundle manifest location manager that knows about source bundles in the current * platform. @@ -441,11 +461,43 @@ private static SourceExtensions processExtensions() { protected BundleManifestSourceLocationManager initializeBundleManifestLocations() { BundleManifestSourceLocationManager manager = new BundleManifestSourceLocationManager(); manager.setPlugins(PDECore.getDefault().getModelManager().getExternalModels()); + try { + ITargetDefinition definition = TargetPlatformService.getDefault().getWorkspaceTargetDefinition(); + if (definition != null && definition.isResolved()) { + TargetBundle[] bundles = definition.getAllBundles(); + if (bundles != null) { + manager.setTargetBundles(bundles); + } + } + } catch (CoreException e) { + // can't use this then... + } return manager; } private static final class SourceExtensions { final Collection locations = new LinkedHashSet<>(); - final List locators = new ArrayList<>(); + final List locators = new ArrayList<>(); + } + + private static final class OrderedPluginSourcePathLocator implements Comparable { + + private IPluginSourcePathLocator locator; + private LocatorComplexity complexity; + + OrderedPluginSourcePathLocator(IPluginSourcePathLocator locator, LocatorComplexity complexity) { + this.locator = locator; + this.complexity = complexity; + } + + @Override + public int compareTo(OrderedPluginSourcePathLocator o) { + return complexity.compareTo(o.complexity); + } + + } + + private enum LocatorComplexity { + low, medium, high, unkown; } } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformHelper.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformHelper.java index 7e9a6275db5..0b5f38beea4 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformHelper.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformHelper.java @@ -15,13 +15,13 @@ *******************************************************************************/ package org.eclipse.pde.internal.core; -import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; -import java.io.FileReader; import java.io.IOException; -import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Dictionary; import java.util.HashMap; @@ -31,9 +31,12 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.StringJoiner; import java.util.StringTokenizer; import java.util.TreeSet; import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; @@ -69,6 +72,8 @@ import org.osgi.framework.Version; public class TargetPlatformHelper { + private TargetPlatformHelper() { // static use only + } public static final String REFERENCE_PREFIX = "reference:"; //$NON-NLS-1$ public static final String PLATFORM_PREFIX = "platform:"; //$NON-NLS-1$ @@ -87,7 +92,7 @@ public class TargetPlatformHelper { Pattern.CASE_INSENSITIVE); private static Map fgCachedLocations; - private static HashMap> fgCachedTargetDefinitionMap = new HashMap<>(); + private static Map> fgCachedTargetDefinitionMap = new HashMap<>(); public static Properties getConfigIniProperties() { File iniFile = new File(TargetPlatform.getLocation(), "configuration/config.ini"); //$NON-NLS-1$ @@ -278,26 +283,19 @@ public static ITargetDefinition getUnresolvedRepositoryBasedWorkspaceTarget() th if (service == null) { throw new CoreException(Status.error(PDECoreMessages.TargetPlatformHelper_CouldNotAcquireTargetService)); } - final ITargetDefinition target = service.getWorkspaceTargetDefinition(); - if (target != null && !target.isResolved()) { - ITargetLocation[] locations = target.getTargetLocations(); - if (locations != null) { - for (ITargetLocation location : locations) { - if (location instanceof IUBundleContainer) { - IUBundleContainer bc = (IUBundleContainer) location; - URI[] uri = bc.getRepositories(); - if (uri != null) { - if (uri.length > 0) { - return target; - } - } - } - } - } + ITargetDefinition target = service.getWorkspaceTargetDefinition(); + if (target != null && !target.isResolved() && containsNotEmptyIULocation(target.getTargetLocations())) { + return target; } return null; } + private static boolean containsNotEmptyIULocation(ITargetLocation[] locations) { + return locations != null && Arrays.stream(locations) // + .filter(IUBundleContainer.class::isInstance).map(IUBundleContainer.class::cast) + .map(IUBundleContainer::getRepositories).anyMatch(uri -> uri != null && uri.length > 0); + } + public static Set getApplicationNameSet() { TreeSet result = new TreeSet<>(); IExtension[] extensions = PDECore.getDefault().getExtensionsRegistry() @@ -309,7 +307,7 @@ public static Set getApplicationNameSet() { continue; } String visiblity = elements[0].getAttribute("visible"); //$NON-NLS-1$ - boolean visible = visiblity == null ? true : Boolean.parseBoolean(visiblity); + boolean visible = visiblity == null || Boolean.parseBoolean(visiblity); if (id != null && visible) { result.add(id); } @@ -323,29 +321,19 @@ public static String[] getApplicationNames() { return result.toArray(new String[result.size()]); } - public static TreeSet getProductNameSet() { - TreeSet result = new TreeSet<>(); - IExtension[] extensions = PDECore.getDefault().getExtensionsRegistry() - .findExtensions("org.eclipse.core.runtime.products", true); //$NON-NLS-1$ - for (IExtension extension : extensions) { - IConfigurationElement[] elements = extension.getConfigurationElements(); - if (elements.length != 1) { - continue; - } - if (!"product".equals(elements[0].getName())) { //$NON-NLS-1$ - continue; - } - String id = extension.getUniqueIdentifier(); - if (id != null && id.trim().length() > 0) { - result.add(id); - } - } - return result; + public static Set getProductNameSet() { + PDEExtensionRegistry registry = PDECore.getDefault().getExtensionsRegistry(); + return Arrays.stream(registry.findExtensions("org.eclipse.core.runtime.products", true)) //$NON-NLS-1$ + .filter(extension -> { + IConfigurationElement[] elements = extension.getConfigurationElements(); + return elements.length == 1 && "product".equals(elements[0].getName()); //$NON-NLS-1$ + }) // + .map(IExtension::getUniqueIdentifier).filter(id -> id != null && !id.isBlank()) + .collect(Collectors.toCollection(TreeSet::new)); } public static String[] getProductNames() { - TreeSet result = getProductNameSet(); - return result.toArray(new String[result.size()]); + return getProductNameSet().toArray(String[]::new); } public static Dictionary getTargetEnvironment() { @@ -373,34 +361,39 @@ public static Dictionary[] getPlatformProperties(String[] profil // add java profiles for those EE's that have a .profile file in the // current system bundle - ArrayList> result = new ArrayList<>(profiles.length); + List> result = new ArrayList<>(profiles.length); for (String profile : profiles) { IExecutionEnvironment environment = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(profile); if (environment != null) { Properties profileProps = environment.getProfileProperties(); if (profileProps != null) { - Dictionary props = TargetPlatformHelper.getTargetEnvironment(state); - String systemPackages = profileProps.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES); - if (systemPackages == null) { - systemPackages = querySystemPackages(environment); - } - if (systemPackages != null) { - props.put(Constants.FRAMEWORK_SYSTEMPACKAGES, systemPackages); - } - @SuppressWarnings("deprecation") - String frameworkExecutionenvironment = Constants.FRAMEWORK_EXECUTIONENVIRONMENT; - String ee = profileProps.getProperty(frameworkExecutionenvironment); - if (ee != null) { - props.put(frameworkExecutionenvironment, ee); - } + Dictionary props = getTargetEnvironment(state); + addEnvironmentProperties(props, environment, profileProps); result.add(props); } } } if (!result.isEmpty()) { - return result.toArray(new Dictionary[result.size()]); + return result.toArray(Dictionary[]::new); + } + return new Dictionary[] { getTargetEnvironment(state) }; + } + + public static void addEnvironmentProperties(Dictionary properties, + IExecutionEnvironment environment, Properties profileProps) { + String systemPackages = profileProps.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES); + if (systemPackages == null) { // java 10 and beyond + systemPackages = querySystemPackages(environment); + } + if (systemPackages != null) { + properties.put(Constants.FRAMEWORK_SYSTEMPACKAGES, systemPackages); + } + @SuppressWarnings("deprecation") + String frameworkExecutionenvironment = Constants.FRAMEWORK_EXECUTIONENVIRONMENT; + String ee = profileProps.getProperty(frameworkExecutionenvironment); + if (ee != null) { + properties.put(frameworkExecutionenvironment, ee); } - return new Dictionary[] { TargetPlatformHelper.getTargetEnvironment(state) }; } @SuppressWarnings("restriction") @@ -632,15 +625,12 @@ public static ITargetDefinition getWorkspaceTargetResolved(IProgressMonitor moni } PDEPreferencesManager preferences = PDECore.getDefault().getPreferencesManager(); String memento = target.getHandle().getMemento(); - if (memento != null) { + if (memento != null && memento.equals(preferences.getString(ICoreConstants.WORKSPACE_TARGET_HANDLE))) { // Same target has been re-resolved upon loading, clear the - // preference and - // update the target so listeners can react to the change - see - // TargetStatus - if (memento.equals(preferences.getString(ICoreConstants.WORKSPACE_TARGET_HANDLE))) { - preferences.setValue(ICoreConstants.WORKSPACE_TARGET_HANDLE, ""); //$NON-NLS-1$ - preferences.setValue(ICoreConstants.WORKSPACE_TARGET_HANDLE, memento); - } + // preference and update the target so listeners can react to + // the change - see TargetStatus + preferences.setValue(ICoreConstants.WORKSPACE_TARGET_HANDLE, ""); //$NON-NLS-1$ + preferences.setValue(ICoreConstants.WORKSPACE_TARGET_HANDLE, memento); } } return target; @@ -731,21 +721,16 @@ public static boolean usesNewApplicationModel() { public static String getIniVMArgs() { File installDirectory = new File(Platform.getInstallLocation().getURL().getFile()); File eclipseIniFile = new File(installDirectory, "eclipse.ini"); //$NON-NLS-1$ - StringBuilder result = new StringBuilder(); + StringJoiner result = new StringJoiner(" "); //$NON-NLS-1$ if (eclipseIniFile.exists()) { - try (BufferedReader in = new BufferedReader(new FileReader(eclipseIniFile))) { - - String str; + try (Stream lines = Files.lines(eclipseIniFile.toPath(), StandardCharsets.UTF_8)) { boolean vmargs = false; - while ((str = in.readLine()) != null) { + for (String str : (Iterable) lines::iterator) { if (vmargs) { - if (result.length() > 0) { - result.append(" "); //$NON-NLS-1$ - } - result.append(str); + result.add(str); } // start concat'ng if we have vmargs - if (vmargs == false && str.equals("-vmargs")) { //$NON-NLS-1$ + if (!vmargs && str.equals("-vmargs")) { //$NON-NLS-1$ vmargs = true; } } @@ -756,7 +741,7 @@ public static String getIniVMArgs() { return result.toString(); } - public static HashMap> getTargetDefinitionMap() { + public static Map> getTargetDefinitionMap() { return fgCachedTargetDefinitionMap; } diff --git a/ui/org.eclipse.pde.genericeditor.extension.tests/pom.xml b/ui/org.eclipse.pde.genericeditor.extension.tests/pom.xml index 3b2d72fa4c3..12e3a081e52 100644 --- a/ui/org.eclipse.pde.genericeditor.extension.tests/pom.xml +++ b/ui/org.eclipse.pde.genericeditor.extension.tests/pom.xml @@ -14,7 +14,7 @@ org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT ../../ org.eclipse.pde.genericeditor.extension.tests diff --git a/ui/org.eclipse.pde.junit.runtime.tests/.classpath b/ui/org.eclipse.pde.junit.runtime.tests/.classpath index a42a828e04a..675a5e2962b 100644 --- a/ui/org.eclipse.pde.junit.runtime.tests/.classpath +++ b/ui/org.eclipse.pde.junit.runtime.tests/.classpath @@ -1,6 +1,6 @@ - + diff --git a/ui/org.eclipse.pde.junit.runtime.tests/.settings/org.eclipse.jdt.core.prefs b/ui/org.eclipse.pde.junit.runtime.tests/.settings/org.eclipse.jdt.core.prefs index 74507b89bce..932989a046a 100644 --- a/ui/org.eclipse.pde.junit.runtime.tests/.settings/org.eclipse.jdt.core.prefs +++ b/ui/org.eclipse.pde.junit.runtime.tests/.settings/org.eclipse.jdt.core.prefs @@ -9,8 +9,8 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 -org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.problem.APILeak=warning org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error @@ -107,4 +107,4 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.compiler.source=17 diff --git a/ui/org.eclipse.pde.junit.runtime.tests/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.junit.runtime.tests/META-INF/MANIFEST.MF index b5fdab132a5..adfb4dab5d2 100644 --- a/ui/org.eclipse.pde.junit.runtime.tests/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.junit.runtime.tests/META-INF/MANIFEST.MF @@ -2,9 +2,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: PDE JUnit Runtime Tests Bundle-SymbolicName: org.eclipse.pde.junit.runtime.tests;singleton:=true -Bundle-Version: 3.6.800.qualifier +Bundle-Version: 3.7.0.qualifier Automatic-Module-Name: org.eclipse.pde.junit.runtime.tests -Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-Vendor: Eclipse.org Bundle-ActivationPolicy: lazy Eclipse-BundleShape: dir diff --git a/ui/org.eclipse.pde.junit.runtime.tests/pom.xml b/ui/org.eclipse.pde.junit.runtime.tests/pom.xml index eecddb05208..7234fcf3d5f 100644 --- a/ui/org.eclipse.pde.junit.runtime.tests/pom.xml +++ b/ui/org.eclipse.pde.junit.runtime.tests/pom.xml @@ -20,11 +20,11 @@ org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT ../../ org.eclipse.pde.junit.runtime.tests - 3.6.800-SNAPSHOT + 3.7.0-SNAPSHOT eclipse-test-plugin -warn:-discouraged diff --git a/ui/org.eclipse.pde.launching/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.launching/META-INF/MANIFEST.MF index 055dc24a7c6..bc14fd158d0 100644 --- a/ui/org.eclipse.pde.launching/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.launching/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.launching;singleton:=true -Bundle-Version: 3.10.200.qualifier +Bundle-Version: 3.10.400.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-Vendor: %provider-name Require-Bundle: org.eclipse.jdt.junit.core;bundle-version="[3.6.0,4.0.0)", diff --git a/ui/org.eclipse.pde.launching/forceQualifierUpdate.txt b/ui/org.eclipse.pde.launching/forceQualifierUpdate.txt index 8870d19cdd9..1501a15daa1 100644 --- a/ui/org.eclipse.pde.launching/forceQualifierUpdate.txt +++ b/ui/org.eclipse.pde.launching/forceQualifierUpdate.txt @@ -3,3 +3,4 @@ Bug 578351 - Lambda generation order is unstable in ecj Bug 579126 - 4.24 I-Build: I20220307-0340 - Comparator Errors Found 4.26 I-Build: I20220915-0110 - Comparator Errors Found +Comparator errors in I20230307-0840 diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchConfigurationHelper.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchConfigurationHelper.java index 4afc7aeb53b..103ed0d4188 100644 --- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchConfigurationHelper.java +++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchConfigurationHelper.java @@ -16,7 +16,6 @@ import java.io.*; import java.net.URL; import java.util.*; -import java.util.Map.Entry; import org.eclipse.core.runtime.*; import org.eclipse.core.variables.IStringVariableManager; import org.eclipse.core.variables.VariablesPlugin; @@ -121,8 +120,10 @@ else if ((productID != null && !productID.equals(properties.get(PROP_PRODUCT)) | } // if target's config.ini has the osgi.bundles header, then parse and compute the proper osgi.bundles value String bundleList = properties.getProperty(PROP_OSGI_BUNDLES); - if (bundleList != null) - properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatformHelper.stripPathInformation(bundleList), bundles, bundlesWithStartLevels)); + if (bundleList != null) { + boolean autoStart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, false); + properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatformHelper.stripPathInformation(bundleList), bundles, bundlesWithStartLevels, autoStart)); + } } else { String templateLoc = configuration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, (String) null); if (templateLoc != null) { @@ -134,8 +135,9 @@ else if ((productID != null && !productID.equals(properties.get(PROP_PRODUCT)) | } } // whether we create a new config.ini or read from one as a template, we should add the required properties - bug 161265 + boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, false); if (properties != null) { - addRequiredProperties(properties, productID, bundles, bundlesWithStartLevels); + addRequiredProperties(properties, productID, bundles, bundlesWithStartLevels, autostart); } else { properties = new Properties(); } @@ -145,7 +147,6 @@ else if ((productID != null && !productID.equals(properties.get(PROP_PRODUCT)) | String osgiBundles = properties.getProperty(PROP_OSGI_BUNDLES); int start = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4); properties.put("osgi.bundles.defaultStartLevel", Integer.toString(start)); //$NON-NLS-1$ - boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, false); // Special processing for launching with p2 (simple configurator) if (osgiBundles != null && osgiBundles.contains(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) && bundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) { @@ -192,7 +193,7 @@ else if ((productID != null && !productID.equals(properties.get(PROP_PRODUCT)) | return properties; } - private static void addRequiredProperties(Properties properties, String productID, Map> bundles, Map bundlesWithStartLevels) { + private static void addRequiredProperties(Properties properties, String productID, Map> bundles, Map bundlesWithStartLevels, boolean autoStart) { if (!properties.containsKey("osgi.install.area")) //$NON-NLS-1$ properties.setProperty("osgi.install.area", "file:" + TargetPlatform.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$ if (!properties.containsKey("osgi.configuration.cascaded")) //$NON-NLS-1$ @@ -205,7 +206,7 @@ private static void addRequiredProperties(Properties properties, String productI if (properties.containsKey("osgi.splashPath")) //$NON-NLS-1$ resolveLocationPath(properties.getProperty("osgi.splashPath"), properties, bundles); //$NON-NLS-1$ if (!properties.containsKey(PROP_OSGI_BUNDLES)) - properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatform.getBundleList(), bundles, bundlesWithStartLevels)); + properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatform.getBundleList(), bundles, bundlesWithStartLevels, autoStart)); if (!properties.containsKey("osgi.bundles.defaultStartLevel")) //$NON-NLS-1$ properties.setProperty("osgi.bundles.defaultStartLevel", "4"); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -213,14 +214,15 @@ private static void addRequiredProperties(Properties properties, String productI /** * Computes a list of osgi bundles to be put into the osgi.bundles property based * on the bundles from the target platform config.ini and a map of bundles we are - * launching with. The list of bundles must have already had it's path information - * removed. - * @param bundleList list of bundles without path information + * launching with. + * @param initialBundleList initial list of bundles without path information * @param bundles map of bundle id to bundle model, contains all bundles being launched with * @param bundlesWithStartLevels map of bundles of start level - * @return string list of osgi bundles + * @param defaultAuto whether autostart should be configured + * @return string list of osgi bundles. Some entries are of the form `id@startLevel` and need + * to be resolved on a 2nd step; some others are of the form `reference:file:/path/to/plugin@startInfo` */ - private static String computeOSGiBundles(String bundleList, Map> bundles, Map bundlesWithStartLevels) { + private static String computeOSGiBundles(String initialBundleList, Map> bundles, Map bundlesWithStartLevels, boolean defaultAuto) { // if p2 and only simple configurator and // if simple configurator isn't selected & isn't in bundle list... hack it @@ -229,40 +231,29 @@ private static String computeOSGiBundles(String bundleList, Map initialBundleSet = new HashSet<>(); - StringTokenizer tokenizer = new StringTokenizer(bundleList, ","); //$NON-NLS-1$ + Map allBundles = new HashMap<>(bundlesWithStartLevels); + allBundles.keySet().removeIf(model -> IPDEBuildConstants.BUNDLE_OSGI.equals(model.getPluginBase().getId())); // write out all bundles in osgi.bundles - bug 170772 + // then override with resolved initialBundleList content + StringTokenizer tokenizer = new StringTokenizer(initialBundleList, ","); //$NON-NLS-1$ while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); int index = token.indexOf('@'); String id = index != -1 ? token.substring(0, index) : token; - if (bundles.containsKey(id)) { - if (buffer.length() > 0) - buffer.append(','); - buffer.append(id); - if (index != -1 && index < token.length() - 1) - buffer.append(token.substring(index)); - initialBundleSet.add(id); - } - } - - // write out all bundles in osgi.bundles - bug 170772 - initialBundleSet.add(IPDEBuildConstants.BUNDLE_OSGI); - for (Entry entry : bundlesWithStartLevels.entrySet()) { - IPluginModelBase model = entry.getKey(); - String id = model.getPluginBase().getId(); - if (!initialBundleSet.contains(id)) { - if (buffer.length() > 0) - buffer.append(','); - - String slinfo = entry.getValue(); - buffer.append(id); - buffer.append('@'); - buffer.append(slinfo); + IPluginModelBase model = getLatestModel(id, bundles); + if (model != null) { + // when present, startInfo from intialBundlesList overrides the one from the config + String startInfo = index + 1 < token.length() ? token.substring(index + 1) : allBundles.get(model); + allBundles.put(model, startInfo != null ? startInfo : ""); //$NON-NLS-1$ } } - return buffer.toString(); + StringJoiner osgiBundles = new StringJoiner(","); //$NON-NLS-1$ + allBundles.forEach((bundle, startInfo) -> { + String bundleURL = getBundleURL(bundle, true); + String startData = getStartData(startInfo, defaultAuto); + osgiBundles.add(bundleURL + startData); + }); + return osgiBundles.toString(); } private static Properties loadFromTemplate(String templateLoc) throws CoreException { @@ -368,7 +359,8 @@ public static String getBundleURL(IPluginModelBase model, boolean includeReferen /** * Use the map of bundles we are launching with to update the osgi.framework - * and osgi.bundles properties with the correct info. + * and osgi.bundles properties with the correct info; typically remapping + * `id@startLevel` entries into `reference:file:/path/to/bundle@startData` * @param map map of bundles being launched (id mapped to model) * @param properties properties for config.ini */ @@ -407,27 +399,35 @@ private static void setBundleLocations(Map> map, StringTokenizer tokenizer = new StringTokenizer(bundles, ","); //$NON-NLS-1$ while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken().trim(); - String url = getBundleURL(token, map, true); - int i = -1; - if (url == null) { - i = token.indexOf('@'); - if (i != -1) { - url = getBundleURL(token.substring(0, i), map, true); + if (token.startsWith("reference")) {//$NON-NLS-1$ + // already resolved + if (buffer.length() > 0) { + buffer.append(','); } + buffer.append(token); + } else { + String url = getBundleURL(token, map, true); + int i = -1; if (url == null) { - i = token.indexOf(':'); - if (i != -1) + i = token.indexOf('@'); + if (i != -1) { url = getBundleURL(token.substring(0, i), map, true); + } + if (url == null) { + i = token.indexOf(':'); + if (i != -1) + url = getBundleURL(token.substring(0, i), map, true); + } } - } - if (url != null) { - if (buffer.length() > 0) { - buffer.append(','); - } - buffer.append(url); - if (i != -1) { - String slinfo = token.substring(i + 1); - buffer.append(getStartData(slinfo, defaultAuto)); + if (url != null) { + if (buffer.length() > 0) { + buffer.append(','); + } + buffer.append(url); + if (i != -1) { + String slinfo = token.substring(i + 1); + buffer.append(getStartData(slinfo, defaultAuto)); + } } } } diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchValidationOperation.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchValidationOperation.java index 62e703a1968..ab996e8c590 100644 --- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchValidationOperation.java +++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchValidationOperation.java @@ -24,13 +24,11 @@ import org.eclipse.jdt.launching.IVMInstall; import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.jdt.launching.environments.IExecutionEnvironment; -import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager; import org.eclipse.osgi.service.resolver.State; import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.plugin.PluginRegistry; import org.eclipse.pde.internal.core.BundleValidationOperation; import org.eclipse.pde.internal.core.TargetPlatformHelper; -import org.osgi.framework.Constants; public class LaunchValidationOperation implements IWorkspaceRunnable { @@ -52,11 +50,11 @@ public void run(IProgressMonitor monitor) throws CoreException { @SuppressWarnings("unchecked") protected Dictionary[] getPlatformProperties() throws CoreException { IExecutionEnvironment[] envs = getMatchingEnvironments(); - if (envs.length == 0) + if (envs.length == 0) { return new Dictionary[] {TargetPlatformHelper.getTargetEnvironment()}; - + } // add java profiles for those EE's that have a .profile file in the current system bundle - ArrayList> result = new ArrayList<>(envs.length); + List> result = new ArrayList<>(envs.length); for (IExecutionEnvironment env : envs) { Properties profileProps = getJavaProfileProperties(env.getId()); if (profileProps == null) { @@ -65,96 +63,62 @@ protected Dictionary[] getPlatformProperties() throws CoreExcept } if (profileProps != null) { Dictionary props = TargetPlatformHelper.getTargetEnvironment(); - String systemPackages = profileProps.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES); - if (systemPackages == null) { - // java 10 and beyond - systemPackages = TargetPlatformHelper.querySystemPackages(env); - } - if (systemPackages != null) - props.put(Constants.FRAMEWORK_SYSTEMPACKAGES, systemPackages); - @SuppressWarnings("deprecation") - String frameworkExecutionenvironment = Constants.FRAMEWORK_EXECUTIONENVIRONMENT; - String ee = profileProps.getProperty(frameworkExecutionenvironment); - if (ee != null) - props.put(frameworkExecutionenvironment, ee); + TargetPlatformHelper.addEnvironmentProperties(props, env, profileProps); result.add(props); } } - if (!result.isEmpty()) - return result.toArray(new Dictionary[result.size()]); + if (!result.isEmpty()) { + return result.toArray(Dictionary[]::new); + } return new Dictionary[] {TargetPlatformHelper.getTargetEnvironment()}; - } protected IExecutionEnvironment[] getMatchingEnvironments() throws CoreException { IVMInstall install = VMHelper.getVMInstall(fLaunchConfiguration); - if (install == null) - return new IExecutionEnvironment[0]; + return install == null ? new IExecutionEnvironment[0] : getMatchingEEs(install); + } - IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); - IExecutionEnvironment[] envs = manager.getExecutionEnvironments(); - List result = new ArrayList<>(envs.length); - for (IExecutionEnvironment env : envs) { - IVMInstall[] compatible = env.getCompatibleVMs(); - for (IVMInstall element : compatible) { - if (element.equals(install)) { - result.add(env); - break; - } - } - } - return result.toArray(new IExecutionEnvironment[result.size()]); + static IExecutionEnvironment[] getMatchingEEs(IVMInstall install) { + return Arrays.stream(JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments()) // + .filter(env -> Arrays.stream(env.getCompatibleVMs()).anyMatch(install::equals)) // + .toArray(IExecutionEnvironment[]::new); } private Properties getJavaProfileProperties(String ee) { IPluginModelBase model = PluginRegistry.findModel("system.bundle"); //$NON-NLS-1$ - if (model == null) + if (model == null) { return null; - + } File location = new File(model.getInstallLocation()); String filename = ee.replace('/', '_') + ".profile"; //$NON-NLS-1$ - InputStream is = null; - ZipFile zipFile = null; try { // find the input stream to the profile properties file if (location.isDirectory()) { File file = new File(location, filename); if (file.exists()) - is = new FileInputStream(file); + try (InputStream is = new FileInputStream(file)) { + return loadProperties(is); + } } else { - try { - zipFile = new ZipFile(location, ZipFile.OPEN_READ); + try (ZipFile zipFile = new ZipFile(location, ZipFile.OPEN_READ)) { ZipEntry entry = zipFile.getEntry(filename); - if (entry != null) - is = zipFile.getInputStream(entry); - } catch (IOException e) { - // nothing to do + if (entry != null) { + return loadProperties(zipFile.getInputStream(entry)); + } } } - if (is != null) { - Properties profile = new Properties(); - profile.load(is); - return profile; - } } catch (IOException e) { // nothing to do - } finally { - if (is != null) - try { - is.close(); - } catch (IOException e) { - // nothing to do - } - if (zipFile != null) - try { - zipFile.close(); - } catch (IOException e) { - // nothing to do - } } return null; } + private static Properties loadProperties(InputStream is) throws IOException { + Properties profile = new Properties(); + profile.load(is); + return profile; + } + public boolean hasErrors() { return fOperation.hasErrors(); } diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/ProductValidationOperation.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/ProductValidationOperation.java index 3cc0f01e3fc..18fd4c27335 100644 --- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/ProductValidationOperation.java +++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/ProductValidationOperation.java @@ -14,12 +14,10 @@ *******************************************************************************/ package org.eclipse.pde.internal.launching.launcher; -import java.util.*; +import java.util.Set; import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.launching.IVMInstall; import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.jdt.launching.environments.IExecutionEnvironment; -import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager; import org.eclipse.pde.core.plugin.IPluginModelBase; public class ProductValidationOperation extends LaunchValidationOperation { @@ -30,21 +28,7 @@ public ProductValidationOperation(Set models) { @Override protected IExecutionEnvironment[] getMatchingEnvironments() throws CoreException { - IVMInstall install = JavaRuntime.getDefaultVMInstall(); - - IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); - IExecutionEnvironment[] envs = manager.getExecutionEnvironments(); - List result = new ArrayList<>(envs.length); - for (IExecutionEnvironment env : envs) { - IVMInstall[] compatible = env.getCompatibleVMs(); - for (IVMInstall element : compatible) { - if (element.equals(install)) { - result.add(env); - break; - } - } - } - return result.toArray(new IExecutionEnvironment[result.size()]); + return LaunchValidationOperation.getMatchingEEs(JavaRuntime.getDefaultVMInstall()); } } diff --git a/ui/org.eclipse.pde.runtime/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.runtime/META-INF/MANIFEST.MF index 07a5a20498f..54fe1b816b5 100644 --- a/ui/org.eclipse.pde.runtime/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.runtime/META-INF/MANIFEST.MF @@ -2,12 +2,12 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.runtime; singleton:=true -Bundle-Version: 3.7.500.qualifier +Bundle-Version: 3.7.600.qualifier Bundle-Activator: org.eclipse.pde.internal.runtime.PDERuntimePlugin Bundle-Vendor: %provider-name Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)", - org.eclipse.ui;bundle-version="[3.3.0,4.0.0)", + org.eclipse.ui;bundle-version="[3.202.0,4.0.0)", org.eclipse.ui.forms;bundle-version="[3.3.0,4.0.0)", org.eclipse.e4.ui.workbench;bundle-version="1.12.0", org.eclipse.e4.ui.model.workbench;bundle-version="2.1.0", diff --git a/ui/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java b/ui/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java index 6a6d898db09..0f688276765 100644 --- a/ui/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java +++ b/ui/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java @@ -13,7 +13,7 @@ *******************************************************************************/ package org.eclipse.pde.internal.runtime.registry; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Status; import org.eclipse.pde.internal.runtime.registry.model.*; import org.eclipse.ui.progress.UIJob; @@ -27,13 +27,10 @@ public RegistryBrowserModelChangeListener(RegistryBrowser registryBrowser) { @Override public void modelChanged(final ModelChangeDelta[] delta) { - new UIJob("Updating Registry") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - update(delta); - return Status.OK_STATUS; - } - }.schedule(); + UIJob.create("Updating Registry", monitor -> { //$NON-NLS-1$ + update(delta); + return Status.OK_STATUS; + }).schedule(); } private boolean topLevelElement(Object object) { diff --git a/ui/org.eclipse.pde.spy.bundle/.project b/ui/org.eclipse.pde.spy.bundle/.project index 405de65274e..c7dfdcd1eef 100644 --- a/ui/org.eclipse.pde.spy.bundle/.project +++ b/ui/org.eclipse.pde.spy.bundle/.project @@ -20,9 +20,15 @@ + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature + org.eclipse.pde.api.tools.apiAnalysisNature diff --git a/ui/org.eclipse.pde.spy.bundle/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.spy.bundle/META-INF/MANIFEST.MF index 1ec63f5091f..70e4762b879 100644 --- a/ui/org.eclipse.pde.spy.bundle/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.spy.bundle/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.spy.bundle;singleton:=true -Bundle-Version: 0.12.200.qualifier +Bundle-Version: 0.12.300.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Automatic-Module-Name: org.eclipse.pde.spy.bundle Require-Bundle: org.eclipse.core.runtime;bundle-version="3.10.0", diff --git a/ui/org.eclipse.pde.spy.context/.project b/ui/org.eclipse.pde.spy.context/.project index 7ee455081b2..1286e0f352b 100644 --- a/ui/org.eclipse.pde.spy.context/.project +++ b/ui/org.eclipse.pde.spy.context/.project @@ -20,9 +20,15 @@ + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature diff --git a/ui/org.eclipse.pde.spy.context/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.spy.context/META-INF/MANIFEST.MF index bfe00aea2f6..51ffb2603c0 100644 --- a/ui/org.eclipse.pde.spy.context/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.spy.context/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.spy.context;singleton:=true -Bundle-Version: 1.0.400.qualifier +Bundle-Version: 1.0.500.qualifier Bundle-Vendor: %provider-name Automatic-Module-Name: org.eclipse.pde.spy.context Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/ui/org.eclipse.pde.spy.core/.project b/ui/org.eclipse.pde.spy.core/.project index 404931287c4..b4bf5ba0b60 100644 --- a/ui/org.eclipse.pde.spy.core/.project +++ b/ui/org.eclipse.pde.spy.core/.project @@ -20,9 +20,15 @@ + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature diff --git a/ui/org.eclipse.pde.spy.core/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.spy.core/META-INF/MANIFEST.MF index a9d84751078..7989090ed54 100644 --- a/ui/org.eclipse.pde.spy.core/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.spy.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.spy.core;singleton:=true -Bundle-Version: 1.0.200.qualifier +Bundle-Version: 1.0.300.qualifier Automatic-Module-Name: org.eclipse.pde.spy.core Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/ui/org.eclipse.pde.spy.css/.project b/ui/org.eclipse.pde.spy.css/.project index 3d31baa8cff..a723a9298d1 100644 --- a/ui/org.eclipse.pde.spy.css/.project +++ b/ui/org.eclipse.pde.spy.css/.project @@ -20,9 +20,15 @@ + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature diff --git a/ui/org.eclipse.pde.spy.css/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.spy.css/META-INF/MANIFEST.MF index 45205f8fa6b..acffd9b3487 100644 --- a/ui/org.eclipse.pde.spy.css/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.spy.css/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.spy.css;singleton:=true -Bundle-Version: 0.12.300.qualifier +Bundle-Version: 0.12.400.qualifier Automatic-Module-Name: org.eclipse.pde.spy.css Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: org.eclipse.core.runtime;bundle-version="3.6.0", diff --git a/ui/org.eclipse.pde.spy.event/.project b/ui/org.eclipse.pde.spy.event/.project index 8683ccc56c6..698f125734d 100644 --- a/ui/org.eclipse.pde.spy.event/.project +++ b/ui/org.eclipse.pde.spy.event/.project @@ -20,9 +20,15 @@ + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature diff --git a/ui/org.eclipse.pde.spy.event/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.spy.event/META-INF/MANIFEST.MF index c1615355d21..eba121553f0 100644 --- a/ui/org.eclipse.pde.spy.event/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.spy.event/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.spy.event;singleton:=true -Bundle-Version: 1.0.100.qualifier +Bundle-Version: 1.0.200.qualifier Bundle-Vendor: Eclipse Foundation Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, diff --git a/ui/org.eclipse.pde.spy.model/.project b/ui/org.eclipse.pde.spy.model/.project index 6dc8cbfbc18..59481a7cf4c 100644 --- a/ui/org.eclipse.pde.spy.model/.project +++ b/ui/org.eclipse.pde.spy.model/.project @@ -25,9 +25,15 @@ + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature diff --git a/ui/org.eclipse.pde.spy.model/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.spy.model/META-INF/MANIFEST.MF index ac9985244b3..50a75414f3f 100644 --- a/ui/org.eclipse.pde.spy.model/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.spy.model/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.spy.model;singleton:=true -Bundle-Version: 0.12.400.qualifier +Bundle-Version: 0.12.500.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: org.eclipse.e4.ui.services;bundle-version="0.9.1", org.eclipse.e4.tools.emf.ui;bundle-version="4.7.0", diff --git a/ui/org.eclipse.pde.spy.preferences/.project b/ui/org.eclipse.pde.spy.preferences/.project index 1b4f8a19880..c1bf38dfd1e 100644 --- a/ui/org.eclipse.pde.spy.preferences/.project +++ b/ui/org.eclipse.pde.spy.preferences/.project @@ -20,9 +20,15 @@ + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature diff --git a/ui/org.eclipse.pde.spy.preferences/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.spy.preferences/META-INF/MANIFEST.MF index 80ab59a50ee..aac1464c218 100644 --- a/ui/org.eclipse.pde.spy.preferences/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.spy.preferences/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.spy.preferences;singleton:=true -Bundle-Version: 0.12.300.qualifier +Bundle-Version: 0.12.400.qualifier Automatic-Module-Name: org.eclipse.pde.spy.preferences Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-Vendor: %provider-name diff --git a/ui/org.eclipse.pde.ui.templates.tests/.classpath b/ui/org.eclipse.pde.ui.templates.tests/.classpath index a42a828e04a..675a5e2962b 100644 --- a/ui/org.eclipse.pde.ui.templates.tests/.classpath +++ b/ui/org.eclipse.pde.ui.templates.tests/.classpath @@ -1,6 +1,6 @@ - + diff --git a/ui/org.eclipse.pde.ui.templates.tests/.settings/org.eclipse.jdt.core.prefs b/ui/org.eclipse.pde.ui.templates.tests/.settings/org.eclipse.jdt.core.prefs index a5e24386f52..8a5f1f72b01 100644 --- a/ui/org.eclipse.pde.ui.templates.tests/.settings/org.eclipse.jdt.core.prefs +++ b/ui/org.eclipse.pde.ui.templates.tests/.settings/org.eclipse.jdt.core.prefs @@ -17,9 +17,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -134,7 +134,7 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 diff --git a/ui/org.eclipse.pde.ui.templates.tests/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.ui.templates.tests/META-INF/MANIFEST.MF index bf4e5f32393..24f342c7295 100644 --- a/ui/org.eclipse.pde.ui.templates.tests/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.ui.templates.tests/META-INF/MANIFEST.MF @@ -2,10 +2,10 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Tests for PDE templates Bundle-SymbolicName: org.eclipse.pde.ui.templates.tests -Bundle-Version: 1.1.200.qualifier +Bundle-Version: 1.2.0.qualifier Bundle-Vendor: Eclipse.org Bundle-ClassPath: tests.jar -Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.eclipse.pde.ui;bundle-version="3.10.0", org.eclipse.pde.ui.templates;bundle-version="3.6.0", org.junit;bundle-version="4.13.0", diff --git a/ui/org.eclipse.pde.ui.templates.tests/pom.xml b/ui/org.eclipse.pde.ui.templates.tests/pom.xml index e245d6e6b58..9433fd31e33 100644 --- a/ui/org.eclipse.pde.ui.templates.tests/pom.xml +++ b/ui/org.eclipse.pde.ui.templates.tests/pom.xml @@ -14,11 +14,11 @@ org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT ../../ org.eclipse.pde.ui.templates.tests - 1.1.200-SNAPSHOT + 1.2.0-SNAPSHOT eclipse-test-plugin diff --git a/ui/org.eclipse.pde.ui.templates.tests/src/org/eclipse/pde/ui/templates/tests/TestPDETemplates.java b/ui/org.eclipse.pde.ui.templates.tests/src/org/eclipse/pde/ui/templates/tests/TestPDETemplates.java index 574415fd961..a16646c402c 100644 --- a/ui/org.eclipse.pde.ui.templates.tests/src/org/eclipse/pde/ui/templates/tests/TestPDETemplates.java +++ b/ui/org.eclipse.pde.ui.templates.tests/src/org/eclipse/pde/ui/templates/tests/TestPDETemplates.java @@ -23,16 +23,14 @@ import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; import org.eclipse.pde.core.plugin.IPluginModelBase; -import org.eclipse.pde.core.plugin.PluginRegistry; import org.eclipse.pde.ds.internal.annotations.Messages; import org.eclipse.pde.internal.core.ICoreConstants; -import org.eclipse.pde.internal.core.TargetPlatformHelper; import org.eclipse.pde.internal.core.builders.CompilerFlags; import org.eclipse.pde.internal.core.builders.PDEMarkerFactory; import org.eclipse.pde.internal.core.iproduct.IProduct; -import org.eclipse.pde.internal.core.iproduct.IProductPlugin; import org.eclipse.pde.internal.core.product.WorkspaceProductModel; import org.eclipse.pde.internal.launching.launcher.ProductValidationOperation; +import org.eclipse.pde.internal.ui.launcher.LaunchAction; import org.eclipse.pde.internal.ui.wizards.IProjectProvider; import org.eclipse.pde.internal.ui.wizards.WizardElement; import org.eclipse.pde.internal.ui.wizards.plugin.*; @@ -175,12 +173,7 @@ public void validateProduct() throws CoreException { model.load(); IProduct product = model.getProduct(); - Set launchPlugins = new HashSet<>(); - for (IProductPlugin plugin : product.getPlugins()) { - IPluginModelBase pluginModel = PluginRegistry.findModel(plugin.getId()); - if (pluginModel != null && TargetPlatformHelper.matchesCurrentEnvironment(pluginModel)) - launchPlugins.add(pluginModel); - } + Set launchPlugins = LaunchAction.getLaunchedBundlesForProduct(product); ProductValidationOperation validationOperation = new ProductValidationOperation(launchPlugins); validationOperation.run(new NullProgressMonitor()); diff --git a/ui/org.eclipse.pde.ui.templates/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.ui.templates/META-INF/MANIFEST.MF index a5d0881aec0..1af95b33f91 100644 --- a/ui/org.eclipse.pde.ui.templates/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.ui.templates/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %bundleName Bundle-SymbolicName: org.eclipse.pde.ui.templates;singleton:=true -Bundle-Version: 3.7.700.qualifier +Bundle-Version: 3.7.800.qualifier Bundle-Vendor: %bundleVendor Bundle-RequiredExecutionEnvironment: JavaSE-11 Export-Package: org.eclipse.pde.internal.ui.templates;x-internal:=true, diff --git a/ui/org.eclipse.pde.ui.templates/plugin.properties b/ui/org.eclipse.pde.ui.templates/plugin.properties index 6fb2c8189f6..a9b2f91be43 100644 --- a/ui/org.eclipse.pde.ui.templates/plugin.properties +++ b/ui/org.eclipse.pde.ui.templates/plugin.properties @@ -68,7 +68,10 @@ pluginContent.browserview.name = View using browser technology pluginContent.browserview.description=\

This wizard creates a standard plug-in directory structure and \ adds the following:

\ -
  • Browser view. %template.browserview.desc%
  • +
  • Browser view. %template.browserview.desc%
  • \ +

    Extensions Used

    \ +
  • org.eclipse.ui.views
  • \ +
  • org.eclipse.ui.perspectiveExtensions
  • pluginContent.view.name = View contribution using 3.x API pluginContent.view.description=\ diff --git a/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ToolbarContributionTemplate.java b/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ToolbarContributionTemplate.java index 64a4f83dbe6..975de89cbe6 100644 --- a/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ToolbarContributionTemplate.java +++ b/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ToolbarContributionTemplate.java @@ -113,7 +113,7 @@ private void createE4ModelExtension() throws CoreException { extension.setId(getValue(KEY_PACKAGE_NAME) + ".fragment"); //$NON-NLS-1$ element.setName("fragment"); //$NON-NLS-1$ - element.setAttribute("apply", "apply"); //$NON-NLS-1$ //$NON-NLS-2$ + element.setAttribute("apply", "always"); //$NON-NLS-1$ //$NON-NLS-2$ element.setAttribute("uri", E4_FRAGMENT_FILE); //$NON-NLS-1$ extension.add(element); diff --git a/ui/org.eclipse.pde.ui.templates/templates_3.5/E4Application/$pluginId$.product b/ui/org.eclipse.pde.ui.templates/templates_3.5/E4Application/$pluginId$.product index dbb3af481a7..7e31b026063 100644 --- a/ui/org.eclipse.pde.ui.templates/templates_3.5/E4Application/$pluginId$.product +++ b/ui/org.eclipse.pde.ui.templates/templates_3.5/E4Application/$pluginId$.product @@ -25,7 +25,6 @@ - diff --git a/ui/org.eclipse.pde.ui.templates/templates_3.5/E4View/fragment.e4xmi b/ui/org.eclipse.pde.ui.templates/templates_3.5/E4View/fragment.e4xmi index 19cb4003a4b..02497362ef7 100644 --- a/ui/org.eclipse.pde.ui.templates/templates_3.5/E4View/fragment.e4xmi +++ b/ui/org.eclipse.pde.ui.templates/templates_3.5/E4View/fragment.e4xmi @@ -1,7 +1,7 @@ - + View categoryTag:$viewCategoryName$ diff --git a/ui/org.eclipse.pde.ui.tests.smartimport/.classpath b/ui/org.eclipse.pde.ui.tests.smartimport/.classpath index 336abe9f465..7f87f1ffe76 100644 --- a/ui/org.eclipse.pde.ui.tests.smartimport/.classpath +++ b/ui/org.eclipse.pde.ui.tests.smartimport/.classpath @@ -1,6 +1,6 @@ - + diff --git a/ui/org.eclipse.pde.ui.tests.smartimport/.settings/org.eclipse.jdt.core.prefs b/ui/org.eclipse.pde.ui.tests.smartimport/.settings/org.eclipse.jdt.core.prefs index 20e30ff6839..a57c61d2b66 100644 --- a/ui/org.eclipse.pde.ui.tests.smartimport/.settings/org.eclipse.jdt.core.prefs +++ b/ui/org.eclipse.pde.ui.tests.smartimport/.settings/org.eclipse.jdt.core.prefs @@ -1,13 +1,13 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 -org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 diff --git a/ui/org.eclipse.pde.ui.tests.smartimport/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.ui.tests.smartimport/META-INF/MANIFEST.MF index 2f6eb43fe23..1acbe52596c 100644 --- a/ui/org.eclipse.pde.ui.tests.smartimport/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.ui.tests.smartimport/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Smart Import test for PDE Bundle-SymbolicName: org.eclipse.pde.ui.tests.smartimport;singleton:=true -Bundle-Version: 1.1.100.qualifier +Bundle-Version: 1.2.0.qualifier Bundle-Vendor: Eclipse.org Export-Package: org.eclipse.ui.tests.smartimport Require-Bundle: org.eclipse.core.resources, @@ -23,5 +23,5 @@ Require-Bundle: org.eclipse.core.resources, org.eclipse.pde.ui Bundle-ActivationPolicy: lazy Eclipse-BundleShape: dir -Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: org.eclipse.pde.ui.tests.smartimport diff --git a/ui/org.eclipse.pde.ui.tests.smartimport/pom.xml b/ui/org.eclipse.pde.ui.tests.smartimport/pom.xml index 6dd17ffd4d2..7a362c8ef4e 100644 --- a/ui/org.eclipse.pde.ui.tests.smartimport/pom.xml +++ b/ui/org.eclipse.pde.ui.tests.smartimport/pom.xml @@ -11,11 +11,11 @@ org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT ../../ org.eclipse.pde.ui.tests.smartimport - 1.1.100-SNAPSHOT + 1.2.0-SNAPSHOT eclipse-test-plugin diff --git a/ui/org.eclipse.pde.ui.tests/.classpath b/ui/org.eclipse.pde.ui.tests/.classpath index a42a828e04a..675a5e2962b 100644 --- a/ui/org.eclipse.pde.ui.tests/.classpath +++ b/ui/org.eclipse.pde.ui.tests/.classpath @@ -1,6 +1,6 @@ - + diff --git a/ui/org.eclipse.pde.ui.tests/.settings/org.eclipse.jdt.core.prefs b/ui/org.eclipse.pde.ui.tests/.settings/org.eclipse.jdt.core.prefs index 69c5ce90eaa..3ec081faa6b 100644 --- a/ui/org.eclipse.pde.ui.tests/.settings/org.eclipse.jdt.core.prefs +++ b/ui/org.eclipse.pde.ui.tests/.settings/org.eclipse.jdt.core.prefs @@ -18,9 +18,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -135,7 +135,7 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 diff --git a/ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF index 71d3573370f..a58d62933c4 100644 --- a/ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: PDE JUnit Tests Bundle-SymbolicName: org.eclipse.pde.ui.tests; singleton:=true -Bundle-Version: 3.11.1000.qualifier +Bundle-Version: 3.12.0.qualifier Bundle-ClassPath: tests.jar Bundle-Activator: org.eclipse.pde.ui.tests.PDETestsPlugin Bundle-Vendor: Eclipse.org @@ -11,7 +11,6 @@ Require-Bundle: org.junit, org.eclipse.ui, org.eclipse.core.resources, org.eclipse.core.runtime, - org.eclipse.osgi.services, org.eclipse.e4.core.contexts, org.eclipse.e4.core.services, org.eclipse.jdt.core, @@ -45,9 +44,11 @@ Require-Bundle: org.junit, org.eclipse.ui.ide.application Import-Package: org.assertj.core.api;version="3.14.0", org.assertj.core.presentation;version="3.21.0", - org.junit.jupiter.api.function;version="5.8.1" + org.eclipse.pde.internal.build, + org.junit.jupiter.api.function;version="5.8.1", + org.osgi.service.event;version="[1.3.0,2.0.0)" Eclipse-LazyStart: true -Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Eclipse-BundleShape: dir Automatic-Module-Name: org.eclipse.pde.ui.tests Export-Package: org.eclipse.pde.ui.tests.util diff --git a/ui/org.eclipse.pde.ui.tests/pom.xml b/ui/org.eclipse.pde.ui.tests/pom.xml index 096969029d1..531602928cc 100644 --- a/ui/org.eclipse.pde.ui.tests/pom.xml +++ b/ui/org.eclipse.pde.ui.tests/pom.xml @@ -14,11 +14,11 @@ org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT ../../ org.eclipse.pde.ui.tests - 3.11.1000-SNAPSHOT + 3.12.0-SNAPSHOT eclipse-test-plugin diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/core/builders/BundleErrorReporterTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/core/builders/BundleErrorReporterTest.java index 90e95bf980c..80fda47779e 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/core/builders/BundleErrorReporterTest.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/core/builders/BundleErrorReporterTest.java @@ -13,12 +13,16 @@ *******************************************************************************/ package org.eclipse.pde.core.tests.internal.core.builders; -import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; import java.util.Arrays; import java.util.List; -import org.eclipse.core.resources.*; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.launching.JavaRuntime; @@ -30,7 +34,9 @@ import org.eclipse.pde.internal.ui.util.ModelModification; import org.eclipse.pde.internal.ui.util.PDEModelUtility; import org.eclipse.pde.ui.tests.util.ProjectUtils; -import org.junit.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.osgi.framework.Constants; public class BundleErrorReporterTest { @@ -78,7 +84,7 @@ private List findUnresolvedImportsMarkers() throws CoreException { manifest.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null); return Arrays.stream(manifest.findMarkers(PDEMarkerFactory.MARKER_ID, false, 0)).filter( m -> m.getAttribute(PDEMarkerFactory.compilerKey, "").equals(CompilerFlags.P_UNRESOLVED_IMPORTS)) - .collect(toList()); + .toList(); } @After diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestCase.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestCase.java index 760ddc84a1c..5ce50483df4 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestCase.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestCase.java @@ -103,14 +103,8 @@ protected final void assertWelcomeScreenClosed() throws Exception { return; } - UIJob job = new UIJob("close welcome screen for debug test suite") { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - closeIntro(wb); - return Status.OK_STATUS; - } - - }; + UIJob job = UIJob.create("close welcome screen for debug test suite", + (ICoreRunnable) monitor -> closeIntro(wb)); job.setPriority(Job.INTERACTIVE); job.setSystem(true); job.schedule(); diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/EnvironmentAnalyzerDelegate.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/EnvironmentAnalyzerDelegate.java index 54b53fd5910..004186ca6d1 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/EnvironmentAnalyzerDelegate.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/EnvironmentAnalyzerDelegate.java @@ -13,12 +13,18 @@ *******************************************************************************/ package org.eclipse.pde.ui.tests.ee; -import java.util.*; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.launching.*; -import org.eclipse.jdt.launching.environments.*; +import org.eclipse.jdt.launching.IVMInstall; +import org.eclipse.jdt.launching.IVMInstall2; +import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.jdt.launching.environments.CompatibleEnvironment; +import org.eclipse.jdt.launching.environments.IExecutionEnvironment; +import org.eclipse.jdt.launching.environments.IExecutionEnvironmentAnalyzerDelegate; /** * Test analyzer recognizes 1.3 JREs and higher as compatible @@ -32,10 +38,9 @@ public class EnvironmentAnalyzerDelegate implements IExecutionEnvironmentAnalyze @Override public CompatibleEnvironment[] analyze(IVMInstall vm, IProgressMonitor monitor) throws CoreException { - if (!(vm instanceof IVMInstall2)) + if (!(vm instanceof IVMInstall2 vm2)) return new CompatibleEnvironment[0]; ArrayList result = new ArrayList<>(); - IVMInstall2 vm2 = (IVMInstall2) vm; String javaVersion = vm2.getJavaVersion(); if (javaVersion != null) { IExecutionEnvironment env = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(EE_NO_SOUND); diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/AbstractLaunchTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/AbstractLaunchTest.java index 7914ce942c8..dd43797aa42 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/AbstractLaunchTest.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/AbstractLaunchTest.java @@ -20,19 +20,31 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.util.*; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Map; import java.util.Map.Entry; +import java.util.NoSuchElementException; +import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; + import org.assertj.core.api.Assertions; import org.assertj.core.presentation.StandardRepresentation; import org.eclipse.core.resources.IProject; -import org.eclipse.debug.core.*; -import org.eclipse.pde.core.plugin.*; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.pde.core.plugin.IPluginBase; +import org.eclipse.pde.core.plugin.IPluginModelBase; +import org.eclipse.pde.core.plugin.ModelEntry; +import org.eclipse.pde.core.plugin.PluginRegistry; import org.eclipse.pde.ui.tests.util.ProjectUtils; import org.eclipse.pde.ui.tests.util.TargetPlatformUtil; -import org.junit.*; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; import org.junit.rules.TestRule; import org.osgi.framework.Version; @@ -110,8 +122,7 @@ static void assertPluginMapsEquals(String message, Map Assertions.assertThat(actual).withRepresentation(new StandardRepresentation() { @Override public String toStringOf(Object object) { - if (object instanceof IPluginModelBase) { - IPluginModelBase plugin = (IPluginModelBase) object; + if (object instanceof IPluginModelBase plugin) { String location = plugin.getUnderlyingResource() != null ? "w" : "e"; IPluginBase p = plugin.getPluginBase(); return p.getId() + "-" + p.getVersion() + "(" + location + ")"; diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java index e33688287a3..de7b3ccaa44 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java @@ -20,20 +20,28 @@ import static org.eclipse.pde.ui.tests.util.TargetPlatformUtil.bundle; import static org.eclipse.pde.ui.tests.util.TargetPlatformUtil.resolution; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.osgi.framework.Constants.REQUIRE_BUNDLE; import static org.osgi.framework.Constants.RESOLUTION_OPTIONAL; +import java.io.File; +import java.io.FileInputStream; +import java.net.URI; +import java.nio.file.Files; import java.nio.file.Path; import java.util.*; import java.util.function.Consumer; import java.util.stream.Collectors; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.debug.core.*; import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.target.NameVersionDescriptor; +import org.eclipse.pde.internal.build.IPDEBuildConstants; import org.eclipse.pde.internal.core.DependencyManager; import org.eclipse.pde.internal.launching.IPDEConstants; import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper; +import org.eclipse.pde.launching.EclipseApplicationLaunchConfiguration; import org.eclipse.pde.launching.IPDELauncherConstants; import org.eclipse.pde.ui.tests.util.ProjectUtils; import org.eclipse.pde.ui.tests.util.TargetPlatformUtil; @@ -818,6 +826,68 @@ public void testGetMergedBundleMap_automaticallyAddRequirements() throws Excepti targetBundle("plugin.b", "1.0.0"))))); } + @Test + public void testTwoVersionsOfSameBundleConfigIni() throws Exception { + var workspacePlugins = ofEntries( // + bundle("plugin.a", "1.0.0"), // + bundle("plugin.a", "2.0.0")); + setUpWorkspace(workspacePlugins, Map.of()); + + ILaunchConfigurationWorkingCopy launchConfig = createPluginLaunchConfig("testTwoVersionsOfSameBundleConfigIni"); + launchConfig.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_BUNDLES, + Set.of("plugin.a*1.0.0", "plugin.a*2.0.0")); + IPluginModelBase plugin1 = workspaceBundle("plugin.a", "1.0.0").findModel(); + IPluginModelBase plugin2 = workspaceBundle("plugin.a", "2.0.0").findModel(); + + EclipseApplicationLaunchConfiguration launch = new EclipseApplicationLaunchConfiguration(); + ILaunch alaunch = new Launch(launchConfig, "run", null); + String commandLine = launch.showCommandLine(launchConfig, "run", alaunch, new NullProgressMonitor()); + StringTokenizer tokenizer = new StringTokenizer(commandLine); + while (!"-configuration".equals(tokenizer.nextToken())) { + // + } + File configIniFile = new File(URI.create(tokenizer.nextToken() + "/config.ini")); + Properties configIni = new Properties(); + try (FileInputStream input = new FileInputStream(configIniFile)) { + configIni.load(input); + } + + String osgiBundles = configIni.getProperty("osgi.bundles"); + assertTrue(osgiBundles, osgiBundles.contains(new File(plugin1.getInstallLocation()).getAbsolutePath())); + assertTrue(osgiBundles, osgiBundles.contains(new File(plugin2.getInstallLocation()).getAbsolutePath())); + } + + @Test + public void testTwoVersionsOfSameBundleBundlesInfo() throws Exception { + var workspacePlugins = ofEntries( // + bundle("plugin.a", "1.0.0"), // + bundle("plugin.a", "2.0.0"), // + // will trigger usage of bundes.info + bundle(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR, "1.0.0")); + setUpWorkspace(workspacePlugins, Map.of()); + + ILaunchConfigurationWorkingCopy launchConfig = createPluginLaunchConfig( + "testTwoVersionsOfSameBundleBundlesInfo"); + launchConfig.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_BUNDLES, + Set.of("plugin.a*1.0.0", "plugin.a*2.0.0", IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR + "*1.0.0")); + IPluginModelBase plugin1 = workspaceBundle("plugin.a", "1.0.0").findModel(); + IPluginModelBase plugin2 = workspaceBundle("plugin.a", "2.0.0").findModel(); + + EclipseApplicationLaunchConfiguration launch = new EclipseApplicationLaunchConfiguration(); + ILaunch alaunch = new Launch(launchConfig, "run", null); + String commandLine = launch.showCommandLine(launchConfig, "run", alaunch, new NullProgressMonitor()); + StringTokenizer tokenizer = new StringTokenizer(commandLine); + while (!"-configuration".equals(tokenizer.nextToken())) { + // + } + File bundlesInfo = new File( + URI.create( + tokenizer.nextToken() + '/' + IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR + "/bundles.info")); + String info = Files.readString(bundlesInfo.toPath()); + assertTrue(info.contains(new File(plugin1.getInstallLocation()).getAbsolutePath())); + assertTrue(info.contains(new File(plugin2.getInstallLocation()).getAbsolutePath())); + } + // --- test cases for writeBundleEntry() ---- @Test diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/SchemaTraversePerfTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/SchemaTraversePerfTest.java index fa8b8f24ee3..65be6e79d14 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/SchemaTraversePerfTest.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/SchemaTraversePerfTest.java @@ -17,6 +17,7 @@ import java.io.InputStream; import java.net.JarURLConnection; import java.net.URLConnection; + import org.eclipse.pde.internal.core.XMLDefaultHandler; import org.eclipse.pde.internal.core.schema.EditableSchema; import org.eclipse.pde.internal.core.util.SAXParserWrapper; @@ -47,8 +48,8 @@ protected void executeTest() throws Exception { EditableSchema schema = new EditableSchema("pluginID", "pointID", "name", true); schema.traverseDocumentTree(handler.getDocumentElement()); } finally { - if (connection instanceof JarURLConnection){ - ((JarURLConnection)connection).getJarFile().close(); + if (connection instanceof JarURLConnection jarConnection) { + jarConnection.getJarFile().close(); } } } diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/PluginRegistryTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/PluginRegistryTests.java index c394c3c923c..e7575d05ddc 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/PluginRegistryTests.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/PluginRegistryTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2020 IBM Corporation and others. + * Copyright (c) 2010, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -16,8 +16,12 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.eclipse.pde.core.plugin.*; +import org.eclipse.pde.core.plugin.IMatchRules; +import org.eclipse.pde.core.plugin.IPluginModelBase; +import org.eclipse.pde.core.plugin.PluginRegistry; import org.junit.Test; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.Version; /** * Tests for plug-in searching @@ -28,7 +32,9 @@ public class PluginRegistryTests extends PluginRegistryTestsMinimal { @Test public void testMatchEquivalent() { - IPluginModelBase model = PluginRegistry.findModel("org.eclipse.pde.ui.tests", "3.11.0", + Version testsVersion = FrameworkUtil.getBundle(getClass()).getVersion(); + IPluginModelBase model = PluginRegistry.findModel("org.eclipse.pde.ui.tests", + String.format("%s.%s.%s", testsVersion.getMajor(), testsVersion.getMinor(), testsVersion.getMicro()), IMatchRules.EQUIVALENT, null); assertNotNull("NOTE: This test might also fail because the version of the bundle got changed.", model); diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/TargetPlatformUtil.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/TargetPlatformUtil.java index 0513c5ba6d1..dba6174900a 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/TargetPlatformUtil.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/TargetPlatformUtil.java @@ -18,28 +18,50 @@ import static java.util.Map.entry; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.Path; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; import java.util.function.Predicate; -import java.util.jar.*; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.jar.Manifest; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; + import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.pde.core.target.*; +import org.eclipse.pde.core.target.ITargetDefinition; +import org.eclipse.pde.core.target.ITargetLocation; +import org.eclipse.pde.core.target.ITargetPlatformService; +import org.eclipse.pde.core.target.LoadTargetDefinitionJob; +import org.eclipse.pde.core.target.NameVersionDescriptor; import org.eclipse.pde.internal.core.PDECore; import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel; import org.eclipse.pde.internal.core.ifeature.IFeature; import org.eclipse.pde.ui.tests.runtime.TestUtils; import org.eclipse.pde.ui.tests.util.ProjectUtils.CoreConsumer; import org.junit.rules.TestRule; -import org.osgi.framework.*; +import org.osgi.framework.Bundle; +import org.osgi.framework.Constants; +import org.osgi.framework.FrameworkUtil; public class TargetPlatformUtil { @@ -96,7 +118,7 @@ private static List addRunningPlatformBundles(Collection< Bundle[] installedBundles = FrameworkUtil.getBundle(TargetPlatformUtil.class).getBundleContext().getBundles(); List targetBundles = Arrays.asList(installedBundles); if (bundleFilter != null) { - targetBundles = targetBundles.stream().filter(bundleFilter).collect(Collectors.toList()); + targetBundles = targetBundles.stream().filter(bundleFilter).toList(); } var containerDirs = targetBundles.stream().map(FileLocator::getBundleFileLocation).map(Optional::orElseThrow) @@ -104,8 +126,7 @@ private static List addRunningPlatformBundles(Collection< containerDirs.map(dir -> TPS.newDirectoryLocation(dir.getAbsolutePath())).forEach(bundleContainers::add); return targetBundles.stream() - .map(b -> new NameVersionDescriptor(b.getSymbolicName(), b.getVersion().toString())) - .collect(Collectors.toList()); + .map(b -> new NameVersionDescriptor(b.getSymbolicName(), b.getVersion().toString())).toList(); } public static void createAndSetTarget(String name, Collection locations, diff --git a/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF index 6dc6f8e8a30..fffc3193ac8 100644 --- a/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.ui; singleton:=true -Bundle-Version: 3.13.700.qualifier +Bundle-Version: 3.13.800.qualifier Bundle-Activator: org.eclipse.pde.internal.ui.PDEPlugin Bundle-Vendor: %provider-name Bundle-Localization: plugin @@ -76,7 +76,6 @@ Export-Package: Require-Bundle: org.eclipse.pde.core;bundle-version="[3.13.0,4.0.0)";visibility:=reexport, org.eclipse.core.runtime;bundle-version="[3.18.0,4.0.0)", - org.eclipse.e4.core.contexts;bundle-version="[1.8.0,2.0.0)", org.eclipse.e4.core.services;bundle-version="[2.0.0,3.0.0)", org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)", @@ -91,7 +90,7 @@ Require-Bundle: org.eclipse.pde.build;bundle-version="[3.2.0,4.0.0)", org.eclipse.search;bundle-version="[3.7.0,4.0.0)", org.eclipse.team.core;bundle-version="[3.2.0,4.0.0)", - org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", + org.eclipse.ui;bundle-version="[3.202.0,4.0.0)", org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)", org.eclipse.ant.launching;bundle-version="[1.0.400,2.0.0)", org.eclipse.ant.ui;bundle-version="[3.1.0,4.0.0)", diff --git a/ui/org.eclipse.pde.ui/icons/elcl16/cleanmanifest.png b/ui/org.eclipse.pde.ui/icons/elcl16/cleanmanifest.png new file mode 100644 index 00000000000..f5b2c6933ca Binary files /dev/null and b/ui/org.eclipse.pde.ui/icons/elcl16/cleanmanifest.png differ diff --git a/ui/org.eclipse.pde.ui/icons/elcl16/cleanmanifest@2x.png b/ui/org.eclipse.pde.ui/icons/elcl16/cleanmanifest@2x.png new file mode 100644 index 00000000000..3ac93786f60 Binary files /dev/null and b/ui/org.eclipse.pde.ui/icons/elcl16/cleanmanifest@2x.png differ diff --git a/ui/org.eclipse.pde.ui/plugin.properties b/ui/org.eclipse.pde.ui/plugin.properties index a0a9d8de63b..919c4514855 100644 --- a/ui/org.eclipse.pde.ui/plugin.properties +++ b/ui/org.eclipse.pde.ui/plugin.properties @@ -143,7 +143,7 @@ differentiate between binary and source projects. PropertyPage.pluginDevelopment = Plug-in Development PropertyPage.selfHosting = Runtime Classpath -PropertyPage.compilers = Plug-in Manifest Compiler +PropertyPage.compilers = Compilers Plugin.dependencies.container = Plug-in Dependencies Plugin.WorkingSet = Plug-ins and Fragments @@ -302,4 +302,4 @@ create.module.info.label.pde= Create module-info.java locationProvider.description = Add a reference to another target file -locationProvider.name = Target File \ No newline at end of file +locationProvider.name = Target File diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java index 9bb353525b6..50daee740a1 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2022 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -21,6 +21,8 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.PlatformUI; /** * Bundle of all images used by the PDE plugin. @@ -277,6 +279,8 @@ public class PDEPluginImages { public static final ImageDescriptor DESC_PROFILE_EXC = create(PATH_OBJ, "profile_exc.png"); //$NON-NLS-1$ public static final ImageDescriptor DESC_CON_SEV = create(PATH_LCL, "configure_problem_severity.png"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_ORGANIZE_MANIFESTS_ACTION = create(PATH_LCL, + "cleanmanifest.png"); //$NON-NLS-1$ /** * WIZ */ @@ -315,27 +319,36 @@ private static ImageDescriptor create(String prefix, String name) { } public static Image get(String key) { - if (PLUGIN_REGISTRY == null) - initialize(); + if (PLUGIN_REGISTRY == null) { + Display display = Display.getCurrent(); + if (display == null && PlatformUI.isWorkbenchRunning()) { + display = PlatformUI.getWorkbench().getDisplay(); + } + if (display == null) { + return null; + } + + initialize(display); + } return PLUGIN_REGISTRY.get(key); } /* package */ - private static final void initialize() { - PLUGIN_REGISTRY = new ImageRegistry(); - manage(IMG_ATT_CLASS_OBJ, DESC_ATT_CLASS_OBJ); - manage(IMG_ATT_FILE_OBJ, DESC_ATT_FILE_OBJ); - manage(IMG_ATT_IMPL_OBJ, DESC_ATT_IMPL_OBJ); - manage(IMG_ATT_REQ_OBJ, DESC_ATT_REQ_OBJ); - manage(IMG_ATT_ID_OBJ, DESC_ATT_ID_OBJ); - manage(IMG_ATT_STRING_OBJ, DESC_ATT_STRING_OBJ); - manage(IMG_ATT_BOOLEAN_OBJ, DESC_ATT_BOOLEAN_OBJ); - manage(IMG_ATTRIBUTE_OBJ, DESC_ATTRIBUTE_OBJ); - manage(IMG_GENERIC_XML_OBJ, DESC_GENERIC_XML_OBJ); - manage(OBJ_DESC_GENERATE_CLASS, DESC_GENERATE_CLASS); - manage(OBJ_DESC_GENERATE_INTERFACE, DESC_GENERATE_INTERFACE); - manage(OBJ_DESC_PACKAGE, DESC_PACKAGE_OBJ); - manage(OBJ_DESC_BUNDLE, DESC_BUNDLE_OBJ); + private static final void initialize(Display display) { + PLUGIN_REGISTRY = new ImageRegistry(display); + manage(display, IMG_ATT_CLASS_OBJ, DESC_ATT_CLASS_OBJ); + manage(display, IMG_ATT_FILE_OBJ, DESC_ATT_FILE_OBJ); + manage(display, IMG_ATT_IMPL_OBJ, DESC_ATT_IMPL_OBJ); + manage(display, IMG_ATT_REQ_OBJ, DESC_ATT_REQ_OBJ); + manage(display, IMG_ATT_ID_OBJ, DESC_ATT_ID_OBJ); + manage(display, IMG_ATT_STRING_OBJ, DESC_ATT_STRING_OBJ); + manage(display, IMG_ATT_BOOLEAN_OBJ, DESC_ATT_BOOLEAN_OBJ); + manage(display, IMG_ATTRIBUTE_OBJ, DESC_ATTRIBUTE_OBJ); + manage(display, IMG_GENERIC_XML_OBJ, DESC_GENERIC_XML_OBJ); + manage(display, OBJ_DESC_GENERATE_CLASS, DESC_GENERATE_CLASS); + manage(display, OBJ_DESC_GENERATE_INTERFACE, DESC_GENERATE_INTERFACE); + manage(display, OBJ_DESC_PACKAGE, DESC_PACKAGE_OBJ); + manage(display, OBJ_DESC_BUNDLE, DESC_BUNDLE_OBJ); } private static URL makeImageURL(String prefix, String name) { @@ -343,8 +356,8 @@ private static URL makeImageURL(String prefix, String name) { return FileLocator.find(PDEPlugin.getDefault().getBundle(), new Path(path), null); } - public static Image manage(String key, ImageDescriptor desc) { - Image image = desc.createImage(); + public static Image manage(Display display, String key, ImageDescriptor desc) { + Image image = desc.createImage(display); PLUGIN_REGISTRY.put(key, image); return image; } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java index a513ce0ac99..1627a282f77 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java @@ -529,6 +529,16 @@ public class PDEUIMessages extends NLS { public static String MainPreferencePage_AddSwtNonDisposedToVMArgumentsToolTop; public static String MainPreferencePage_addToJavaSearch; + public static String MainPreferencePage_BundlePoolPrefsCleanBtn; + + public static String MainPreferencePage_BundlePoolPrefsCleanDesc; + + public static String MainPreferencePage_BundlePoolPrefsError; + + public static String MainPreferencePage_BundlePoolPrefsErrorCleaning; + + public static String MainPreferencePage_BundlePoolPrefsGroup; + public static String MainPreferencePage_junitWorkspace_asContainer; public static String MainPreferencePage_junitWorkspace_asLocation; diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/DependencyManagementSection.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/DependencyManagementSection.java index a799aa36bf4..1dce0185225 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/DependencyManagementSection.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/DependencyManagementSection.java @@ -23,7 +23,8 @@ import java.io.ByteArrayInputStream; import java.util.*; import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.action.*; import org.eclipse.jface.util.IPropertyChangeListener; @@ -469,17 +470,14 @@ public void modelChanged(final IModelChangedEvent event) { markStale(); return; } - UIJob job = new UIJob("Update required bundles") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - Object changedObject = event.getChangedObjects()[0]; - if ((changedObject instanceof IBuildEntry && ((IBuildEntry) changedObject).getName().equals(IBuildEntry.SECONDARY_DEPENDENCIES))) { - refresh(); - updateButtons(); - } - return Status.OK_STATUS; + UIJob job = UIJob.create("Update required bundles", monitor -> { //$NON-NLS-1$ + Object changedObject = event.getChangedObjects()[0]; + if ((changedObject instanceof IBuildEntry + && ((IBuildEntry) changedObject).getName().equals(IBuildEntry.SECONDARY_DEPENDENCIES))) { + refresh(); + updateButtons(); } - }; + }); job.setSystem(true); job.schedule(); } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ImportPackageSection.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ImportPackageSection.java index 2269a144c3f..d8f9b73cd78 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ImportPackageSection.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ImportPackageSection.java @@ -18,7 +18,7 @@ import java.util.*; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.*; import org.eclipse.jdt.ui.ISharedImages; import org.eclipse.jdt.ui.JavaUI; @@ -590,48 +590,44 @@ public void modelChanged(final IModelChangedEvent event) { } // Model change may have come from a non UI thread such as the auto add dependencies operation. See bug 333533 - UIJob job = new UIJob("Update package imports") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - if (Constants.IMPORT_PACKAGE.equals(event.getChangedProperty())) { - refresh(); - // Bug 171896 - // Since the model sends a CHANGE event instead of - // an INSERT event on the very first addition to the empty table - // Selection should fire here to take this first insertion into account - Object lastElement = fPackageViewer.getElementAt(fPackageViewer.getTable().getItemCount() - 1); - if (lastElement != null) { - fPackageViewer.setSelection(new StructuredSelection(lastElement)); - } - return Status.OK_STATUS; + UIJob job = UIJob.create("Update package imports", monitor -> { //$NON-NLS-1$ + if (Constants.IMPORT_PACKAGE.equals(event.getChangedProperty())) { + refresh(); + // Bug 171896 + // Since the model sends a CHANGE event instead of an INSERT + // event on the very first addition to the empty table Selection + // should fire here to take this first insertion into account + Object lastElement = fPackageViewer.getElementAt(fPackageViewer.getTable().getItemCount() - 1); + if (lastElement != null) { + fPackageViewer.setSelection(new StructuredSelection(lastElement)); } - + } else { Object[] objects = event.getChangedObjects(); for (Object changedObject : objects) { if (changedObject instanceof ImportPackageObject) { ImportPackageObject object = (ImportPackageObject) changedObject; - switch (event.getChangeType()) { - case IModelChangedEvent.INSERT : + switch (event.getChangeType()) + { + case IModelChangedEvent.INSERT: fPackageViewer.remove(object); // If another thread has modified the header, avoid creating a duplicate fPackageViewer.add(object); fPackageViewer.setSelection(new StructuredSelection(object)); fPackageViewer.getTable().setFocus(); break; - case IModelChangedEvent.REMOVE : + case IModelChangedEvent.REMOVE: Table table = fPackageViewer.getTable(); int index = table.getSelectionIndex(); fPackageViewer.remove(object); table.setSelection(index < table.getItemCount() ? index : table.getItemCount() - 1); updateButtons(); break; - default : + default: fPackageViewer.refresh(object); - } + } } } - return Status.OK_STATUS; } - }; + }); job.setSystem(true); job.schedule(); } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ManifestEditor.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ManifestEditor.java index 4f46c149694..67c378d2cb8 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ManifestEditor.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ManifestEditor.java @@ -24,9 +24,11 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.osgi.service.resolver.BaseDescription; import org.eclipse.osgi.service.resolver.BundleDescription; import org.eclipse.osgi.util.NLS; @@ -45,6 +47,7 @@ import org.eclipse.pde.internal.ui.editor.build.*; import org.eclipse.pde.internal.ui.editor.context.InputContext; import org.eclipse.pde.internal.ui.editor.context.InputContextManager; +import org.eclipse.pde.internal.ui.wizards.tools.OrganizeManifestsAction; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.*; import org.eclipse.ui.ide.FileStoreEditorInput; @@ -696,9 +699,23 @@ protected void setShowExtensions(boolean show) throws BackingStoreException { @Override public void contributeToToolbar(IToolBarManager manager) { contributeLaunchersToToolbar(manager); + manager.add(getOrganizeManifestsAction()); manager.add(getExportAction()); } + private Action getOrganizeManifestsAction() { + Action action = new Action() { + @Override + public void run() { + OrganizeManifestsAction organizeAction = new OrganizeManifestsAction(); + organizeAction.runOrganizeManfestsAction(new StructuredSelection(getCommonProject())); + } + }; + action.setToolTipText(PDEUIMessages.OrganizeManifestJob_taskName); + action.setImageDescriptor(PDEPluginImages.DESC_ORGANIZE_MANIFESTS_ACTION); + return action; + } + private PluginExportAction getExportAction() { if (fExportAction == null) { fExportAction = new PluginExportAction(this); diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/OverviewPage.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/OverviewPage.java index 18a9b4b58a7..d71bc318842 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/OverviewPage.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/OverviewPage.java @@ -18,7 +18,7 @@ import org.eclipse.core.commands.*; import org.eclipse.core.commands.common.NotDefinedException; import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.*; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.StructuredSelection; @@ -82,16 +82,15 @@ protected void createFormContent(IManagedForm managedForm) { // Add warning about missing manifest (Bug 407755) if (!isBundle() && isEditable()) { // We have to use a job so that the form header has been created - UIJob messageJob = new UIJob(PDEUIMessages.OverviewPage_ManifestWarning) { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - IManagedForm form = getManagedForm(); - if (form != null) { - form.getMessageManager().addMessage(PDEUIMessages.OverviewPage_ManifestWarning, isFragment() ? PDEUIMessages.OverviewPage_WarnAboutMissingManifestFragment : PDEUIMessages.OverviewPage_WarnAboutMissingManifest, null, IMessageProvider.WARNING); - } - return Status.OK_STATUS; + UIJob messageJob = UIJob.create(PDEUIMessages.OverviewPage_ManifestWarning, monitor -> { + IManagedForm form1 = getManagedForm(); + if (form1 != null) { + form1.getMessageManager().addMessage(PDEUIMessages.OverviewPage_ManifestWarning, isFragment() // + ? PDEUIMessages.OverviewPage_WarnAboutMissingManifestFragment + : PDEUIMessages.OverviewPage_WarnAboutMissingManifest// + , null, IMessageProvider.WARNING); } - }; + }); messageJob.setSystem(true); messageJob.schedule(); } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/RequiresSection.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/RequiresSection.java index cad16c615be..7ab9020bc10 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/RequiresSection.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/RequiresSection.java @@ -18,7 +18,7 @@ import java.io.*; import java.util.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.*; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; @@ -545,16 +545,11 @@ public void modelChanged(final IModelChangedEvent event) { } // Model change may have come from a non UI thread such as the auto add dependencies operation. See bug 333533 - UIJob job = new UIJob("Update required bundles") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - - if (event.getChangedProperty() == IPluginBase.P_IMPORT_ORDER) { - refresh(); - updateButtons(); - return Status.OK_STATUS; - } - + UIJob job = UIJob.create("Update required bundles", monitor -> { //$NON-NLS-1$ + if (event.getChangedProperty() == IPluginBase.P_IMPORT_ORDER) { + refresh(); + updateButtons(); + } else { Object[] changedObjects = event.getChangedObjects(); if (changedObjects[0] instanceof IPluginImport) { int index = 0; @@ -614,10 +609,8 @@ public IStatus runInUIThread(IProgressMonitor monitor) { } else { fImportViewer.update(fImportViewer.getStructuredSelection().toArray(), null); } - - return Status.OK_STATUS; } - }; + }); job.setSystem(true); job.schedule(); } @@ -648,9 +641,11 @@ private ImportObject findImportObject(IPluginImport iimport) { private void createImportObjects() { fImports = new Vector<>(); IPluginModelBase model = (IPluginModelBase) getPage().getModel(); - IPluginImport[] iimports = model.getPluginBase().getImports(); - for (IPluginImport iimport : iimports) { - fImports.add(new ImportObject(iimport)); + if (model != null) { + IPluginImport[] iimports = model.getPluginBase().getImports(); + for (IPluginImport iimport : iimports) { + fImports.add(new ImportObject(iimport)); + } } } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/product/ProductValidateAction.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/product/ProductValidateAction.java index 9b629e6df00..c69ee4cb881 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/product/ProductValidateAction.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/product/ProductValidateAction.java @@ -28,7 +28,7 @@ public class ProductValidateAction extends Action { - IProduct fProduct; + private final IProduct fProduct; public ProductValidateAction(IProduct product) { super(PDEUIMessages.ProductValidateAction_validate, IAction.AS_PUSH_BUTTON); @@ -38,8 +38,8 @@ public ProductValidateAction(IProduct product) { @Override public void run() { - Set launchPlugins = LaunchAction.getModels(fProduct); try { + Set launchPlugins = LaunchAction.getLaunchedBundlesForProduct(fProduct); LaunchValidationOperation operation = new ProductValidationOperation(launchPlugins); LaunchPluginValidator.runValidationOperation(operation, new NullProgressMonitor()); if (!operation.hasErrors()) { diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java index 9789e3bb9cd..036f15c8d26 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java @@ -620,23 +620,19 @@ public boolean belongsTo(Object family) { @Override public void done(org.eclipse.core.runtime.jobs.IJobChangeEvent event) { final IStatus status = event.getResult(); - UIJob job = new UIJob(PDEUIMessages.TargetEditor_2) { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - if (fContentTree != null) { - if (status.getSeverity() == IStatus.CANCEL) { - fContentTree.setCancelled(); - } else { - fContentTree.setInput(getTarget()); - } + UIJob job = UIJob.create(PDEUIMessages.TargetEditor_2, monitor -> { + if (fContentTree != null) { + if (status.getSeverity() == IStatus.CANCEL) { + fContentTree.setCancelled(); + } else { + fContentTree.setInput(getTarget()); } - if (fLocationTree != null) { - fLocationTree.setInput(getTarget()); - fLocationTree.setExpandCollapseState(true); - } - return Status.OK_STATUS; } - }; + if (fLocationTree != null) { + fLocationTree.setInput(getTarget()); + fLocationTree.setExpandCollapseState(true); + } + }); job.setSystem(true); job.schedule(); } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditorContributor.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditorContributor.java index 3ebf7b95259..72c076414bb 100755 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditorContributor.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditorContributor.java @@ -65,11 +65,4 @@ private IAction getRevertAction() { } return fRevertAction; } - -// public void setActivePage(IEditorPart activeEditor) { -// // TODO Revert action is not working correctly, activeEditor is always null -// fEditor = (TargetEditor) activeEditor; -// getActionBars().setGlobalActionHandler(ActionFactory.REVERT.getId(), new RevertAction()); -// getActionBars().updateActionBars(); -// } } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/LaunchAction.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/LaunchAction.java index 86362f95ff9..48965a3728b 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/LaunchAction.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/LaunchAction.java @@ -34,6 +34,7 @@ import org.eclipse.pde.internal.core.ifeature.*; import org.eclipse.pde.internal.core.iproduct.*; import org.eclipse.pde.internal.core.iproduct.IProduct; +import org.eclipse.pde.internal.core.text.plugin.PluginModelBase; import org.eclipse.pde.internal.core.util.CoreUtility; import org.eclipse.pde.internal.launching.IPDEConstants; import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper; @@ -50,6 +51,20 @@ public class LaunchAction extends Action { private static final String DEFAULT = "default"; //$NON-NLS-1$ + /** + * Returns the complete Set of all {@link PluginModelBase plugins} launched + * for the given product. This for example also includes transitive + * dependencies, if the product is configured to include them. + */ + public static Set getLaunchedBundlesForProduct(IProduct product) + throws CoreException { + IResource resource = product.getModel().getUnderlyingResource(); + IPath fullPath = resource != null ? resource.getFullPath() : Path.fromOSString(product.getProductId()); + LaunchAction launchAction = new LaunchAction(product, fullPath, null); + ILaunchConfigurationWorkingCopy config = launchAction.createConfiguration(); + return BundleLauncherHelper.getMergedBundleMap(config, false).keySet(); + } + private IProduct fProduct; private String fMode; private IPath fPath; @@ -79,19 +94,19 @@ public ILaunchConfiguration findLaunchConfiguration() throws CoreException { List configs = getLaunchConfigurations(); if (configs.isEmpty()) { - return createConfiguration(); + return createConfiguration().doSave(); } ILaunchConfiguration config = configs.size() == 1 // ? configs.get(0) : chooseConfiguration(configs); // Prompt the user to choose one if (config != null) { - config = refreshConfiguration(config.getWorkingCopy()); + config = refreshConfiguration(config.getWorkingCopy()).doSave(); } return config; } - private ILaunchConfiguration refreshConfiguration(ILaunchConfigurationWorkingCopy wc) throws CoreException { + private ILaunchConfigurationWorkingCopy refreshConfiguration(ILaunchConfigurationWorkingCopy wc) { wc.setAttribute(IPDELauncherConstants.PRODUCT, fProduct.getProductId()); wc.setAttribute(IPDELauncherConstants.APPLICATION, fProduct.getApplication()); @@ -131,7 +146,7 @@ private ILaunchConfiguration refreshConfiguration(ILaunchConfigurationWorkingCop if (configIni != null) { wc.setAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, configIni); } - return wc.doSave(); + return wc; } private void refreshFeatureLaunchPlugins(ILaunchConfigurationWorkingCopy wc, Set allModels) { @@ -346,7 +361,7 @@ private ILaunchConfiguration chooseConfiguration(List conf return result == Window.OK ? (ILaunchConfiguration) dialog.getFirstResult() : null; } - private ILaunchConfiguration createConfiguration() throws CoreException { + private ILaunchConfigurationWorkingCopy createConfiguration() throws CoreException { ILaunchConfigurationType configType = getWorkbenchLaunchConfigType(); String computedName = getComputedName(fPath.lastSegment()); ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, computedName); diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties index 5f4d26dd432..186c2cc2892 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties @@ -349,6 +349,11 @@ MainPreferencePage_notNow=Not now MainPreferencePage_AddSwtNonDisposedToVMArguments=&Enable SWT reporting of non-disposed resources when creating a new launch configuration MainPreferencePage_AddSwtNonDisposedToVMArgumentsToolTop=Add '-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true' to VM arguments when creating a new launch configuration MainPreferencePage_addToJavaSearch=Include all plug-ins from target in &Java workspace scope +MainPreferencePage_BundlePoolPrefsCleanBtn=Clean +MainPreferencePage_BundlePoolPrefsCleanDesc=Clean bundle pool of artifacts that are not in the active target platform +MainPreferencePage_BundlePoolPrefsError=Error +MainPreferencePage_BundlePoolPrefsErrorCleaning=There was an error cleaning the bundle pool ({0}). See log for more details. +MainPreferencePage_BundlePoolPrefsGroup=Bundle Pool MainPreferencePage_junitWorkspace_asContainer=Append launch configuration &name to this location MainPreferencePage_junitWorkspace_asLocation=Us&e as workspace location MainPreferencePage_junitWorkspace_fileSystem=File S&ystem... diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java index 78de1b01671..9a5b5effa1f 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java @@ -16,6 +16,8 @@ import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; +import java.lang.reflect.InvocationTargetException; +import java.text.MessageFormat; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import org.eclipse.core.resources.IProject; @@ -24,13 +26,16 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialogWithToggle; import org.eclipse.jface.fieldassist.TextContentAdapter; +import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.FindReplaceDocumentAdapterContentProposalProvider; +import org.eclipse.jface.widgets.WidgetFactory; import org.eclipse.jface.window.Window; import org.eclipse.pde.core.target.ITargetPlatformService; import org.eclipse.pde.internal.core.*; +import org.eclipse.pde.internal.core.target.P2TargetUtils; import org.eclipse.pde.internal.core.target.TargetPlatformService; import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants; import org.eclipse.pde.internal.launching.PDELaunchingPlugin; @@ -38,6 +43,7 @@ import org.eclipse.pde.internal.ui.launcher.BaseBlock; import org.eclipse.pde.internal.ui.shared.target.TargetStatus; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -48,7 +54,8 @@ import org.osgi.service.prefs.BackingStoreException; /** - * This is the top level preference page for PDE. It contains a random assortment of preferences that don't belong to other pages. + * This is the top level preference page for PDE. It contains a random + * assortment of preferences that don't belong to other pages. * */ public class MainPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { @@ -60,7 +67,8 @@ private final class DefaultRuntimeWorkspaceBlock extends BaseBlock { } public void createControl(Composite parent) { - Group group = SWTFactory.createGroup(parent, PDEUIMessages.MainPreferencePage_runtimeWorkspaceGroup, 2, 1, GridData.FILL_HORIZONTAL); + Group group = SWTFactory.createGroup(parent, PDEUIMessages.MainPreferencePage_runtimeWorkspaceGroup, 2, 1, + GridData.FILL_HORIZONTAL); Composite radios = SWTFactory.createComposite(group, 2, 2, GridData.FILL_HORIZONTAL, 0, 0); fRuntimeWorkspaceLocationRadio = new Button(radios, SWT.RADIO); @@ -76,8 +84,12 @@ public void createControl(Composite parent) { ((GridData) fLocationText.getLayoutData()).widthHint = 200; fRuntimeWorkspaceLocation = fLocationText; - Composite buttons = SWTFactory.createComposite(group, 3, 2, GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL, 0, 0); - createButtons(buttons, new String[] {PDEUIMessages.MainPreferencePage_runtimeWorkspace_workspace, PDEUIMessages.MainPreferencePage_runtimeWorkspace_fileSystem, PDEUIMessages.MainPreferencePage_runtimeWorkspace_variables}); + Composite buttons = SWTFactory.createComposite(group, 3, 2, + GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL, 0, 0); + createButtons(buttons, + new String[] { PDEUIMessages.MainPreferencePage_runtimeWorkspace_workspace, + PDEUIMessages.MainPreferencePage_runtimeWorkspace_fileSystem, + PDEUIMessages.MainPreferencePage_runtimeWorkspace_variables }); } @Override @@ -98,7 +110,8 @@ private final class DefaultJUnitWorkspaceBlock extends BaseBlock { } public void createControl(Composite parent) { - Group group = SWTFactory.createGroup(parent, PDEUIMessages.MainPreferencePage_junitWorkspaceGroup, 2, 1, GridData.FILL_HORIZONTAL); + Group group = SWTFactory.createGroup(parent, PDEUIMessages.MainPreferencePage_junitWorkspaceGroup, 2, 1, + GridData.FILL_HORIZONTAL); Composite radios = SWTFactory.createComposite(group, 2, 2, GridData.FILL_HORIZONTAL, 0, 0); fJUnitWorkspaceLocationRadio = new Button(radios, SWT.RADIO); @@ -114,8 +127,12 @@ public void createControl(Composite parent) { ((GridData) fLocationText.getLayoutData()).widthHint = 200; fJUnitWorkspaceLocation = fLocationText; - Composite buttons = SWTFactory.createComposite(group, 3, 2, GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL, 0, 0); - createButtons(buttons, new String[] {PDEUIMessages.MainPreferencePage_junitWorkspace_workspace, PDEUIMessages.MainPreferencePage_junitWorkspace_fileSystem, PDEUIMessages.MainPreferencePage_junitWorkspace_variables}); + Composite buttons = SWTFactory.createComposite(group, 3, 2, + GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL, 0, 0); + createButtons(buttons, + new String[] { PDEUIMessages.MainPreferencePage_junitWorkspace_workspace, + PDEUIMessages.MainPreferencePage_junitWorkspace_fileSystem, + PDEUIMessages.MainPreferencePage_junitWorkspace_variables }); } @Override @@ -172,7 +189,8 @@ protected Control createContents(Composite parent) { fOverwriteBuildFiles = new Button(optionComp, SWT.CHECK); fOverwriteBuildFiles.setText(PDEUIMessages.MainPreferencePage_promptBeforeOverwrite); - fOverwriteBuildFiles.setSelection(!MessageDialogWithToggle.ALWAYS.equals(store.getString(IPreferenceConstants.OVERWRITE_BUILD_FILES_ON_EXPORT))); + fOverwriteBuildFiles.setSelection(!MessageDialogWithToggle.ALWAYS + .equals(store.getString(IPreferenceConstants.OVERWRITE_BUILD_FILES_ON_EXPORT))); fAutoManage = new Button(optionComp, SWT.CHECK); fAutoManage.setText(PDEUIMessages.MainPreferencePage_updateStale); @@ -180,8 +198,12 @@ protected Control createContents(Composite parent) { fPromptOnRemove = new Button(optionComp, SWT.CHECK); fPromptOnRemove.setText(PDEUIMessages.MainPreferencePage_promtBeforeRemove); - fPromptOnRemove.setSelection(!MessageDialogWithToggle.ALWAYS.equals(store.getString(IPreferenceConstants.PROP_PROMPT_REMOVE_TARGET))); - fPromptOnRemove.addSelectionListener(widgetSelectedAdapter(e -> PDEPlugin.getDefault().getPreferenceStore().setValue(IPreferenceConstants.PROP_PROMPT_REMOVE_TARGET, fPromptOnRemove.getSelection() ? MessageDialogWithToggle.PROMPT : MessageDialogWithToggle.ALWAYS))); + fPromptOnRemove.setSelection(!MessageDialogWithToggle.ALWAYS + .equals(store.getString(IPreferenceConstants.PROP_PROMPT_REMOVE_TARGET))); + fPromptOnRemove.addSelectionListener(widgetSelectedAdapter(e -> PDEPlugin.getDefault().getPreferenceStore() + .setValue(IPreferenceConstants.PROP_PROMPT_REMOVE_TARGET, + fPromptOnRemove.getSelection() ? MessageDialogWithToggle.PROMPT + : MessageDialogWithToggle.ALWAYS))); fAddToJavaSearch = new Button(optionComp, SWT.CHECK); fAddToJavaSearch.setText(PDEUIMessages.MainPreferencePage_addToJavaSearch); @@ -196,7 +218,6 @@ protected Control createContents(Composite parent) { fAlwaysPreferWorkspace.setSelection(store.getBoolean(IPreferenceConstants.WORKSPACE_PLUGINS_OVERRIDE_TARGET)); fAlwaysPreferWorkspace.setToolTipText(PDEUIMessages.MainPreferencePage_WorkspacePluginsOverrideTargetTooltip); - fDisableAPIAnalysisBuilder = new Button(optionComp, SWT.CHECK); fDisableAPIAnalysisBuilder.setText(PDEUIMessages.MainPreferencePage_DisableAPIAnalysisBuilder); fDisableAPIAnalysisBuilder.setSelection(store.getBoolean(IPreferenceConstants.DISABLE_API_ANALYSIS_BUILDER)); @@ -226,8 +247,7 @@ protected Control createContents(Composite parent) { pathComposite.setFont(optionComp.getFont()); Group testGroup = SWTFactory.createGroup(composite, PDEUIMessages.MainPreferencePage_test_plugin_pattern_group, - 2, 1, - GridData.FILL_HORIZONTAL); + 2, 1, GridData.FILL_HORIZONTAL); Label testPluginPatternDescription = new Label(testGroup, SWT.LEFT); testPluginPatternDescription.setText(PDEUIMessages.MainPreferencePage_test_plugin_pattern_description); testPluginPatternDescription.setFont(JFaceResources.getDialogFont()); @@ -255,22 +275,24 @@ protected Control createContents(Composite parent) { FindReplaceDocumentAdapterContentProposalProvider findProposer = new FindReplaceDocumentAdapterContentProposalProvider( true); ContentAssistCommandAdapter contentAssist = new ContentAssistCommandAdapter(fTestPluginPatternText, - contentAdapter, - findProposer, ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0], true); + contentAdapter, findProposer, ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0], + true); contentAssist.setEnabled(true); Label testPluginPatternNote = new Label(testGroup, SWT.LEFT); testPluginPatternNote.setText(PDEUIMessages.MainPreferencePage_test_plugin_pattern_note); testPluginPatternNote.setFont(JFaceResources.getDialogFont()); testPluginPatternNote.setLayoutData(gd2); - Group group = SWTFactory.createGroup(composite, PDEUIMessages.Preferences_MainPage_showObjects, 2, 1, GridData.FILL_HORIZONTAL); + Group group = SWTFactory.createGroup(composite, PDEUIMessages.Preferences_MainPage_showObjects, 2, 1, + GridData.FILL_HORIZONTAL); fUseID = new Button(group, SWT.RADIO); fUseID.setText(PDEUIMessages.Preferences_MainPage_useIds); fUseName = new Button(group, SWT.RADIO); fUseName.setText(PDEUIMessages.Preferences_MainPage_useFullNames); - fShowSourceBundles = SWTFactory.createCheckButton(group, PDEUIMessages.MainPreferencePage_showSourceBundles, null, store.getBoolean(IPreferenceConstants.PROP_SHOW_SOURCE_BUNDLES), 2); + fShowSourceBundles = SWTFactory.createCheckButton(group, PDEUIMessages.MainPreferencePage_showSourceBundles, + null, store.getBoolean(IPreferenceConstants.PROP_SHOW_SOURCE_BUNDLES), 2); if (store.getString(IPreferenceConstants.PROP_SHOW_OBJECTS).equals(IPreferenceConstants.VALUE_USE_IDS)) { fUseID.setSelection(true); @@ -279,20 +301,52 @@ protected Control createContents(Composite parent) { } new DefaultRuntimeWorkspaceBlock().createControl(composite); - fRuntimeWorkspaceLocation.setText(launchingStore.getString(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION)); - boolean runtimeLocationIsContainer = launchingStore.getBoolean(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER); + fRuntimeWorkspaceLocation + .setText(launchingStore.getString(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION)); + boolean runtimeLocationIsContainer = launchingStore + .getBoolean(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER); fRuntimeWorkspaceLocationRadio.setSelection(!runtimeLocationIsContainer); fRuntimeWorkspacesContainerRadio.setSelection(runtimeLocationIsContainer); new DefaultJUnitWorkspaceBlock().createControl(composite); - fJUnitWorkspaceLocation.setText(launchingStore.getString(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION)); - boolean jUnitLocationIsContainer = launchingStore.getBoolean(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION_IS_CONTAINER); + fJUnitWorkspaceLocation + .setText(launchingStore.getString(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION)); + boolean jUnitLocationIsContainer = launchingStore + .getBoolean(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION_IS_CONTAINER); fJUnitWorkspaceLocationRadio.setSelection(!jUnitLocationIsContainer); fJUnitWorkspacesContainerRadio.setSelection(jUnitLocationIsContainer); + Group bundlePoolGp = SWTFactory.createGroup(composite, PDEUIMessages.MainPreferencePage_BundlePoolPrefsGroup, 2, + 1, GridData.FILL_HORIZONTAL); + WidgetFactory.label(SWT.WRAP) + .layoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create()) + .text(PDEUIMessages.MainPreferencePage_BundlePoolPrefsCleanDesc).create(bundlePoolGp); + WidgetFactory.button(SWT.PUSH).text(PDEUIMessages.MainPreferencePage_BundlePoolPrefsCleanBtn) + .layoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).create()).create(bundlePoolGp) + .addSelectionListener(SelectionListener.widgetSelectedAdapter(this::handleClean)); + return composite; } + private void handleClean(SelectionEvent event) { + // User pushed the "Clean" button to clean the bundle pool + // Disable the button first until we are done + ((Button) event.widget).setEnabled(false); + + try { + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> P2TargetUtils.garbageCollect()); + } catch (InterruptedException e) { + // Nothing, let them cancel + } catch (InvocationTargetException e) { + PDEPlugin.log(e); + MessageDialog.openError(getShell(), PDEUIMessages.MainPreferencePage_BundlePoolPrefsError, MessageFormat + .format(PDEUIMessages.MainPreferencePage_BundlePoolPrefsErrorCleaning, e.getMessage())); + } finally { + // Reenable the button so they can do it again + ((Button) event.widget).setEnabled(true); + } + } + private boolean validateRegex() { try { Pattern.compile(fTestPluginPatternText.getText()); @@ -329,7 +383,8 @@ public boolean performOk() { } else { store.setValue(IPreferenceConstants.PROP_SHOW_OBJECTS, IPreferenceConstants.VALUE_USE_NAMES); } - store.setValue(IPreferenceConstants.OVERWRITE_BUILD_FILES_ON_EXPORT, fOverwriteBuildFiles.getSelection() ? MessageDialogWithToggle.PROMPT : MessageDialogWithToggle.ALWAYS); + store.setValue(IPreferenceConstants.OVERWRITE_BUILD_FILES_ON_EXPORT, + fOverwriteBuildFiles.getSelection() ? MessageDialogWithToggle.PROMPT : MessageDialogWithToggle.ALWAYS); store.setValue(IPreferenceConstants.PROP_SHOW_SOURCE_BUNDLES, fShowSourceBundles.getSelection()); boolean synchJavaSearch = fAddToJavaSearch.getSelection(); @@ -349,7 +404,8 @@ public boolean performOk() { boolean useWorkspace = fAlwaysPreferWorkspace.getSelection(); if (store.getBoolean(IPreferenceConstants.WORKSPACE_PLUGINS_OVERRIDE_TARGET) != useWorkspace) { - store.setValue(IPreferenceConstants.WORKSPACE_PLUGINS_OVERRIDE_TARGET, fAlwaysPreferWorkspace.getSelection()); + store.setValue(IPreferenceConstants.WORKSPACE_PLUGINS_OVERRIDE_TARGET, + fAlwaysPreferWorkspace.getSelection()); PDEPreferencesManager prefs = PDECore.getDefault().getPreferencesManager(); prefs.setValue(ICoreConstants.WORKSPACE_PLUGINS_OVERRIDE_TARGET, fAlwaysPreferWorkspace.getSelection()); try { @@ -372,10 +428,10 @@ public boolean performOk() { TargetStatus.refreshTargetStatus(); } - boolean disableAPIAnalysisBuilder = fDisableAPIAnalysisBuilder.getSelection(); if (store.getBoolean(IPreferenceConstants.DISABLE_API_ANALYSIS_BUILDER) != disableAPIAnalysisBuilder) { - store.setValue(IPreferenceConstants.DISABLE_API_ANALYSIS_BUILDER, fDisableAPIAnalysisBuilder.getSelection()); + store.setValue(IPreferenceConstants.DISABLE_API_ANALYSIS_BUILDER, + fDisableAPIAnalysisBuilder.getSelection()); PDEPreferencesManager prefs = PDECore.getDefault().getPreferencesManager(); prefs.setValue(ICoreConstants.DISABLE_API_ANALYSIS_BUILDER, fDisableAPIAnalysisBuilder.getSelection()); IProject[] projects = BuildJob.getApiProjects(); @@ -410,10 +466,14 @@ public boolean performOk() { PDEPreferencesManager launchingStore = PDELaunchingPlugin.getDefault().getPreferenceManager(); launchingStore.setValueOrRemove(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE, fAutoManage.getSelection()); - launchingStore.setValueOrRemove(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION, fRuntimeWorkspaceLocation.getText()); - launchingStore.setValueOrRemove(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER, fRuntimeWorkspacesContainerRadio.getSelection()); - launchingStore.setValueOrRemove(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION, fJUnitWorkspaceLocation.getText()); - launchingStore.setValueOrRemove(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION_IS_CONTAINER, fJUnitWorkspacesContainerRadio.getSelection()); + launchingStore.setValueOrRemove(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION, + fRuntimeWorkspaceLocation.getText()); + launchingStore.setValueOrRemove(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER, + fRuntimeWorkspacesContainerRadio.getSelection()); + launchingStore.setValueOrRemove(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION, + fJUnitWorkspaceLocation.getText()); + launchingStore.setValueOrRemove(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION_IS_CONTAINER, + fJUnitWorkspacesContainerRadio.getSelection()); try { launchingStore.flush(); } catch (BackingStoreException e) { @@ -440,29 +500,36 @@ protected void performDefaults() { fAddToJavaSearch.setSelection(store.getDefaultBoolean(IPreferenceConstants.ADD_TO_JAVA_SEARCH)); fShowTargetStatus.setSelection(store.getDefaultBoolean(IPreferenceConstants.SHOW_TARGET_STATUS)); - fAlwaysPreferWorkspace.setSelection(store.getDefaultBoolean(IPreferenceConstants.WORKSPACE_PLUGINS_OVERRIDE_TARGET)); + fAlwaysPreferWorkspace + .setSelection(store.getDefaultBoolean(IPreferenceConstants.WORKSPACE_PLUGINS_OVERRIDE_TARGET)); fRunAPIAnalysisBuilderAsJob.setEnabled(true); fRunAPIAnalysisBuilderAsJob.setSelection( PDECore.getDefault().getPreferencesManager().getDefaultBoolean(ICoreConstants.RUN_API_ANALYSIS_AS_JOB)); - fDisableAPIAnalysisBuilder.setSelection(store.getDefaultBoolean(IPreferenceConstants.DISABLE_API_ANALYSIS_BUILDER)); + fDisableAPIAnalysisBuilder + .setSelection(store.getDefaultBoolean(IPreferenceConstants.DISABLE_API_ANALYSIS_BUILDER)); fAddSwtNonDisposalReporting .setSelection(store.getDefaultBoolean(IPreferenceConstants.ADD_SWT_NON_DISPOSAL_REPORTING)); fTestPluginPatternText.setText(store.getDefaultString(IPreferenceConstants.TEST_PLUGIN_PATTERN)); PDEPreferencesManager launchingStore = PDELaunchingPlugin.getDefault().getPreferenceManager(); - boolean runtimeLocationIsContainer = launchingStore.getDefaultBoolean(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER); + boolean runtimeLocationIsContainer = launchingStore + .getDefaultBoolean(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER); fRuntimeWorkspaceLocationRadio.setSelection(!runtimeLocationIsContainer); fRuntimeWorkspacesContainerRadio.setSelection(runtimeLocationIsContainer); - fRuntimeWorkspaceLocation.setText(launchingStore.getDefaultString(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION)); + fRuntimeWorkspaceLocation.setText( + launchingStore.getDefaultString(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION)); - boolean jUnitLocationIsContainer = launchingStore.getDefaultBoolean(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION_IS_CONTAINER); + boolean jUnitLocationIsContainer = launchingStore + .getDefaultBoolean(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION_IS_CONTAINER); fJUnitWorkspaceLocationRadio.setSelection(!jUnitLocationIsContainer); fJUnitWorkspacesContainerRadio.setSelection(jUnitLocationIsContainer); - fJUnitWorkspaceLocation.setText(launchingStore.getDefaultString(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION)); + fJUnitWorkspaceLocation + .setText(launchingStore.getDefaultString(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION)); } @Override public void setVisible(boolean visible) { - fPromptOnRemove.setSelection(!MessageDialogWithToggle.ALWAYS.equals(PDEPlugin.getDefault().getPreferenceManager().getString(IPreferenceConstants.PROP_PROMPT_REMOVE_TARGET))); + fPromptOnRemove.setSelection(!MessageDialogWithToggle.ALWAYS.equals(PDEPlugin.getDefault() + .getPreferenceManager().getString(IPreferenceConstants.PROP_PROMPT_REMOVE_TARGET))); super.setVisible(visible); } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/TargetPlatformPreferencePage.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/TargetPlatformPreferencePage.java index dd15c4c5c67..ba48d12b916 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/TargetPlatformPreferencePage.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/TargetPlatformPreferencePage.java @@ -182,27 +182,13 @@ public void applyStyles(TextStyle textStyle) { * target with the same handle */ private boolean isResolved(ITargetDefinition target) { - boolean isResolved = false; if (target.equals(fActiveTarget) && target.isResolved()) { - isResolved = true; - - } else { - // checked earlier status of earlier resolved targets - HashMap> targetFlagMap = TargetPlatformHelper - .getTargetDefinitionMap(); - for (Entry> entry : targetFlagMap.entrySet()) { - if (entry.getKey().equals(target.getHandle())) { - if (!entry.getValue().isEmpty()) { - if (entry.getValue().get(0).isContentEquivalent(target)) { - isResolved = true; - break; - } - } - } - } + return true; } - return isResolved; - + // checked earlier status of earlier resolved targets + Map> targetFlagMap = TargetPlatformHelper.getTargetDefinitionMap(); + List targets = targetFlagMap.get(target.getHandle()); + return targets != null && !targets.isEmpty() && targets.get(0).isContentEquivalent(target); } private Image getImage(ITargetDefinition target) { @@ -218,31 +204,24 @@ private Image getImage(ITargetDefinition target) { } else { // checked earlier status of earlier resolved targets boolean isResolved = false; - HashMap> targetFlagMap = TargetPlatformHelper - .getTargetDefinitionMap(); - for (Entry> entry : targetFlagMap.entrySet()) { - if (entry.getKey().equals(target.getHandle())) { - List targetList = entry.getValue(); - if (!targetList.isEmpty()) { - if (targetList.get(0).isContentEquivalent(target) - && targetList.get(0).getStatus() != null) { - int value = targetList.get(0).getStatus().getSeverity(); - if (value == IStatus.WARNING) { - flag = SharedLabelProvider.F_WARNING; - } else if (value == IStatus.ERROR) { - flag = SharedLabelProvider.F_ERROR; - } - isResolved = true; - } - else - isResolved = false; - break; - + List targets = TargetPlatformHelper.getTargetDefinitionMap().get(target.getHandle()); + if (targets != null && !targets.isEmpty()) { + TargetDefinition targetDef = targets.get(0); + if (targetDef.isContentEquivalent(target) && targetDef.getStatus() != null) { + int value = targetDef.getStatus().getSeverity(); + if (value == IStatus.WARNING) { + flag = SharedLabelProvider.F_WARNING; + } else if (value == IStatus.ERROR) { + flag = SharedLabelProvider.F_ERROR; } + isResolved = true; + } else { + isResolved = false; } } - if (isResolved == false) + if (!isResolved) { flag = SharedLabelProvider.F_WARNING; + } } if (target.getTargetLocations() == null) flag = 0; @@ -396,19 +375,15 @@ private void createTargetProfilesGroup(Composite container) { job.addJobChangeListener(new JobChangeAdapter() { @Override public void done(final IJobChangeEvent event) { - UIJob job = new UIJob(Messages.UpdateTargetJob_UpdateJobName) { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - TargetDefinition target = ((LoadDefaultTargetJob) event.getJob()).defaultTarget; - if (target != null && fLabelProvider != null) { - fLabelProvider.setDefaultTarget(target); - if (fTableViewer != null && !fTableViewer.getTable().isDisposed()) { - fTableViewer.refresh(true); - } + UIJob job = UIJob.create(Messages.UpdateTargetJob_UpdateJobName, monitor -> { + TargetDefinition target = ((LoadDefaultTargetJob) event.getJob()).defaultTarget; + if (target != null && fLabelProvider != null) { + fLabelProvider.setDefaultTarget(target); + if (fTableViewer != null && !fTableViewer.getTable().isDisposed()) { + fTableViewer.refresh(true); } - return Status.OK_STATUS; } - }; + }); job.schedule(); } }); diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java index 13fe2314f38..1410a351c2c 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java @@ -60,7 +60,7 @@ public class Messages extends NLS { public static String BundleContainerTable_Btn_Text_Edit; public static String BundleContainerTable_Btn_Text_Remove; public static String BundleContainerTable_Btn_Text_Update; - public static String BundleContainerTable_Btn_Text_Reload; + public static String BundleContainerTable_Btn_Text_Refresh; public static String BundleContainerTable_Btn_Text_ExpandAll; public static String BundleContainerTable_Btn_Text_CollapseAll; public static String BundleContainerTable_8; @@ -132,9 +132,11 @@ public class Messages extends NLS { public static String TargetContentsGroup_OtherPluginsParent; public static String TargetContentsGroup_PluginMode; public static String TargetContentsGroup_resolveCancelled; + public static String TargetLocationsGroup_update; - public static String TargetLocationsGroup_reload; + public static String TargetLocationsGroup_refresh; public static String TargetLocationsGroup_1; + public static String TargetLocationsGroup_TargetUpdateErrorDialog; public static String TargetStatus_NoActiveTargetPlatformStatus; public static String TargetStatus_TargetStatusDefaultString; diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/StyledBundleLabelProvider.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/StyledBundleLabelProvider.java index 216a5e03fda..1cb71c3a824 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/StyledBundleLabelProvider.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/StyledBundleLabelProvider.java @@ -80,8 +80,7 @@ public void update(ViewerCell cell) { protected StyledString getStyledString(Object element) { return Optional - .ofNullable(Adapters.adapt(element, - DelegatingStyledCellLabelProvider.IStyledLabelProvider.class)) + .ofNullable(Adapters.adapt(element, DelegatingStyledCellLabelProvider.IStyledLabelProvider.class)) .map(styleProvider -> styleProvider.getStyledText(element)).or(() -> { return Optional.ofNullable(Adapters.adapt(element, ILabelProvider.class)).map(provider -> { if (provider instanceof StyledBundleLabelProvider) { @@ -277,8 +276,7 @@ private void appendBundleCount(StyledString styledString, ITargetLocation contai @Override public Image getImage(Object element) { return Optional - .ofNullable(Adapters.adapt(element, - DelegatingStyledCellLabelProvider.IStyledLabelProvider.class)) + .ofNullable(Adapters.adapt(element, DelegatingStyledCellLabelProvider.IStyledLabelProvider.class)) .map(styleProvider -> styleProvider.getImage(element)).or(() -> { return Optional.ofNullable(Adapters.adapt(element, ILabelProvider.class)).map(provider -> { @@ -356,9 +354,8 @@ private Image getInternalImage(Object element) { flag = SharedLabelProvider.F_ERROR; } } else { - HashMap> targetFlagMap = TargetPlatformHelper - .getTargetDefinitionMap(); - for (List targetDefinitionValues : targetFlagMap.values()) { + Collection> targetFlags = TargetPlatformHelper.getTargetDefinitionMap().values(); + for (List targetDefinitionValues : targetFlags) { if (!targetDefinitionValues.isEmpty()) { ITargetLocation[] locs = targetDefinitionValues.get(0).getTargetLocations(); if (locs != null) { diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationContentProvider.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationContentProvider.java index 2e4dc0ea631..5a0e17ba1f6 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationContentProvider.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationContentProvider.java @@ -60,9 +60,8 @@ public Object[] getChildren(Object parentElement) { } } } else { - HashMap> targetFlagMap = TargetPlatformHelper - .getTargetDefinitionMap(); - for (List targetDefinitionValues : targetFlagMap.values()) { + Collection> targetFlags = TargetPlatformHelper.getTargetDefinitionMap().values(); + for (List targetDefinitionValues : targetFlags) { if (!targetDefinitionValues.isEmpty()) { ITargetLocation[] locs = targetDefinitionValues.get(0).getTargetLocations(); if (locs != null) { diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java index 4442f83de8a..4e65c2794c0 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java @@ -88,7 +88,7 @@ static DeleteButtonState computeState(boolean canRemove, boolean canEnable, bool private Button fEditButton; private Button fRemoveButton; private Button fUpdateButton; - private Button fReloadButton; + private Button fRefreshButton; private Button fExpandCollapseButton; private Button fShowContentButton; @@ -189,9 +189,10 @@ private void createFormContents(Composite parent, FormToolkit toolkit) { fRemoveButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Remove, SWT.PUSH); fUpdateButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Update, SWT.PUSH); fUpdateButton.setToolTipText(Messages.TargetLocationsGroup_update); - fReloadButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Reload, SWT.PUSH); - fReloadButton.setToolTipText(Messages.TargetLocationsGroup_reload); - fExpandCollapseButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_Btn_Text_ExpandAll, SWT.PUSH); + fRefreshButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Refresh, SWT.PUSH); + fRefreshButton.setToolTipText(Messages.TargetLocationsGroup_refresh); + fExpandCollapseButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_Btn_Text_ExpandAll, + SWT.PUSH); fShowContentButton = toolkit.createButton(comp, Messages.TargetLocationsGroup_1, SWT.CHECK); @@ -229,8 +230,9 @@ private void createDialogContents(Composite parent) { fEditButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Edit, null); fRemoveButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Remove, null); fUpdateButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Update, null); - fReloadButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Reload, null); - fExpandCollapseButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_Btn_Text_ExpandAll, null); + fRefreshButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Refresh, null); + fExpandCollapseButton = SWTFactory.createPushButton(buttonComp, + Messages.BundleContainerTable_Btn_Text_ExpandAll, null); fShowContentButton = SWTFactory.createCheckButton(comp, Messages.TargetLocationsGroup_1, null, false, 2); @@ -285,9 +287,11 @@ public int compare(Viewer viewer, Object e1, Object e2) { public void mouseDoubleClick(MouseEvent e) { setExpandCollapseState(); } + @Override public void mouseDown(MouseEvent e) { } + @Override public void mouseUp(MouseEvent e) { setExpandCollapseState(); @@ -319,6 +323,7 @@ private void setExpandCollapseState() { } } + private void createContextMenu(Tree tree) { fCopySelectionAction = new CopyTreeSelectionAction(tree); @@ -353,10 +358,10 @@ private void initializeButtons() { fUpdateButton.setEnabled(false); SWTFactory.setButtonDimensionHint(fUpdateButton); - fReloadButton.addSelectionListener(widgetSelectedAdapter(e -> handleReload())); - fReloadButton.setLayoutData(new GridData()); - fReloadButton.setEnabled(true); - SWTFactory.setButtonDimensionHint(fReloadButton); + fRefreshButton.addSelectionListener(widgetSelectedAdapter(e -> handleReload())); + fRefreshButton.setLayoutData(new GridData()); + fRefreshButton.setEnabled(true); + SWTFactory.setButtonDimensionHint(fRefreshButton); fExpandCollapseButton.addSelectionListener(widgetSelectedAdapter(e -> toggleCollapse())); fExpandCollapseButton.setLayoutData(new GridData()); @@ -457,43 +462,38 @@ private void handleUpdate() { JobChangeAdapter listener = new JobChangeAdapter() { @Override public void done(final IJobChangeEvent event) { - UIJob job = new UIJob(Messages.UpdateTargetJob_UpdateJobName) { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - IStatus result = event.getJob().getResult(); - if (!result.isOK()) { - if (!fTreeViewer.getControl().isDisposed()) { - ErrorDialog.openError(fTreeViewer.getTree().getShell(), - Messages.TargetLocationsGroup_TargetUpdateErrorDialog, result.getMessage(), - result); - } - } else if (result.getCode() != ITargetLocationHandler.STATUS_CODE_NO_CHANGE) { - // Update was successful and changed the target, if - // dialog/editor still open, update it - if (!fTreeViewer.getControl().isDisposed()) { - contentsChanged(true); - fTreeViewer.refresh(true); - updateButtons(); - } + UIJob job = UIJob.create(Messages.UpdateTargetJob_UpdateJobName, monitor -> { + IStatus result = event.getJob().getResult(); + if (!result.isOK()) { + if (!fTreeViewer.getControl().isDisposed()) { + ErrorDialog.openError(fTreeViewer.getTree().getShell(), + Messages.TargetLocationsGroup_TargetUpdateErrorDialog, result.getMessage(), result); + } + } else if (result.getCode() != ITargetLocationHandler.STATUS_CODE_NO_CHANGE) { + // Update was successful and changed the target, if + // dialog/editor still open, update it + if (!fTreeViewer.getControl().isDisposed()) { + contentsChanged(true); + fTreeViewer.refresh(true); + updateButtons(); + } - // If the target is the current platform, run a load - // job for the user - try { - ITargetPlatformService service = PDECore.getDefault() - .acquireService(ITargetPlatformService.class); - if (service != null) { - ITargetHandle currentTarget = service.getWorkspaceTargetHandle(); - if (fTarget.getHandle().equals(currentTarget)) - LoadTargetDefinitionJob.load(fTarget); - } - } catch (CoreException e) { - // do nothing if we could not set the current - // target. + // If the target is the current platform, run a load + // job for the user + try { + ITargetPlatformService service = PDECore.getDefault() + .acquireService(ITargetPlatformService.class); + if (service != null) { + ITargetHandle currentTarget = service.getWorkspaceTargetHandle(); + if (fTarget.getHandle().equals(currentTarget)) + LoadTargetDefinitionJob.load(fTarget); } + } catch (CoreException e) { + // do nothing if we could not set the current + // target. } - return Status.OK_STATUS; } - }; + }); job.schedule(); } }; @@ -509,7 +509,7 @@ private void updateButtons() { fRemoveButton.setData(BUTTON_STATE, DeleteButtonState.NONE); fUpdateButton.setEnabled(false); fEditButton.setEnabled(false); - if(fTreeViewer !=null) { + if (fTreeViewer != null) { setExpandCollapseState(); } return; @@ -552,13 +552,7 @@ private void updateButtons() { private void handleReload() { log(ADAPTER.reload(fTarget, fTarget.getTargetLocations(), new NullProgressMonitor())); - Job job = new UIJob("Reloading...") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - contentsReload(); - return Status.OK_STATUS; - } - }; + Job job = UIJob.create("Refreshing...", (ICoreRunnable) monitor -> contentsReload()); //$NON-NLS-1$ job.schedule(); } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetStatus.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetStatus.java index 3f59640d582..321f0cee7af 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetStatus.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetStatus.java @@ -13,7 +13,8 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.shared.target; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; @@ -120,15 +121,11 @@ public void update() { final String newValue = result; final String newTooltip = statusMessage == null ? newValue : newValue + statusMessage; - UIJob job = new UIJob("") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - targetStatus.setText(newValue); - setImage(newImage); - setToolTipText(newTooltip); - return Status.OK_STATUS; - } - }; + UIJob job = UIJob.create("", monitor -> { //$NON-NLS-1$ + targetStatus.setText(newValue); + setImage(newImage); + setToolTipText(newTooltip); + }); job.setSystem(true); job.schedule(); @@ -189,21 +186,17 @@ public static void initializeTargetStatus() { boolean showStatus = prefs.getBoolean(IPreferenceConstants.SHOW_TARGET_STATUS); if (showStatus) { - UIJob updateStatus = new UIJob("Refresh PDE Target Status") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); - for (IWorkbenchWindow window : windows) { - IStatusLineManager slManager = getStatusLineManager(window); - if (slManager != null) { - slManager.appendToGroup(StatusLineManager.BEGIN_GROUP, getContributionItem()); - slManager.update(false); - break; - } + UIJob updateStatus = UIJob.create("Refresh PDE Target Status", monitor -> { //$NON-NLS-1$ + IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); + for (IWorkbenchWindow window : windows) { + IStatusLineManager slManager = getStatusLineManager(window); + if (slManager != null) { + slManager.appendToGroup(StatusLineManager.BEGIN_GROUP, getContributionItem()); + slManager.update(false); + break; } - return Status.OK_STATUS; } - }; + }); updateStatus.setSystem(true); updateStatus.setPriority(Job.DECORATE); updateStatus.schedule(); diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties index c810c073b9a..5759c042301 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties @@ -53,7 +53,7 @@ BundleContainerTable_Btn_Text_Add=&Add... BundleContainerTable_Btn_Text_Edit=&Edit... BundleContainerTable_Btn_Text_Remove=&Remove BundleContainerTable_Btn_Text_Update=&Update -BundleContainerTable_Btn_Text_Reload=Re&load +BundleContainerTable_Btn_Text_Refresh=Re&fresh BundleContainerTable_Btn_Text_ExpandAll=Ex&pand All BundleContainerTable_Btn_Text_CollapseAll=C&ollapse All @@ -128,8 +128,8 @@ TargetContentsGroup_ManageUsing=Manage using: TargetContentsGroup_OtherPluginsParent=Other Plug-ins TargetContentsGroup_PluginMode=Pl&ug-ins TargetContentsGroup_resolveCancelled=Resolve Cancelled -TargetLocationsGroup_update=Update will look for newer versions of the target contents -TargetLocationsGroup_reload=Reload will clear any cached target data and resolve target +TargetLocationsGroup_update=Looks for newer versions of the target contents and updates them +TargetLocationsGroup_refresh=Clears the cached target data and resolves the target, looking for newer versions of any artifacts TargetLocationsGroup_1=&Show location content TargetLocationsGroup_TargetUpdateErrorDialog=Problems Updating Target Definition TargetStatus_NoActiveTargetPlatformStatus=No active target platform diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java index 8005fb0c62d..9318e822060 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java @@ -50,6 +50,7 @@ import org.eclipse.team.core.*; import org.eclipse.team.core.importing.provisional.IBundleImporter; import org.eclipse.ui.*; +import org.eclipse.ui.dialogs.SelectionDialog; import org.eclipse.ui.progress.UIJob; import org.eclipse.ui.wizards.datatransfer.*; import org.osgi.framework.BundleException; @@ -221,20 +222,14 @@ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { } } if (!namesOfNotImportedProjects.isEmpty()) { - UIJob job = new UIJob(PDEUIMessages.PluginImportOperation_WarningDialogJob) { - - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - String dialogMessage = namesOfNotImportedProjects.size() == 1 - ? PDEUIMessages.PluginImportOperation_WarningDialogMessageSingular - : PDEUIMessages.PluginImportOperation_WarningDialogMessagePlural; - NotImportedProjectsWarningDialog dialog = new NotImportedProjectsWarningDialog(dialogMessage, - namesOfNotImportedProjects); - dialog.open(); - return Status.OK_STATUS; - } - }; - + UIJob job = UIJob.create(PDEUIMessages.PluginImportOperation_WarningDialogJob, m -> { + String dialogMessage = namesOfNotImportedProjects.size() == 1 + ? PDEUIMessages.PluginImportOperation_WarningDialogMessageSingular + : PDEUIMessages.PluginImportOperation_WarningDialogMessagePlural; + NotImportedProjectsWarningDialog dialog = new NotImportedProjectsWarningDialog(dialogMessage, + namesOfNotImportedProjects); + dialog.open(); + }); try { job.schedule(); job.join(); @@ -315,20 +310,16 @@ private void deleteConflictingProjects(MultiStatus status, IProgressMonitor moni final ArrayList overwriteProjectList = new ArrayList<>(); if (!conflictingPlugins.isEmpty()) { - UIJob job = new UIJob(PDEUIMessages.PluginImportOperation_OverwritePluginProjects) { - - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - OverwriteProjectsSelectionDialog dialog = new OverwriteProjectsSelectionDialog( - getDisplay().getActiveShell(), conflictingPlugins); - dialog.setBlockOnOpen(true); - if (dialog.open() == Window.OK) { - overwriteProjectList.addAll(Arrays.asList(dialog.getResult())); - return Status.OK_STATUS; - } - return Status.CANCEL_STATUS; + UIJob job = UIJob.create(PDEUIMessages.PluginImportOperation_OverwritePluginProjects, m -> { + Shell shell = Display.getCurrent().getActiveShell(); + SelectionDialog dialog = new OverwriteProjectsSelectionDialog(shell, conflictingPlugins); + dialog.setBlockOnOpen(true); + if (dialog.open() == Window.OK) { + overwriteProjectList.addAll(Arrays.asList(dialog.getResult())); + return Status.OK_STATUS; } - }; + return Status.CANCEL_STATUS; + }); try { job.schedule(); diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/target/EditTargetDefinitionWizard.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/target/EditTargetDefinitionWizard.java index 70698c6ad93..71c48a276d6 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/target/EditTargetDefinitionWizard.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/target/EditTargetDefinitionWizard.java @@ -13,11 +13,14 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.wizards.target; -import java.util.*; +import static java.util.function.Predicate.not; + +import java.util.List; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.Wizard; -import org.eclipse.pde.core.target.*; +import org.eclipse.pde.core.target.ITargetDefinition; +import org.eclipse.pde.core.target.ITargetPlatformService; import org.eclipse.pde.internal.core.TargetPlatformHelper; import org.eclipse.pde.internal.core.target.TargetDefinition; import org.eclipse.pde.internal.ui.PDEPlugin; @@ -49,17 +52,9 @@ public EditTargetDefinitionWizard(ITargetDefinition definition, boolean createWo public boolean performFinish() { // update the cache to remove all other targets with same handle except // this. - HashMap> targetFlagMap = TargetPlatformHelper.getTargetDefinitionMap(); - for (Map.Entry> entry : targetFlagMap.entrySet()) { - if (entry.getKey().equals(fDefinition.getHandle())) { - List targets = targetFlagMap.get(fDefinition.getHandle()); - for (Iterator iterator = targets.iterator(); iterator.hasNext();) { - TargetDefinition target = iterator.next(); - if (!target.equals(fDefinition)) { - iterator.remove(); - } - } - } + List targets = TargetPlatformHelper.getTargetDefinitionMap().get(fDefinition.getHandle()); + if (targets != null) { + targets.removeIf(not(fDefinition::equals)); } return true; @@ -68,17 +63,9 @@ public boolean performFinish() { @Override public boolean performCancel() { // update the cache to remove this target with this handle - HashMap> targetFlagMap = TargetPlatformHelper.getTargetDefinitionMap(); - for (Map.Entry> entry : targetFlagMap.entrySet()) { - if (entry.getKey().equals(fDefinition.getHandle())) { - List targets = targetFlagMap.get(fDefinition.getHandle()); - for (Iterator iterator = targets.iterator(); iterator.hasNext();) { - TargetDefinition target = iterator.next(); - if (target.equals(fDefinition)) { - iterator.remove(); - } - } - } + List targets = TargetPlatformHelper.getTargetDefinitionMap().get(fDefinition.getHandle()); + if (targets != null) { + targets.removeIf(fDefinition::equals); } return true; } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionContentPage.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionContentPage.java index 66d3fe59192..1b4a1c41a18 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionContentPage.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionContentPage.java @@ -236,48 +236,41 @@ protected void targetChanged(ITargetDefinition definition) { super.targetChanged(definition); if (definition != null) { // When If the page isn't open yet, try running a UI job so the dialog has time to finish opening - UIJob resolveJob = new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - ITargetDefinition definition = getTargetDefinition(); - if (!definition.isResolved()) { - try { - getContainer().run(true, true, monitor1 -> { - getTargetDefinition().resolve(new ResolutionProgressMonitor(monitor1)); - if (monitor1.isCanceled()) { - throw new InterruptedException(); - } - }); - } catch (InvocationTargetException e) { - PDECore.log(e); - } catch (InterruptedException e) { - fContentTree.setCancelled(); - return Status.CANCEL_STATUS; - } - } - fContentTree.setInput(definition); - fLocationTree.setInput(definition); - if (definition.isResolved() && definition.getStatus().getSeverity() == IStatus.ERROR) { - fLocationTab.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); - } else { - fLocationTab.setImage(null); + UIJob resolveJob = UIJob.create(PDEUIMessages.TargetDefinitionContentPage_0, monitor -> { + if (!definition.isResolved()) { + try { + getContainer().run(true, true, monitor1 -> { + getTargetDefinition().resolve(new ResolutionProgressMonitor(monitor1)); + if (monitor1.isCanceled()) { + throw new InterruptedException(); + } + }); + } catch (InvocationTargetException e) { + PDECore.log(e); + } catch (InterruptedException e) { + fContentTree.setCancelled(); + return Status.CANCEL_STATUS; } - return Status.OK_STATUS; } - }; + fContentTree.setInput(definition); + fLocationTree.setInput(definition); + if (definition.isResolved() && definition.getStatus().getSeverity() == IStatus.ERROR) { + fLocationTab.setImage( + PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); + } else { + fLocationTab.setImage(null); + } + return Status.OK_STATUS; + }); resolveJob.schedule(); resolveJob.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { - UIJob job = new UIJob("") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - if (fLocationTree != null) { - fLocationTree.setExpandCollapseState(true); - } - return Status.OK_STATUS; + UIJob job = UIJob.create("", monitor -> { //$NON-NLS-1$ + if (fLocationTree != null) { + fLocationTree.setExpandCollapseState(true); } - }; + }); job.setSystem(true); job.schedule(); } diff --git a/ui/org.eclipse.pde/META-INF/MANIFEST.MF b/ui/org.eclipse.pde/META-INF/MANIFEST.MF index 6d6ecf519a9..ea25efabc42 100644 --- a/ui/org.eclipse.pde/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde/META-INF/MANIFEST.MF @@ -2,6 +2,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.pde;singleton:=true -Bundle-Version: 3.13.2100.qualifier +Bundle-Version: 3.13.2300.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/ui/org.eclipse.pde/pom.xml b/ui/org.eclipse.pde/pom.xml index 17cd99c2986..d2b43ae286f 100644 --- a/ui/org.eclipse.pde/pom.xml +++ b/ui/org.eclipse.pde/pom.xml @@ -14,11 +14,11 @@ org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT ../../ org.eclipse.pde - 3.13.2100-SNAPSHOT + 3.13.2300-SNAPSHOT eclipse-plugin diff --git a/ui/pom.xml b/ui/pom.xml index 4606566a34e..1d271b03a74 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -14,7 +14,7 @@ org.eclipse.pde eclipse.pde - 4.26.0-SNAPSHOT + 4.28.0-SNAPSHOT eclipse.pde.ui pom