diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java b/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java index de9a30fb3fc3..f0aa1aef3d15 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java @@ -16,7 +16,6 @@ import com.intellij.openapi.compiler.options.ExcludedEntriesConfiguration; import com.intellij.openapi.compiler.options.ExcludedEntriesListener; import com.intellij.openapi.compiler.options.ExcludesConfiguration; import com.intellij.openapi.components.PersistentStateComponent; -import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.diagnostic.Logger; @@ -26,6 +25,7 @@ import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.ModuleListener; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.ui.InputValidator; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.*; @@ -66,7 +66,7 @@ import static org.jetbrains.jps.model.java.impl.compiler.ResourcePatterns.normal import static org.jetbrains.jps.model.serialization.java.compiler.JpsJavaCompilerConfigurationSerializer.DEFAULT_WILDCARD_PATTERNS; @State(name = "CompilerConfiguration", storages = @Storage("compiler.xml")) -public class CompilerConfigurationImpl extends CompilerConfiguration implements PersistentStateComponent, ProjectComponent { +public class CompilerConfigurationImpl extends CompilerConfiguration implements PersistentStateComponent { private static final Logger LOG = Logger.getInstance(CompilerConfiguration.class); public static final String TESTS_EXTERNAL_COMPILER_HOME_PROPERTY_NAME = "tests.external.compiler.home"; @@ -104,7 +104,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements private String myBytecodeTargetLevel = null; // null means same as effective language level private final Map myModuleBytecodeTarget = new HashMap<>(); - public CompilerConfigurationImpl(Project project) { + public CompilerConfigurationImpl(@NotNull Project project) { myProject = project; myExcludesConfiguration = createExcludedEntriesConfiguration(project); MessageBusConnection connection = project.getMessageBus().connect(); @@ -126,6 +126,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements updateModuleNames(modules.stream().collect(Collectors.toMap(oldNameProvider::fun, Module::getName))); } }); + StartupManager.getInstance(project).runAfterOpened(() -> createCompilers()); } // Overridden in Upsource @@ -423,11 +424,6 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements return JAVAC_EXTERNAL_BACKEND; } - @Override - public void projectOpened() { - createCompilers(); - } - private void createCompilers() { if (JAVAC_EXTERNAL_BACKEND != null) { return; diff --git a/java/compiler/impl/src/com/intellij/compiler/ExternalCompilerConfigurationStorage.kt b/java/compiler/impl/src/com/intellij/compiler/ExternalCompilerConfigurationStorage.kt index fd2f84827f7c..dbcbe1691e29 100644 --- a/java/compiler/impl/src/com/intellij/compiler/ExternalCompilerConfigurationStorage.kt +++ b/java/compiler/impl/src/com/intellij/compiler/ExternalCompilerConfigurationStorage.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.compiler import com.intellij.openapi.components.PersistentStateComponent @@ -26,7 +26,7 @@ internal class ExternalCompilerConfigurationStorage(private val project: Project return result } - val map = (CompilerConfigurationImpl.getInstance(project) as CompilerConfigurationImpl).modulesBytecodeTargetMap + val map = if (project.isDefault) emptyMap() else (CompilerConfiguration.getInstance(project) as CompilerConfigurationImpl).modulesBytecodeTargetMap val moduleNames = getFilteredModuleNameList(project, map, true) if (moduleNames.isNotEmpty()) { val element = Element(JpsJavaCompilerConfigurationSerializer.BYTECODE_TARGET_LEVEL) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompilerCacheManager.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompilerCacheManager.java index 6cf0afcc3559..8f5f0e6e373e 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompilerCacheManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompilerCacheManager.java @@ -1,29 +1,17 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.compiler.impl; import com.intellij.openapi.Disposable; import com.intellij.openapi.compiler.Compiler; import com.intellij.openapi.compiler.*; +import com.intellij.openapi.components.Service; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import java.io.File; import java.io.IOException; @@ -35,25 +23,26 @@ import java.util.Map; /** * @author Eugene Zhuravlev */ -public class CompilerCacheManager implements Disposable { +@Service +public final class CompilerCacheManager implements Disposable { private static final Logger LOG = Logger.getInstance(CompilerCacheManager.class); private final Map myCompilerToCacheMap = new HashMap<>(); private final List myCacheDisposables = new ArrayList<>(); private final File myCachesRoot; - public CompilerCacheManager(Project project) { + public CompilerCacheManager(@NotNull Project project) { myCachesRoot = CompilerPaths.getCacheStoreDirectory(project); } public static CompilerCacheManager getInstance(Project project) { - return project.getComponent(CompilerCacheManager.class); + return project.getService(CompilerCacheManager.class); } @Override public void dispose() { flushCaches(); } - + private File getCompilerRootDir(final Compiler compiler) { final File dir = new File(myCachesRoot, getCompilerIdString(compiler)); dir.mkdirs(); @@ -84,7 +73,7 @@ public class CompilerCacheManager implements Disposable { @NonNls String description = compiler.getDescription(); return StringUtil.toLowerCase(description.replaceAll("\\s+", "_").replaceAll("[\\.\\?]", "_")); } - + synchronized void flushCaches() { for (Disposable disposable : myCacheDisposables) { try { diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java index 44e0fc9512c5..08f8de04689d 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java @@ -40,7 +40,7 @@ import java.util.*; * @author nik */ @State(name = ArtifactManagerImpl.COMPONENT_NAME, storages = @Storage(value = "artifacts", stateSplitter = ArtifactManagerStateSplitter.class)) -public class ArtifactManagerImpl extends ArtifactManager implements PersistentStateComponent, Disposable { +public final class ArtifactManagerImpl extends ArtifactManager implements PersistentStateComponent, Disposable { private static final Logger LOG = Logger.getInstance(ArtifactManagerImpl.class); @NonNls public static final String COMPONENT_NAME = "ArtifactManager"; @NonNls public static final String PACKAGING_ELEMENT_NAME = "element"; @@ -53,7 +53,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements PersistentSt private final SimpleModificationTracker myModificationTracker = new SimpleModificationTracker(); private final Map myWatchedOutputs = new HashMap<>(); - public ArtifactManagerImpl(Project project) { + public ArtifactManagerImpl(@NotNull Project project) { myProject = project; myModel = new ArtifactManagerModel(); myResolvingContext = new DefaultPackagingElementResolvingContext(myProject); diff --git a/java/compiler/openapi/src/com/intellij/compiler/CompilerConfiguration.java b/java/compiler/openapi/src/com/intellij/compiler/CompilerConfiguration.java index 4c54bb08ad32..8f29fe305b1e 100644 --- a/java/compiler/openapi/src/com/intellij/compiler/CompilerConfiguration.java +++ b/java/compiler/openapi/src/com/intellij/compiler/CompilerConfiguration.java @@ -1,16 +1,4 @@ -// Copyright 2000-2017 JetBrains s.r.o. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.compiler; import com.intellij.openapi.compiler.options.ExcludesConfiguration; @@ -25,7 +13,7 @@ import java.util.List; public abstract class CompilerConfiguration { public static CompilerConfiguration getInstance(Project project) { - return project.getComponent(CompilerConfiguration.class); + return project.getService(CompilerConfiguration.class); } public abstract int getBuildProcessHeapSize(int javacPreferredHeapSize); diff --git a/java/compiler/openapi/src/com/intellij/packaging/artifacts/ArtifactManager.java b/java/compiler/openapi/src/com/intellij/packaging/artifacts/ArtifactManager.java index 25840d233722..748b7af4c2e5 100644 --- a/java/compiler/openapi/src/com/intellij/packaging/artifacts/ArtifactManager.java +++ b/java/compiler/openapi/src/com/intellij/packaging/artifacts/ArtifactManager.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.packaging.artifacts; import com.intellij.openapi.project.Project; @@ -36,7 +22,7 @@ public abstract class ArtifactManager implements ArtifactModel { public static final Comparator ARTIFACT_COMPARATOR = (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()); public static ArtifactManager getInstance(@NotNull Project project) { - return project.getComponent(ArtifactManager.class); + return project.getService(ArtifactManager.class); } public abstract Artifact[] getSortedArtifacts(); diff --git a/java/java-impl/src/META-INF/JavaPlugin.xml b/java/java-impl/src/META-INF/JavaPlugin.xml index 058c9ed9148a..50c3a84b21db 100644 --- a/java/java-impl/src/META-INF/JavaPlugin.xml +++ b/java/java-impl/src/META-INF/JavaPlugin.xml @@ -16,7 +16,6 @@ - @@ -46,6 +45,11 @@ + + com.intellij.compiler.ExternalCompilerConfigurationStorage + + + com.intellij.psi.RefResolveService com.intellij.psi.refResolve.RefResolveServiceImpl @@ -271,6 +275,18 @@ + + + + + + + + + + + + diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GrBuildProcessParametersProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GrBuildProcessParametersProvider.java index e6e9e3f95105..c15008e2a83b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GrBuildProcessParametersProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GrBuildProcessParametersProvider.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.compiler; import com.intellij.compiler.CompilerConfiguration; @@ -28,17 +14,17 @@ import java.io.File; import java.util.Collections; import java.util.List; -public class GrBuildProcessParametersProvider extends BuildProcessParametersProvider { +final class GrBuildProcessParametersProvider extends BuildProcessParametersProvider { private final Project myProject; - public GrBuildProcessParametersProvider(@NotNull Project project) { + GrBuildProcessParametersProvider(@NotNull Project project) { myProject = project; } @NotNull @Override public List getClassPath() { - CompilerConfiguration config = CompilerConfiguration.getInstance(myProject); + CompilerConfiguration config = myProject.isDefault() ? null : CompilerConfiguration.getInstance(myProject); if (config instanceof CompilerConfigurationImpl) { BackendCompiler backend = ((CompilerConfigurationImpl)config).getDefaultCompiler(); if (backend != null && backend.getId() == GreclipseBuilder.ID) { diff --git a/resources/src/componentSets/Compiler.xml b/resources/src/componentSets/Compiler.xml deleted file mode 100644 index e237d9c3a154..000000000000 --- a/resources/src/componentSets/Compiler.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - com.intellij.packaging.artifacts.ArtifactManager - com.intellij.packaging.impl.artifacts.ArtifactManagerImpl - - - com.intellij.compiler.ExternalCompilerConfigurationStorage - - - - com.intellij.compiler.CompilerConfiguration - com.intellij.compiler.CompilerConfigurationImpl - - - - com.intellij.compiler.impl.CompilerCacheManager - - - - - - - - - - - - - - - -