Search in sources :

Example 1 with XcodeprojSerializer

use of org.gradle.ide.xcode.internal.xcodeproj.XcodeprojSerializer in project gradle by gradle.

the class GenerateXcodeProjectFileTask method configure.

@Override
protected void configure(XcodeProjectFile projectFile) {
    PBXProject project = new PBXProject(getProject().getPath());
    project.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(BUILD_DEBUG);
    project.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(BUILD_RELEASE);
    addToGroup(project.getMainGroup(), xcodeProject.getGroups().getSources(), "Sources");
    addToGroup(project.getMainGroup(), xcodeProject.getGroups().getHeaders(), "Headers");
    addToGroup(project.getMainGroup(), xcodeProject.getGroups().getTests(), "Tests");
    addToGroup(project.getMainGroup(), xcodeProject.getGroups().getRoot());
    for (XcodeTarget xcodeTarget : xcodeProject.getTargets()) {
        project.getTargets().add(toGradlePbxTarget(xcodeTarget));
        project.getTargets().add(toIndexPbxTarget(xcodeTarget));
        if (xcodeTarget.isUnitTest()) {
            // Creates XCTest configuration only if XCTest are present.
            project.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(TEST_DEBUG);
        } else {
            File debugOutputFile = xcodeTarget.getDebugOutputFile().get().getAsFile();
            PBXFileReference fileReference = new PBXFileReference(debugOutputFile.getName(), debugOutputFile.getAbsolutePath(), PBXReference.SourceTree.ABSOLUTE);
            fileReference.setExplicitFileType(Optional.of(xcodeTarget.getOutputFileType()));
            project.getMainGroup().getOrCreateChildGroupByName(PRODUCTS_GROUP_NAME).getChildren().add(fileReference);
        }
    }
    XcodeprojSerializer serializer = new XcodeprojSerializer(gidGenerator, project);
    final NSDictionary rootObject = serializer.toPlist();
    projectFile.transformAction(new Action<NSDictionary>() {

        @Override
        public void execute(NSDictionary dict) {
            dict.clear();
            dict.putAll(rootObject);
        }
    });
}
Also used : XcodeprojSerializer(org.gradle.ide.xcode.internal.xcodeproj.XcodeprojSerializer) NSDictionary(com.dd.plist.NSDictionary) XcodeTarget(org.gradle.ide.xcode.internal.XcodeTarget) PBXProject(org.gradle.ide.xcode.internal.xcodeproj.PBXProject) XcodeProjectFile(org.gradle.ide.xcode.tasks.internal.XcodeProjectFile) PBXBuildFile(org.gradle.ide.xcode.internal.xcodeproj.PBXBuildFile) File(java.io.File) PBXFileReference(org.gradle.ide.xcode.internal.xcodeproj.PBXFileReference)

Aggregations

NSDictionary (com.dd.plist.NSDictionary)1 File (java.io.File)1 XcodeTarget (org.gradle.ide.xcode.internal.XcodeTarget)1 PBXBuildFile (org.gradle.ide.xcode.internal.xcodeproj.PBXBuildFile)1 PBXFileReference (org.gradle.ide.xcode.internal.xcodeproj.PBXFileReference)1 PBXProject (org.gradle.ide.xcode.internal.xcodeproj.PBXProject)1 XcodeprojSerializer (org.gradle.ide.xcode.internal.xcodeproj.XcodeprojSerializer)1 XcodeProjectFile (org.gradle.ide.xcode.tasks.internal.XcodeProjectFile)1