new project model: added module type and sdk for DevKit

This commit is contained in:
nik
2012-07-20 13:21:54 +04:00
parent 43eda1a880
commit 0c1e772902
10 changed files with 241 additions and 9 deletions
@@ -15,7 +15,7 @@ public class CompileServerPlugin implements PluginAware {
/**
* Specifies path to a jar file which should be added to the classpath of the compile server. The path is relative to the plugin 'lib' directory.
* In the development node the name of this file without extension is treated as a module name and the output directory of the module is added to the classpath.
* In the development mode the name of this file without extension is treated as a module name and the output directory of the module is added to the classpath.
*/
@Attribute("jar-path")
public String getJarPath() {
@@ -5,6 +5,7 @@ import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@@ -43,7 +44,7 @@ public abstract class JpsLoaderBase {
}
@Nullable
protected static Element findComponent(Element root, String componentName) {
public static Element findComponent(@Nullable Element root, @NotNull String componentName) {
for (Element element : JDOMUtil.getChildren(root, "component")) {
if (componentName.equals(element.getAttributeValue("name"))) {
return element;
@@ -7,7 +7,6 @@ import org.jetbrains.jps.model.JpsCompositeElement;
import org.jetbrains.jps.model.JpsElementReference;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.library.JpsSdkType;
import org.jetbrains.jps.model.module.JpsDependencyElement;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.serialization.facet.JpsModuleExtensionLoader;
@@ -31,11 +30,6 @@ public abstract class JpsModelLoaderExtension {
return null;
}
@Nullable
public JpsSdkType<?> getSdkType(@NotNull String typeId) {
return null;
}
public void loadModuleDependencyProperties(JpsDependencyElement dependency, Element orderEntry) {
}
@@ -45,7 +39,7 @@ public abstract class JpsModelLoaderExtension {
}
@NotNull
public List<JpsModulePropertiesLoader<?>> getModulePropertiesLoaders() {
public List<? extends JpsModulePropertiesLoader<?>> getModulePropertiesLoaders() {
return Collections.emptyList();
}
@@ -8,6 +8,9 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="jps-model" />
<orderEntry type="module" module-name="jps-model-api" />
<orderEntry type="module" module-name="jps-model-serialization" />
<orderEntry type="module" module-name="jps-builders" />
</component>
</module>
@@ -0,0 +1 @@
org.jetbrains.jps.devkit.model.impl.JpsDevKitModelLoaderExtension
@@ -0,0 +1,49 @@
/*
* 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.
*/
package org.jetbrains.jps.devkit.model;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.library.JpsSdkProperties;
/**
* @author nik
*/
public class JpsIdeaSdkProperties extends JpsSdkProperties {
private final String mySandboxHome;
private final String myJdkName;
public JpsIdeaSdkProperties(String homePath, String versionString, String sandboxHome, String jdkName) {
super(homePath, versionString);
mySandboxHome = sandboxHome;
myJdkName = jdkName;
}
public JpsIdeaSdkProperties(JpsIdeaSdkProperties properties) {
super(properties);
mySandboxHome = properties.mySandboxHome;
myJdkName = properties.myJdkName;
}
@Nullable
public String getSandboxHome() {
return mySandboxHome;
}
@Nullable
public String getJdkName() {
return myJdkName;
}
}
@@ -0,0 +1,38 @@
/*
* 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.
*/
package org.jetbrains.jps.devkit.model;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.java.JpsJavaSdkTypeWrapper;
import org.jetbrains.jps.model.library.JpsSdkProperties;
import org.jetbrains.jps.model.library.JpsSdkType;
/**
* @author nik
*/
public class JpsIdeaSdkType extends JpsSdkType<JpsIdeaSdkProperties> implements JpsJavaSdkTypeWrapper {
public static final JpsIdeaSdkType INSTANCE = new JpsIdeaSdkType();
@Override
public JpsIdeaSdkProperties createCopy(JpsIdeaSdkProperties properties) {
return new JpsIdeaSdkProperties(properties);
}
@Override
public String getJavaSdkName(@NotNull JpsSdkProperties properties) {
return properties instanceof JpsIdeaSdkProperties ? ((JpsIdeaSdkProperties)properties).getJdkName() : null;
}
}
@@ -0,0 +1,37 @@
/*
* 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.
*/
package org.jetbrains.jps.devkit.model;
import org.jetbrains.jps.model.JpsElementProperties;
/**
* @author nik
*/
public class JpsPluginModuleProperties extends JpsElementProperties {
private final String myPluginXmlUrl;
public JpsPluginModuleProperties(String pluginXmlUrl) {
myPluginXmlUrl = pluginXmlUrl;
}
public JpsPluginModuleProperties(JpsPluginModuleProperties properties) {
myPluginXmlUrl = properties.getPluginXmlUrl();
}
public String getPluginXmlUrl() {
return myPluginXmlUrl;
}
}
@@ -0,0 +1,30 @@
/*
* 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.
*/
package org.jetbrains.jps.devkit.model;
import org.jetbrains.jps.model.module.JpsModuleType;
/**
* @author nik
*/
public class JpsPluginModuleType extends JpsModuleType<JpsPluginModuleProperties> {
public static final JpsPluginModuleType INSTANCE = new JpsPluginModuleType();
@Override
public JpsPluginModuleProperties createCopy(JpsPluginModuleProperties properties) {
return new JpsPluginModuleProperties(properties);
}
}
@@ -0,0 +1,79 @@
/*
* 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.
*/
package org.jetbrains.jps.devkit.model.impl;
import com.intellij.openapi.util.JDOMExternalizerUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.devkit.model.JpsIdeaSdkProperties;
import org.jetbrains.jps.devkit.model.JpsIdeaSdkType;
import org.jetbrains.jps.devkit.model.JpsPluginModuleProperties;
import org.jetbrains.jps.devkit.model.JpsPluginModuleType;
import org.jetbrains.jps.model.serialization.JpsLoaderBase;
import org.jetbrains.jps.model.serialization.JpsModelLoaderExtension;
import org.jetbrains.jps.model.serialization.JpsModulePropertiesLoader;
import org.jetbrains.jps.model.serialization.JpsSdkPropertiesLoader;
import java.util.Arrays;
import java.util.List;
/**
* @author nik
*/
public class JpsDevKitModelLoaderExtension extends JpsModelLoaderExtension {
@NotNull
@Override
public List<? extends JpsModulePropertiesLoader<?>> getModulePropertiesLoaders() {
return Arrays.asList(new JpsPluginModulePropertiesLoader());
}
@NotNull
@Override
public List<? extends JpsSdkPropertiesLoader<?>> getSdkPropertiesLoaders() {
return Arrays.asList(new JpsIdeaSdkPropertiesLoader());
}
private static class JpsIdeaSdkPropertiesLoader extends JpsSdkPropertiesLoader<JpsIdeaSdkProperties> {
public JpsIdeaSdkPropertiesLoader() {
super("IDEA JDK", JpsIdeaSdkType.INSTANCE);
}
@Override
public JpsIdeaSdkProperties loadProperties(String homePath, String version, @Nullable Element propertiesElement) {
String sandboxHome = null;
String jdkName = null;
if (propertiesElement != null) {
sandboxHome = JDOMExternalizerUtil.readField(propertiesElement, "mySandboxHome");
jdkName = propertiesElement.getAttributeValue("sdk");
}
return new JpsIdeaSdkProperties(homePath, version, sandboxHome, jdkName);
}
}
private static class JpsPluginModulePropertiesLoader extends JpsModulePropertiesLoader<JpsPluginModuleProperties> {
private JpsPluginModulePropertiesLoader() {
super(JpsPluginModuleType.INSTANCE, "PLUGIN_MODULE");
}
@Override
public JpsPluginModuleProperties loadProperties(@Nullable Element moduleRootElement) {
Element component = JpsLoaderBase.findComponent(moduleRootElement, "DevKit.ModuleBuildProperties");
return new JpsPluginModuleProperties(component != null ? component.getAttributeValue("url") : null);
}
}
}