Search in sources :

Example 1 with AirDescriptorOptions

use of com.intellij.flex.build.AirDescriptorOptions in project intellij-plugins by JetBrains.

the class FlexBuilderUtils method generateAirDescriptor.

private static void generateAirDescriptor(final CompileContext context, final BuildOutputConsumer outputConsumer, final Collection<String> dirtyFilePaths, final JpsFlexBuildConfiguration bc, final String descriptorFileName, final boolean android, final boolean ios) {
    final JpsSdk<?> sdk = bc.getSdk();
    assert sdk != null;
    final String outputFilePath = bc.getActualOutputFilePath();
    final String outputFolderPath = PathUtilRt.getParentPath(outputFilePath);
    final File outputFolder = new File(outputFolderPath);
    if (!outputFolder.isDirectory()) {
        context.processMessage(new CompilerMessage(getCompilerName(bc), BuildMessage.Kind.ERROR, FlexCommonBundle.message("output.folder.does.not.exist", outputFolder.getPath())));
        return;
    }
    final String airVersion = FlexCommonUtils.getAirVersion(sdk.getHomePath(), sdk.getVersionString());
    if (airVersion == null) {
        context.processMessage(new CompilerMessage(getCompilerName(bc), BuildMessage.Kind.ERROR, FlexCommonBundle.message("failed.to.get.air.sdk.version.use.custom.descriptor")));
        return;
    }
    final String appId = FlexCommonUtils.fixApplicationId(bc.getMainClass());
    final String appName = StringUtil.getShortName(bc.getMainClass());
    final String swfName = PathUtilRt.getFileName(outputFilePath);
    final String[] extensions = getAirExtensionIDs(bc);
    try {
        final AirDescriptorOptions descriptorOptions = new AirDescriptorOptions(airVersion, appId, appName, swfName, extensions, android, ios);
        final String descriptorText = descriptorOptions.getAirDescriptorText();
        final File outputFile = new File(outputFolder, descriptorFileName);
        FileUtil.writeToFile(outputFile, descriptorText);
        outputConsumer.registerOutputFile(outputFile, dirtyFilePaths);
    } catch (IOException e) {
        context.processMessage(new CompilerMessage(getCompilerName(bc), BuildMessage.Kind.ERROR, FlexCommonBundle.message("failed.to.generate.air.descriptor", e.getMessage())));
    }
}
Also used : CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) AirDescriptorOptions(com.intellij.flex.build.AirDescriptorOptions) IOException(java.io.IOException) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 2 with AirDescriptorOptions

use of com.intellij.flex.build.AirDescriptorOptions in project intellij-plugins by JetBrains.

the class CreateAirDescriptorTemplateDialog method doOKAction.

protected void doOKAction() {
    final String airVersion = ((String) myAirVersionCombo.getSelectedItem()).trim();
    final String appId = myAppIdTextField.getText().trim();
    final String appName = myAppNameTextField.getText().trim();
    final String appVersion = myAppVersionTextField.getText().trim();
    final String swfName = "SWF file name is set automatically at compile time";
    final boolean mobile = myMobileOptionsPanel.isVisible();
    final boolean autoOrients = mobile && myAutoOrientCheckBox.isSelected();
    final boolean fullScreen = mobile && myFullScreenCheckBox.isSelected();
    final boolean android = mobile && myAndroidCheckBox.isSelected();
    final int androidPermissions = !mobile || !android ? 0 : (myAndroidInternetCheckBox.isSelected() ? ANDROID_PERMISSION_INTERNET : 0) | (myAndroidWriteExternalStorageCheckBox.isSelected() ? ANDROID_PERMISSION_WRITE_EXTERNAL_STORAGE : 0) | (myAndroidAccessFineLocationCheckBox.isSelected() ? ANDROID_PERMISSION_ACCESS_FINE_LOCATION : 0) | (myAndroidCameraCheckBox.isSelected() ? ANDROID_PERMISSION_CAMERA : 0);
    final boolean ios = mobile && myIOSCheckBox.isSelected();
    final boolean iPhone = mobile && ios && (myIOSAllRadioButton.isSelected() || myIPhoneRadioButton.isSelected());
    final boolean iPad = mobile && ios && (myIOSAllRadioButton.isSelected() || myIPadRadioButton.isSelected());
    final boolean iosHighResolution = mobile && ios && myIOSHighResolutionCheckBox.isSelected();
    final AirDescriptorOptions options = new AirDescriptorOptions(airVersion, appId, appName, appVersion, swfName, myExtensions, mobile, autoOrients, fullScreen, android, androidPermissions, ios, iPhone, iPad, iosHighResolution);
    if (createAirDescriptorTemplate(myProject, true, getDescriptorPath(), options) != null) {
        super.doOKAction();
    }
}
Also used : AirDescriptorOptions(com.intellij.flex.build.AirDescriptorOptions)

