use of org.jetbrains.jps.model.JpsSimpleElement in project android by JetBrains.
the class AndroidBuilderTest method test9.
public void test9() throws Exception {
final MyExecutor executor = new MyExecutor("com.example.simple");
final JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> androidSdk = addJdkAndAndroidSdk();
addPathPatterns(executor, androidSdk);
final JpsModule appModule1 = addAndroidModule("app1", new String[] { "src" }, "app1", "app1", androidSdk).getFirst();
final JpsModule appModule2 = addAndroidModule("app2", new String[] { "src" }, "app2", "app2", androidSdk).getFirst();
final JpsModule libModule = addAndroidModule("lib", new String[] { "src" }, "lib", "lib", androidSdk).getFirst();
final JpsAndroidModuleExtension libExtension = AndroidJpsUtil.getExtension(libModule);
assert libExtension != null;
final JpsAndroidModuleProperties libProps = ((JpsAndroidModuleExtensionImpl) libExtension).getProperties();
libProps.PROJECT_TYPE = PROJECT_TYPE_LIBRARY;
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log");
assertEquals(1, executor.getCheckedJars().size());
checkMakeUpToDate(executor);
appModule1.getDependenciesList().addModuleDependency(libModule);
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_1");
assertTrue(executor.getCheckedJars().isEmpty());
checkMakeUpToDate(executor);
appModule2.getDependenciesList().addModuleDependency(libModule);
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_2");
assertTrue(executor.getCheckedJars().isEmpty());
checkMakeUpToDate(executor);
final JpsLibrary appLib = appModule1.addModuleLibrary("appLib1", JpsJavaLibraryType.INSTANCE);
appLib.addRoot(getProjectPath("lib/external_jar.jar"), JpsOrderRootType.COMPILED);
appModule1.getDependenciesList().addLibraryDependency(appLib);
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_3");
assertTrue(executor.getCheckedJars().isEmpty());
checkMakeUpToDate(executor);
final JpsLibrary libLib = appModule2.addModuleLibrary("appLib2", JpsJavaLibraryType.INSTANCE);
libLib.addRoot(new File(getProjectPath("lib/external_jar.jar")), JpsOrderRootType.COMPILED);
appModule2.getDependenciesList().addLibraryDependency(libLib);
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_4");
assertTrue(executor.getCheckedJars().isEmpty());
checkMakeUpToDate(executor);
}
use of org.jetbrains.jps.model.JpsSimpleElement in project android by JetBrains.
the class AndroidBuilderTest method testPreDexing.
public void testPreDexing() throws Exception {
final MyExecutor executor = new MyExecutor("com.example.simple");
final JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> androidSdk = addJdkAndAndroidSdk();
addPathPatterns(executor, androidSdk);
final JpsModule appModule = addAndroidModule("app", new String[] { "src" }, "app", "app", androidSdk).getFirst();
final JpsModule libModule = addAndroidModule("lib2", new String[] { "src" }, "lib", "lib2", androidSdk).getFirst();
final JpsModule libModule1 = addAndroidModule("lib1", new String[] { "src" }, "lib1", "lib1", androidSdk).getFirst();
final JpsAndroidModuleExtension libExtension = AndroidJpsUtil.getExtension(libModule);
assert libExtension != null;
final JpsAndroidModuleProperties libProps = ((JpsAndroidModuleExtensionImpl) libExtension).getProperties();
libProps.PROJECT_TYPE = PROJECT_TYPE_LIBRARY;
final JpsAndroidModuleExtension libExtension1 = AndroidJpsUtil.getExtension(libModule1);
assert libExtension1 != null;
final JpsAndroidModuleProperties libProps1 = ((JpsAndroidModuleExtensionImpl) libExtension1).getProperties();
libProps1.PROJECT_TYPE = PROJECT_TYPE_LIBRARY;
appModule.getDependenciesList().addModuleDependency(libModule);
libModule.getDependenciesList().addModuleDependency(libModule1);
final JpsLibrary lib = appModule.addModuleLibrary("ext_lib", JpsJavaLibraryType.INSTANCE);
lib.addRoot(new File(getProjectPath("app/libs/external_jar.jar")), JpsOrderRootType.COMPILED);
appModule.getDependenciesList().addLibraryDependency(lib);
final JpsLibrary lib1 = appModule.addModuleLibrary("ext_lib_1", JpsJavaLibraryType.INSTANCE);
lib1.addRoot(new File(getProjectPath("lib/libs/external_jar_1.jar")), JpsOrderRootType.COMPILED);
libModule.getDependenciesList().addLibraryDependency(lib1);
doBuild(CompileScopeTestBuilder.rebuild().allModules().targetTypes(AndroidManifestMergingTarget.MyTargetType.INSTANCE, AndroidDexBuildTarget.MyTargetType.INSTANCE, AndroidResourceCachingBuildTarget.MyTargetType.INSTANCE, AndroidResourcePackagingBuildTarget.MyTargetType.INSTANCE, AndroidPackagingBuildTarget.MyTargetType.INSTANCE, AndroidLibraryPackagingTarget.MyTargetType.INSTANCE, AndroidPackagingBuildTarget.MyTargetType.INSTANCE)).assertSuccessful();
checkBuildLog(executor, "expected_log");
executor.clear();
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_1");
executor.clear();
doBuild(CompileScopeTestBuilder.make().allModules().targetTypes(AndroidManifestMergingTarget.MyTargetType.INSTANCE, AndroidDexBuildTarget.MyTargetType.INSTANCE, AndroidResourceCachingBuildTarget.MyTargetType.INSTANCE, AndroidResourcePackagingBuildTarget.MyTargetType.INSTANCE, AndroidPackagingBuildTarget.MyTargetType.INSTANCE, AndroidLibraryPackagingTarget.MyTargetType.INSTANCE, AndroidPackagingBuildTarget.MyTargetType.INSTANCE)).assertUpToDate();
executor.clear();
rebuildAll();
checkBuildLog(executor, "expected_log_2");
final JpsAndroidModuleExtension appExtension = AndroidJpsUtil.getExtension(appModule);
assert appExtension != null;
final JpsAndroidModuleProperties appProps = ((JpsAndroidModuleExtensionImpl) appExtension).getProperties();
checkMakeUpToDate(executor);
appProps.ENABLE_PRE_DEXING = false;
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_3");
checkMakeUpToDate(executor);
appProps.ENABLE_PRE_DEXING = true;
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_4");
}
use of org.jetbrains.jps.model.JpsSimpleElement in project android by JetBrains.
the class AndroidDexBuilder method getJavaExecutable.
@Nullable
private static String getJavaExecutable(@NotNull AndroidPlatform platform, @NotNull CompileContext context, @NotNull String builderName) {
final JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> sdk = platform.getSdk();
final String jdkName = sdk.getSdkProperties().getData().getJdkName();
final JpsLibrary javaSdk = context.getProjectDescriptor().getModel().getGlobal().getLibraryCollection().findLibrary(jdkName);
if (javaSdk == null || !javaSdk.getType().equals(JpsJavaSdkType.INSTANCE)) {
context.processMessage(new CompilerMessage(builderName, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.errors.java.sdk.not.specified", jdkName)));
return null;
}
return JpsJavaSdkType.getJavaExecutable((JpsSdk<?>) javaSdk.getProperties());
}
use of org.jetbrains.jps.model.JpsSimpleElement in project intellij-plugins by JetBrains.
the class JpsFlexmojosSdkType method createSdkPropertiesSerializer.
public static JpsSdkPropertiesSerializer<JpsSimpleElement<JpsFlexmojosSdkProperties>> createSdkPropertiesSerializer() {
return new JpsSdkPropertiesSerializer<JpsSimpleElement<JpsFlexmojosSdkProperties>>(ID, INSTANCE) {
@NotNull
public JpsSimpleElement<JpsFlexmojosSdkProperties> loadProperties(@Nullable final Element propertiesElement) {
final Collection<String> flexCompilerClasspath = new ArrayList<>();
String adlPath = "";
String airRuntimePath = "";
if (propertiesElement != null) {
final Element compilerClasspathElement = propertiesElement.getChild(COMPILER_CLASSPATH_ELEMENT_NAME);
if (compilerClasspathElement != null) {
for (Object classpathEntryElement : compilerClasspathElement.getChildren(CLASSPATH_ENTRY_ELEMENT_NAME)) {
flexCompilerClasspath.add(((Element) classpathEntryElement).getText());
}
}
adlPath = FileUtil.toSystemIndependentName(StringUtil.notNullize(propertiesElement.getChildText(ADL_PATH_ELEMENT_NAME)));
airRuntimePath = FileUtil.toSystemIndependentName(StringUtil.notNullize(propertiesElement.getChildText(AIR_RUNTIME_PATH_ELEMENT_NAME)));
}
final JpsFlexmojosSdkProperties properties = new JpsFlexmojosSdkProperties(flexCompilerClasspath, adlPath, airRuntimePath);
return JpsElementFactory.getInstance().createSimpleElement(properties);
}
public void saveProperties(@NotNull final JpsSimpleElement<JpsFlexmojosSdkProperties> propertiesElement, @NotNull final Element element) {
final JpsFlexmojosSdkProperties properties = propertiesElement.getData();
final Element compilerClasspathElement = new Element(COMPILER_CLASSPATH_ELEMENT_NAME);
for (final String classpathEntry : properties.getFlexCompilerClasspath()) {
final Element classpathEntryElement = new Element(CLASSPATH_ENTRY_ELEMENT_NAME);
classpathEntryElement.setText(classpathEntry);
compilerClasspathElement.addContent(classpathEntryElement);
}
element.addContent(compilerClasspathElement);
final Element adlPathElement = new Element(ADL_PATH_ELEMENT_NAME);
adlPathElement.setText(properties.getAdlPath());
element.addContent(adlPathElement);
final Element airRuntimePathElement = new Element(AIR_RUNTIME_PATH_ELEMENT_NAME);
airRuntimePathElement.setText(properties.getAirRuntimePath());
element.addContent(airRuntimePathElement);
}
};
}
Aggregations