Skip to content

Commit

Permalink
Fix discouraged access warnings for own code
Browse files Browse the repository at this point in the history
Have all m2e project accesses be silenced by exporting the related
packages via x-friends. That's safe since all that code is changed and
released together.

Disable discouraged access warnings in test projects. Tests can be
adapted the moment that referenced class vanishes, there is no need to
require stable APIs only in tests.

Finally remove no longer needed SuppressWarnings.
  • Loading branch information
Bananeweizen committed Jan 14, 2023
1 parent c5340d3 commit aa88bf3
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=warning
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.discouragedReference=ignore
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase;
import org.junit.Before;

@SuppressWarnings("restriction")
abstract class AbstractM2eAptProjectConfiguratorTestCase extends AbstractMavenProjectTestCase {
static final String COMPILER_OUTPUT_DIR = "target/generated-sources/annotations";
static final String PROCESSOR_OUTPUT_DIR = "target/generated-sources/apt";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.eclipse.osgi.util.NLS;
import org.junit.Test;

@SuppressWarnings("restriction")
public class M2eAptProjectconfiguratorTest extends AbstractM2eAptProjectConfiguratorTestCase {

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
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.discouragedReference=ignore
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.eclipse.m2e.tests.common.ClasspathHelpers;
import org.junit.Test;

@SuppressWarnings({"restriction"})
public class BinaryProjectTest extends AbstractMavenProjectTestCase {
IProgressMonitor monitor = new NullProgressMonitor();

Expand Down
18 changes: 14 additions & 4 deletions org.eclipse.m2e.core.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
Bundle-Localization: plugin
Export-Package: org.eclipse.m2e.core.ui.internal;x-friends:="org.eclipse.m2e.editor",
Export-Package: org.eclipse.m2e.core.ui.internal;x-friends:="org.eclipse.m2e.editor,org.eclipse.m2e.scm",
org.eclipse.m2e.core.ui.internal.actions;
x-friends:="org.eclipse.m2e.editor,
org.eclipse.m2e.editor.xml,
org.eclipse.m2e.scm,
org.eclipse.m2e.jdt.ui",
org.eclipse.m2e.jdt.ui,
org.eclipse.m2e.tests,
org.eclipse.m2e.editor.tests",
org.eclipse.m2e.core.ui.internal.archetype;x-internal:=true,
org.eclipse.m2e.core.ui.internal.components;x-friends:="org.eclipse.m2e.editor,org.eclipse.m2e.editor.xml",
org.eclipse.m2e.core.ui.internal.console;x-internal:=true,
org.eclipse.m2e.core.ui.internal.dialogs;x-friends:="org.eclipse.m2e.editor",
org.eclipse.m2e.core.ui.internal.editing;x-friends:="org.eclipse.m2e.editor.xml,org.eclipse.m2e.editor,org.eclipse.m2e.refactoring",
org.eclipse.m2e.core.ui.internal.editing;
x-friends:="org.eclipse.m2e.editor.xml,
org.eclipse.m2e.editor,
org.eclipse.m2e.refactoring,
org.eclipse.m2e.editor.tests",
org.eclipse.m2e.core.ui.internal.lifecyclemapping;x-internal:=true,
org.eclipse.m2e.core.ui.internal.markers;x-friends:="org.eclipse.m2e.editor",
org.eclipse.m2e.core.ui.internal.preferences;x-internal:=true,
Expand All @@ -25,7 +31,11 @@ Export-Package: org.eclipse.m2e.core.ui.internal;x-friends:="org.eclipse.m2e.edi
org.eclipse.m2e.core.ui.internal.util;x-friends:="org.eclipse.m2e.editor",
org.eclipse.m2e.core.ui.internal.views;x-internal:=true,
org.eclipse.m2e.core.ui.internal.views.nodes;x-internal:=true,
org.eclipse.m2e.core.ui.internal.wizards;x-friends:="org.eclipse.m2e.editor,org.eclipse.m2e.scm"
org.eclipse.m2e.core.ui.internal.wizards;
x-friends:="org.eclipse.m2e.editor,
org.eclipse.m2e.scm,
org.eclipse.m2e.discovery,
org.eclipse.m2e.editor.tests"
Bundle-Activator: org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public void addProjects(Collection<IProject> projects) {
* @author mistria
*
*/
@SuppressWarnings("restriction")
public static class UpdateMavenConfigurationJob extends MavenJob
implements org.eclipse.m2e.core.internal.jobs.IBackgroundProcessingQueue {

Expand Down
16 changes: 11 additions & 5 deletions org.eclipse.m2e.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,27 @@ Export-Package: org.eclipse.m2e.core,
org.eclipse.m2e.profiles.core,
org.eclipse.m2e.scm,
org.eclipse.m2e.sourcelookup.ui,
org.eclipse.m2e.pde.target",
org.eclipse.m2e.pde.target,
org.eclipse.m2e.sourcelookup",
org.eclipse.m2e.core.internal.builder;x-internal:=true,
org.eclipse.m2e.core.internal.builder.plexusbuildapi;x-internal:=true,
org.eclipse.m2e.core.internal.content;x-internal:=true,
org.eclipse.m2e.core.internal.embedder;x-internal:=true,
org.eclipse.m2e.core.internal.index;x-friends:="org.eclipse.m2e.core.ui,org.eclipse.m2e.editor",
org.eclipse.m2e.core.internal.embedder;x-friends:="org.eclipse.m2e.jdt",
org.eclipse.m2e.core.internal.index;x-friends:="org.eclipse.m2e.core.ui,org.eclipse.m2e.editor,org.eclipse.m2e.jdt",
org.eclipse.m2e.core.internal.index.filter;x-internal:=true,
org.eclipse.m2e.core.internal.jobs;x-internal:=true,
org.eclipse.m2e.core.internal.jobs;
x-friends:="org.eclipse.m2e.core.ui,
org.eclipse.m2e.scm,
org.eclipse.m2e.binaryproject,
org.eclipse.m2e.jdt,
org.eclipse.m2e.profiles.ui",
org.eclipse.m2e.core.internal.launch;x-friends:="org.eclipse.m2e.launching",
org.eclipse.m2e.core.internal.lifecyclemapping;x-friends:="org.eclipse.m2e.core.ui",
org.eclipse.m2e.core.internal.lifecyclemapping.discovery;x-friends:="org.eclipse.m2e.core.ui",
org.eclipse.m2e.core.internal.lifecyclemapping.model;x-internal:=true,
org.eclipse.m2e.core.internal.lifecyclemapping.model.io.xpp3;x-internal:=true,
org.eclipse.m2e.core.internal.markers;x-internal:=true,
org.eclipse.m2e.core.internal.preferences;x-friends:="org.eclipse.m2e.core.ui",
org.eclipse.m2e.core.internal.preferences;x-friends:="org.eclipse.m2e.core.ui,org.eclipse.m2e.jdt",
org.eclipse.m2e.core.internal.project;x-friends:="org.eclipse.m2e.core.ui,org.eclipse.m2e.scm",
org.eclipse.m2e.core.internal.project.conversion;x-internal:=true,
org.eclipse.m2e.core.internal.project.registry;x-internal:=true,
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.discovery/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Require-Bundle: org.eclipse.equinox.p2.ui.discovery,
org.eclipse.jface.text
Export-Package: org.eclipse.m2e.internal.discovery;x-internal:=true,
org.eclipse.m2e.internal.discovery.handlers;x-internal:=true,
org.eclipse.m2e.internal.discovery.markers;x-internal:=true,
org.eclipse.m2e.internal.discovery.markers;x-friends:="org.eclipse.m2e.editor",
org.eclipse.m2e.internal.discovery.operation;x-internal:=true,
org.eclipse.m2e.internal.discovery.preferences;x-internal:=true,
org.eclipse.m2e.internal.discovery.startup;x-internal:=true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
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.discouragedReference=ignore
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.eclipse.ui.texteditor.ITextEditor;
import org.junit.Test;

@SuppressWarnings("restriction")
public class M2EEditorTest extends AbstractMavenProjectTestCase {

@Test
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.editor/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-Vendor: %Bundle-Vendor
Export-Package: org.eclipse.m2e.editor;x-friends:="org.eclipse.m2e.editor.xml",
org.eclipse.m2e.editor.composites;x-friends:="org.eclipse.m2e.editor.xml",
org.eclipse.m2e.editor.dialogs;x-friends:="org.eclipse.m2e.editor.xml",
org.eclipse.m2e.editor.dialogs;x-friends:="org.eclipse.m2e.editor.xml,org.eclipse.m2e.editor.tests",
org.eclipse.m2e.editor.internal.lifecycle;x-internal:=true,
org.eclipse.m2e.editor.internal.markers;x-internal:=true,
org.eclipse.m2e.editor.mojo;x-friends:="org.eclipse.m2e.editor.xml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ public JreSystemVersion getJreSystemVersion() {
.valueOf(preferencesService.get(PREFERENCES_JRE_SYSTEM_LIBRARY_VERSION, PLUGIN_ID, preferencesLookup));
}

@SuppressWarnings("restriction")
private class WorkspaceSourceDownloadJob extends MavenJob
implements org.eclipse.m2e.core.internal.jobs.IBackgroundProcessingQueue {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
*
* @author igor
*/
@SuppressWarnings("restriction")
class DownloadSourcesJob extends MavenJob implements IBackgroundProcessingQueue {
private static Logger log = LoggerFactory.getLogger(DownloadSourcesJob.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ private String getCompilerVersion() {
* Returns the highest, non-snapshot plugin version between the given reference version and the versions found in the
* Nexus indexes.
*/
@SuppressWarnings("restriction")
//TODO extract as API when stabilized?
private String getMostRecentPluginVersion(String groupId, String artifactId, String referenceVersion) {
Assert.isNotNull(groupId, "groupId can not be null");
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.model.edit/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.m2e.model.edit.pom;x-friends:="org.eclipse.m2e.refactoring",
org.eclipse.m2e.model.edit.pom.impl;x-internal:=true,
org.eclipse.m2e.model.edit.pom.provider;x-internal:=true,
org.eclipse.m2e.model.edit.pom.util;x-internal:=true
org.eclipse.m2e.model.edit.pom.util;x-friends:="org.eclipse.m2e.refactoring"
Automatic-Module-Name: org.eclipse.m2e.model.edit
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.eclipse.m2e.core.embedder.IMavenExecutionContext;
import org.eclipse.m2e.core.internal.MavenPluginActivator;

@SuppressWarnings("restriction")
final class DependencyNodeGenerator implements ICallable<PreorderNodeListGenerator> {
private final Artifact artifact;
private final List<ArtifactRepository> repositories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
Expand Down
8 changes: 7 additions & 1 deletion org.eclipse.m2e.tests.common/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-Vendor: Eclipse.org - m2e
MavenArtifact-GroupId: org.eclipse.m2e
MavenArtifact-ArtifactId: org.eclipse.m2e.tests.common
Export-Package: org.eclipse.m2e.tests.common;x-friends:="org.eclipse.m2e.tests,org.eclipse.m2e.core.tests,org.eclipse.m2e.jdt.tests,org.eclipse.m2e.core.ui.tests,org.eclipse.m2e.wtp.tests"
Export-Package: org.eclipse.m2e.tests.common;
x-friends:="org.eclipse.m2e.tests,
org.eclipse.m2e.core.tests,
org.eclipse.m2e.jdt.tests,
org.eclipse.m2e.core.ui.tests,
org.eclipse.m2e.wtp.tests,
org.eclipse.m2e.editor.tests"
Import-Package: javax.servlet;version="3.1.0",
javax.servlet.http;version="3.1.0"
Automatic-Module-Name: org.eclipse.m2e.tests.common
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;


@SuppressWarnings("restriction")
@RequireMavenExecutionContext
public abstract class AbstractLifecycleMappingTest extends AbstractMavenProjectTestCase {
protected IMavenProjectRegistry mavenProjectManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
import org.eclipse.m2e.jdt.internal.BuildPathManager;


@SuppressWarnings("restriction")
public abstract class AbstractMavenProjectTestCase {

private static final boolean STOP_ON_FAILED_TEST = Boolean.getBoolean("m2e.stopOnFailedTest");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.eclipse.m2e.core.internal.jobs.IBackgroundProcessingQueue;


@SuppressWarnings("restriction")
public class JobHelpers {

private static final int POLLING_DELAY = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;


@SuppressWarnings("restriction")
public class WorkspaceHelpers {
public static String getModelId(MavenProject mavenProject) {
return mavenProject.getGroupId() + ":" + mavenProject.getArtifactId() + ":" + mavenProject.getVersion();
Expand Down

0 comments on commit aa88bf3

Please sign in to comment.