GitOrigin-RevId: adcb7b5a259765d3a0881cdbfc788580ab6784c9
This commit is contained in:
Vladimir Krivosheev
2024-08-21 14:07:36 +02:00
committed by intellij-monorepo-bot
parent a5668011e9
commit f30e10cb77
13 changed files with 62 additions and 152 deletions

View File

@@ -1,18 +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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.incremental.groovy;
import com.intellij.util.containers.ContainerUtil;
@@ -35,7 +21,7 @@ import java.io.File;
import java.util.*;
public class CheckResourcesTarget extends BuildTarget<GroovyResourceRootDescriptor> {
@NotNull private final JpsModule myModule;
private final @NotNull JpsModule myModule;
CheckResourcesTarget(@NotNull JpsModule module, @NotNull Type targetType) {
super(targetType);
@@ -47,9 +33,8 @@ public class CheckResourcesTarget extends BuildTarget<GroovyResourceRootDescript
return myModule.getName();
}
@Nullable
@Override
public GroovyResourceRootDescriptor findRootDescriptor(@NotNull String rootId, @NotNull BuildRootIndex rootIndex) {
public @Nullable GroovyResourceRootDescriptor findRootDescriptor(@NotNull String rootId, @NotNull BuildRootIndex rootIndex) {
List<GroovyResourceRootDescriptor> descriptors = rootIndex.getRootDescriptors(new File(rootId),
Collections.singletonList((Type)getTargetType()),
null);
@@ -61,9 +46,8 @@ public class CheckResourcesTarget extends BuildTarget<GroovyResourceRootDescript
return ((Type)getTargetType()).myTests;
}
@NotNull
@Override
public String getPresentableName() {
public @NotNull String getPresentableName() {
return "Check Groovy Resources for '" + myModule.getName() + "' " + (isTests() ? "tests" : "production");
}
@@ -82,20 +66,18 @@ public class CheckResourcesTarget extends BuildTarget<GroovyResourceRootDescript
return result;
}
@NotNull
@Override
public List<GroovyResourceRootDescriptor> computeRootDescriptors(@NotNull JpsModel model,
@NotNull ModuleExcludeIndex index,
@NotNull IgnoredFileIndex ignoredFileIndex,
@NotNull BuildDataPaths dataPaths) {
public @NotNull List<GroovyResourceRootDescriptor> computeRootDescriptors(@NotNull JpsModel model,
@NotNull ModuleExcludeIndex index,
@NotNull IgnoredFileIndex ignoredFileIndex,
@NotNull BuildDataPaths dataPaths) {
ResourcesTarget target = new ResourcesTarget(myModule, ResourcesTargetType.getInstance(isTests()));
List<ResourceRootDescriptor> resources = target.computeRootDescriptors(model, index, ignoredFileIndex, dataPaths);
return ContainerUtil.map(resources, descriptor -> new GroovyResourceRootDescriptor(descriptor, this));
}
@NotNull
@Override
public Collection<File> getOutputRoots(@NotNull CompileContext context) {
public @NotNull Collection<File> getOutputRoots(@NotNull CompileContext context) {
return Collections.singletonList(getOutputRoot(context));
}
@@ -109,8 +91,7 @@ public class CheckResourcesTarget extends BuildTarget<GroovyResourceRootDescript
public static final Type TESTS = new Type(true);
static final List<Type> TARGET_TYPES = Arrays.asList(PRODUCTION, TESTS);
@NotNull
public JpsModule getModule() {
public @NotNull JpsModule getModule() {
return myModule;
}
@@ -140,23 +121,20 @@ public class CheckResourcesTarget extends BuildTarget<GroovyResourceRootDescript
myTests = tests;
}
@NotNull
@Override
public List<CheckResourcesTarget> computeAllTargets(@NotNull JpsModel model) {
public @NotNull List<CheckResourcesTarget> computeAllTargets(@NotNull JpsModel model) {
return ContainerUtil.map(model.getProject().getModules(), module -> new CheckResourcesTarget(module, this));
}
@NotNull
@Override
public BuildTargetLoader<CheckResourcesTarget> createLoader(@NotNull JpsModel model) {
public @NotNull BuildTargetLoader<CheckResourcesTarget> createLoader(@NotNull JpsModel model) {
final Map<String, JpsModule> modules = new HashMap<>();
for (JpsModule module : model.getProject().getModules()) {
modules.put(module.getName(), module);
}
return new BuildTargetLoader<CheckResourcesTarget>() {
@Nullable
@Override
public CheckResourcesTarget createTarget(@NotNull String targetId) {
public @Nullable CheckResourcesTarget createTarget(@NotNull String targetId) {
JpsModule module = modules.get(targetId);
return module != null ? new CheckResourcesTarget(module, Type.this) : null;
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.incremental.groovy;
import com.intellij.openapi.util.NlsSafe;
@@ -79,8 +79,7 @@ class EclipseOutputParser {
}
}
@Nullable
private CompilerMessage parseMessage(@NlsSafe String msgText) {
private @Nullable CompilerMessage parseMessage(@NlsSafe String msgText) {
// message should look like this:
// 1. WARNING in /Users/andrew/git-repos/foo/src/main/java/packAction.java (at line 47)
// public abstract class AbstractScmTagAction extends TaskAction implements BuildBadgeAction {

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.incremental.groovy;
import com.intellij.execution.process.BaseOSProcessHandler;
@@ -94,9 +94,8 @@ final class ForkedGroovyc implements GroovycFlavor {
);
final Process process = Runtime.getRuntime().exec(ArrayUtilRt.toStringArray(cmd));
ProcessHandler handler = new BaseOSProcessHandler(process, StringUtil.join(cmd, " "), null) {
@NotNull
@Override
public Future<?> executeTask(@NotNull Runnable task) {
public @NotNull Future<?> executeTask(@NotNull Runnable task) {
return SharedThreadPool.getInstance().submit(task);
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.incremental.groovy;
import com.intellij.execution.process.BaseOSProcessHandler;
@@ -73,8 +73,7 @@ public final class GreclipseBuilder extends ModuleLevelBuilder {
}
@Nullable
private ClassLoader createGreclipseLoader(@Nullable String jar) {
private @Nullable ClassLoader createGreclipseLoader(@Nullable String jar) {
if (StringUtil.isEmpty(jar)) return null;
if (jar.equals(myGreclipseJar)) {
@@ -99,9 +98,8 @@ public final class GreclipseBuilder extends ModuleLevelBuilder {
}
@NotNull
@Override
public List<String> getCompilableFileExtensions() {
public @NotNull List<String> getCompilableFileExtensions() {
return Arrays.asList("groovy", "java");
}
@@ -290,9 +288,8 @@ public final class GreclipseBuilder extends ModuleLevelBuilder {
);
final Process process = Runtime.getRuntime().exec(ArrayUtilRt.toStringArray(cmd));
ProcessHandler handler = new BaseOSProcessHandler(process, StringUtil.join(cmd, " "), null) {
@NotNull
@Override
public Future<?> executeTask(@NotNull Runnable task) {
public @NotNull Future<?> executeTask(@NotNull Runnable task) {
return SharedThreadPool.getInstance().submit(task);
}
@@ -413,9 +410,8 @@ public final class GreclipseBuilder extends ModuleLevelBuilder {
return StringUtil.join(cp, File.pathSeparator);
}
@NotNull
@Override
public String getPresentableName() {
public @NotNull String getPresentableName() {
return GroovyJpsBundle.message("compiler.name.greclipse");
}

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.incremental.groovy;
import org.jetbrains.annotations.NotNull;
@@ -31,14 +17,12 @@ public class GreclipseJpsCompilerSettings extends JpsCompositeElementBase<Grecli
mySettings = settings;
}
@NotNull
@Override
public GreclipseJpsCompilerSettings createCopy() {
public @NotNull GreclipseJpsCompilerSettings createCopy() {
return new GreclipseJpsCompilerSettings(mySettings);
}
@Nullable
public static GreclipseSettings getSettings(@NotNull JpsProject project) {
public static @Nullable GreclipseSettings getSettings(@NotNull JpsProject project) {
GreclipseJpsCompilerSettings extension = project.getContainer().getChild(ROLE);
return extension != null ? extension.mySettings : null;
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.incremental.groovy;
import com.intellij.openapi.diagnostic.Logger;
@@ -104,8 +104,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
return new File(context.getProjectDescriptor().dataManager.getDataPaths().getDataStorageRoot(), "groovyStubs");
}
@Nullable
static Map<ModuleBuildTarget, String> getCanonicalModuleOutputs(CompileContext context, ModuleChunk chunk, Builder builder) {
static @Nullable Map<ModuleBuildTarget, String> getCanonicalModuleOutputs(CompileContext context, ModuleChunk chunk, Builder builder) {
Map<ModuleBuildTarget, String> finalOutputs = new LinkedHashMap<>();
for (ModuleBuildTarget target : chunk.getTargets()) {
File moduleOutputDir = target.getOutputDir();
@@ -142,9 +141,8 @@ public class GroovyBuilder extends ModuleLevelBuilder {
return path.endsWith("." + GROOVY_EXTENSION);
}
@NotNull
@Override
public List<String> getCompilableFileExtensions() {
public @NotNull List<String> getCompilableFileExtensions() {
return Collections.singletonList(GROOVY_EXTENSION);
}
@@ -154,8 +152,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
}
@Override
@NotNull
public String getPresentableName() {
public @NotNull String getPresentableName() {
return myBuilderName;
}

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2012 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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.incremental.groovy;
import org.jetbrains.annotations.NotNull;
@@ -27,21 +13,18 @@ import java.util.List;
public class GroovyBuilderService extends BuilderService {
@NotNull
@Override
public List<? extends BuildTargetType<?>> getTargetTypes() {
public @NotNull List<? extends BuildTargetType<?>> getTargetTypes() {
return CheckResourcesTarget.TARGET_TYPES;
}
@NotNull
@Override
public List<? extends TargetBuilder<?, ?>> createBuilders() {
public @NotNull List<? extends TargetBuilder<?, ?>> createBuilders() {
return Collections.singletonList(new GroovyResourceChecker());
}
@NotNull
@Override
public List<? extends ModuleLevelBuilder> createModuleLevelBuilders() {
public @NotNull List<? extends ModuleLevelBuilder> createModuleLevelBuilders() {
return Arrays.asList(new GroovyBuilder(true), new GroovyBuilder(false), new GreclipseBuilder());
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.incremental.groovy;
import com.intellij.util.xmlb.XmlSerializer;
@@ -12,9 +12,8 @@ import java.util.Arrays;
import java.util.List;
public final class GroovyModelSerializerExtension extends JpsModelSerializerExtension {
@NotNull
@Override
public List<? extends JpsProjectExtensionSerializer> getProjectExtensionSerializers() {
public @NotNull List<? extends JpsProjectExtensionSerializer> getProjectExtensionSerializers() {
return Arrays.asList(new JpsProjectExtensionSerializer("groovyc.xml", "GroovyCompilerProjectConfiguration") {
@Override
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.incremental.groovy;
import com.intellij.openapi.util.Key;
@@ -26,9 +26,8 @@ public class GroovyResourceChecker extends TargetBuilder<GroovyResourceRootDescr
super(CheckResourcesTarget.TARGET_TYPES);
}
@NotNull
@Override
public String getPresentableName() {
public @NotNull String getPresentableName() {
return GroovyJpsBundle.message("builder.resource.checker");
}
@@ -38,9 +37,9 @@ public class GroovyResourceChecker extends TargetBuilder<GroovyResourceRootDescr
}
@Override
public void build(@NotNull final CheckResourcesTarget target,
public void build(final @NotNull CheckResourcesTarget target,
@NotNull DirtyFilesHolder<GroovyResourceRootDescriptor, CheckResourcesTarget> holder,
@NotNull final BuildOutputConsumer outputConsumer,
final @NotNull BuildOutputConsumer outputConsumer,
@NotNull CompileContext context) throws ProjectBuildException, IOException {
if (context.getBuilderParameter(CHECKING_RESOURCES_REBUILD.toString()) == null) {
return;
@@ -54,8 +53,7 @@ public class GroovyResourceChecker extends TargetBuilder<GroovyResourceRootDescr
});
}
@NotNull
private static ModuleChunk singleModuleChunk(final JpsModule module) {
private static @NotNull ModuleChunk singleModuleChunk(final JpsModule module) {
return new ModuleChunk(Collections.singleton(new ModuleBuildTarget(module, JavaModuleBuildTargetType.PRODUCTION)));
}
@@ -95,8 +93,7 @@ public class GroovyResourceChecker extends TargetBuilder<GroovyResourceRootDescr
return paths;
}
@NotNull
private List<File> getVisibleResourceOutputs(CompileContext context, boolean tests) {
private @NotNull List<File> getVisibleResourceOutputs(CompileContext context, boolean tests) {
List<File> resourceOutputs = new ArrayList<>();
JpsJavaDependenciesEnumerator enumerator = JpsJavaExtensionService.dependencies(myTarget.getModule()).
includedIn(JpsJavaClasspathKind.compile(tests)).

View File

@@ -9,7 +9,7 @@ import java.io.File;
import java.io.FileFilter;
import java.util.Set;
class GroovyResourceRootDescriptor extends BuildRootDescriptor {
final class GroovyResourceRootDescriptor extends BuildRootDescriptor {
private final CheckResourcesTarget myTarget;
private final ResourceRootDescriptor myDescriptor;
@@ -24,8 +24,7 @@ class GroovyResourceRootDescriptor extends BuildRootDescriptor {
}
@Override
@NotNull
public FileFilter createFileFilter() {
public @NotNull FileFilter createFileFilter() {
return myDescriptor.createFileFilter();
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.incremental.groovy;
import com.intellij.execution.process.ProcessOutputTypes;
@@ -255,7 +255,7 @@ public class GroovycOutputParser {
final Collection<String> changedSources,
Collection<String> finalOutputs,
Map<String, String> class2Src,
@Nullable final String encoding,
final @Nullable String encoding,
List<String> patchers,
String classpath) throws IOException {
File tempFile = FileUtil.createTempFile("ideaGroovyToCompile", ".txt", true);

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.incremental.groovy;
import com.intellij.execution.process.ProcessOutputTypes;
@@ -91,11 +91,10 @@ final class InProcessGroovyc implements GroovycFlavor {
return waitForStubGeneration(future, mailbox, parser, loader);
}
@Nullable
private static GroovycContinuation waitForStubGeneration(Future<Void> future,
LinkedBlockingQueue<?> mailbox,
GroovycOutputParser parser,
JointCompilationClassLoader loader) throws InterruptedException {
private static @Nullable GroovycContinuation waitForStubGeneration(Future<Void> future,
LinkedBlockingQueue<?> mailbox,
GroovycOutputParser parser,
JointCompilationClassLoader loader) throws InterruptedException {
while (true) {
Object msg = mailbox.poll(1, TimeUnit.MINUTES);
if (GROOVYC_FINISHED.equals(msg)) {
@@ -116,15 +115,13 @@ final class InProcessGroovyc implements GroovycFlavor {
}
}
@NotNull
private static GroovycContinuation createContinuation(Future<Void> future,
@NotNull Queue<String> mailbox,
GroovycOutputParser parser,
@NotNull JointCompilationClassLoader loader) {
private static @NotNull GroovycContinuation createContinuation(Future<Void> future,
@NotNull Queue<String> mailbox,
GroovycOutputParser parser,
@NotNull JointCompilationClassLoader loader) {
return new GroovycContinuation() {
@NotNull
@Override
public GroovyCompilerResult continueCompilation() throws Exception {
public @NotNull GroovyCompilerResult continueCompilation() throws Exception {
loader.resetCache();
parser.onContinuation();
mailbox.offer(GroovyRtConstants.JAVAC_COMPLETED);
@@ -232,8 +229,7 @@ final class InProcessGroovyc implements GroovycFlavor {
return null;
}
@Nullable
static String evaluatePathToGroovyJarForParentClassloader(Collection<String> compilationClassPath) {
static @Nullable String evaluatePathToGroovyJarForParentClassloader(Collection<String> compilationClassPath) {
if (!"true".equals(System.getProperty("groovyc.reuse.compiler.classes", "true"))) {
return null;
}
@@ -347,10 +343,9 @@ final class InProcessGroovyc implements GroovycFlavor {
return result;
}
@NotNull
private static PrintStream createStream(@NotNull GroovycOutputParser parser,
@NotNull Key<?> type,
@Nullable("null means not overridden") PrintStream overridden) throws IOException {
private static @NotNull PrintStream createStream(@NotNull GroovycOutputParser parser,
@NotNull Key<?> type,
@Nullable("null means not overridden") PrintStream overridden) throws IOException {
final Thread thread = Thread.currentThread();
OutputStream out = new OutputStream() {
ByteArrayOutputStream line = new ByteArrayOutputStream();

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2013 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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.jps.incremental.groovy;
import com.intellij.util.xmlb.annotations.Tag;
@@ -54,14 +40,12 @@ public class JpsGroovySettings extends JpsElementBase<JpsGroovySettings> {
JpsJavaCompilerConfigurationSerializer.readExcludes(excludes, myExcludeFromStubGeneration);
}
@NotNull
@Override
public JpsGroovySettings createCopy() {
public @NotNull JpsGroovySettings createCopy() {
return new JpsGroovySettings(this);
}
@NotNull
public static JpsGroovySettings getSettings(@NotNull JpsProject project) {
public static @NotNull JpsGroovySettings getSettings(@NotNull JpsProject project) {
JpsGroovySettings settings = project.getContainer().getChild(ROLE);
return settings == null ? new JpsGroovySettings() : settings;
}