From f7a6c6f6fda56699e59848a71c28798a26e1a18f Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 7 Nov 2012 17:54:29 +0400 Subject: [PATCH] JPS plugin stub --- .idea/artifacts/KotlinPlugin.xml | 8 +++ .idea/modules.xml | 1 + idea/src/META-INF/plugin.xml | 2 + jps-plugin/jps-plugin.iml | 13 ++++ ...g.jetbrains.jps.incremental.BuilderService | 1 + .../jet/jps/build/KotlinBuilder.java | 65 +++++++++++++++++++ .../jet/jps/build/KotlinBuilderService.java | 32 +++++++++ 7 files changed, 122 insertions(+) create mode 100644 jps-plugin/jps-plugin.iml create mode 100644 jps-plugin/src/META-INF/services/org.jetbrains.jps.incremental.BuilderService create mode 100644 jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java create mode 100644 jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilderService.java diff --git a/.idea/artifacts/KotlinPlugin.xml b/.idea/artifacts/KotlinPlugin.xml index e9b1e4e22be..3ea1a1c4b6d 100644 --- a/.idea/artifacts/KotlinPlugin.xml +++ b/.idea/artifacts/KotlinPlugin.xml @@ -23,6 +23,14 @@ + + + + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml index c46d8aa1372..5ceca69997e 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -21,6 +21,7 @@ + diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 92ad4281474..936ef08cfc6 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -95,6 +95,8 @@ + + diff --git a/jps-plugin/jps-plugin.iml b/jps-plugin/jps-plugin.iml new file mode 100644 index 00000000000..8aa91671dfd --- /dev/null +++ b/jps-plugin/jps-plugin.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/jps-plugin/src/META-INF/services/org.jetbrains.jps.incremental.BuilderService b/jps-plugin/src/META-INF/services/org.jetbrains.jps.incremental.BuilderService new file mode 100644 index 00000000000..dbf52b9ce3b --- /dev/null +++ b/jps-plugin/src/META-INF/services/org.jetbrains.jps.incremental.BuilderService @@ -0,0 +1 @@ +org.jetbrains.jet.jps.build.KotlinBuilderService \ No newline at end of file diff --git a/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java new file mode 100644 index 00000000000..86113e5e85f --- /dev/null +++ b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.java @@ -0,0 +1,65 @@ +/* + * Copyright 2010-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. + */ + +package org.jetbrains.jet.jps.build; + +import org.jetbrains.jps.ModuleChunk; +import org.jetbrains.jps.builders.DirtyFilesHolder; +import org.jetbrains.jps.builders.FileProcessor; +import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor; +import org.jetbrains.jps.incremental.*; + +import java.io.File; +import java.io.IOException; + +public class KotlinBuilder extends ModuleLevelBuilder { + protected KotlinBuilder() { + super(BuilderCategory.SOURCE_PROCESSOR); + } + + @Override + public ExitCode build( + CompileContext context, ModuleChunk chunk, DirtyFilesHolder dirtyFilesHolder + ) throws ProjectBuildException { + try { + dirtyFilesHolder.processDirtyFiles(new FileProcessor() { + @Override + public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor root) throws IOException { + if (file.getName().endsWith(".kt") || file.getName().endsWith(".java")) { + + } + return true; + } + }); + } + catch (IOException e) { + throw new ProjectBuildException(e); + } + //context.processMessage(new CompilerMessage()); + //JpsJavaExtensionService.dependencies().recursively().productionOnly().classes().getRoots() + return ExitCode.OK; + } + + @Override + public String getName() { + return "KotlinBuilder"; + } + + @Override + public String getDescription() { + return "KotlinBuilder"; + } +} diff --git a/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilderService.java b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilderService.java new file mode 100644 index 00000000000..df253742ecf --- /dev/null +++ b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilderService.java @@ -0,0 +1,32 @@ +/* + * Copyright 2010-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. + */ + +package org.jetbrains.jet.jps.build; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.incremental.BuilderService; +import org.jetbrains.jps.incremental.ModuleLevelBuilder; + +import java.util.Collections; +import java.util.List; + +public class KotlinBuilderService extends BuilderService { + @NotNull + @Override + public List createModuleLevelBuilders() { + return Collections.singletonList(new KotlinBuilder()); + } +}