Example 3 with AirDescriptorOptions

use of com.intellij.flex.build.AirDescriptorOptions in project intellij-plugins by JetBrains.

the class FlexCompilationUtils method generateAirDescriptor.

private static void generateAirDescriptor(final Module module, final FlexBuildConfiguration bc, final String descriptorFileName, final boolean android, final boolean ios) throws FlexCompilerException {
    final Ref<FlexCompilerException> exceptionRef = new Ref<>();
    final Runnable runnable = () -> {
        final Sdk sdk = bc.getSdk();
        assert sdk != null;
        final String outputFilePath = bc.getActualOutputFilePath();
        final String outputFolderPath = PathUtil.getParentPath(outputFilePath);
        final VirtualFile outputFolder = LocalFileSystem.getInstance().findFileByPath(outputFolderPath);
        if (outputFolder == null) {
            exceptionRef.set(new FlexCompilerException(FlexCommonBundle.message("output.folder.does.not.exist", FileUtil.toSystemDependentName(outputFolderPath))));
            return;
        }
        final String airVersion = FlexCommonUtils.getAirVersion(sdk.getHomePath(), sdk.getVersionString());
        if (airVersion == null) {
            exceptionRef.set(new FlexCompilerException(FlexCommonBundle.message("failed.to.get.air.sdk.version.use.custom.descriptor")));
            return;
        }
        final String appId = FlexCommonUtils.fixApplicationId(bc.getMainClass());
        final String appName = StringUtil.getShortName(bc.getMainClass());
        final String swfName = PathUtil.getFileName(outputFilePath);
        final String[] extensions = getAirExtensionIDs(ModuleRootManager.getInstance(module), bc.getDependencies());
        ApplicationManager.getApplication().runWriteAction(() -> {
            try {
                final AirDescriptorOptions descriptorOptions = new AirDescriptorOptions(airVersion, appId, appName, swfName, extensions, android, ios);
                final String descriptorText = descriptorOptions.getAirDescriptorText();
                FlexUtils.addFileWithContent(descriptorFileName, descriptorText, outputFolder);
            } catch (IOException e) {
                exceptionRef.set(new FlexCompilerException(FlexCommonBundle.message("failed.to.generate.air.descriptor", e.getMessage())));
            }
        });
    };
    ApplicationManager.getApplication().invokeAndWait(runnable);
    if (!exceptionRef.isNull()) {
        throw exceptionRef.get();
    }
}
Also used : Ref(com.intellij.openapi.util.Ref) AirDescriptorOptions(com.intellij.flex.build.AirDescriptorOptions) Sdk(com.intellij.openapi.projectRoots.Sdk) IOException(java.io.IOException)

Aggregations

AirDescriptorOptions (com.intellij.flex.build.AirDescriptorOptions)3 IOException (java.io.IOException)2 Sdk (com.intellij.openapi.projectRoots.Sdk)1 Ref (com.intellij.openapi.util.Ref)1 File (java.io.File)1 ZipFile (java.util.zip.ZipFile)1 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)1