Search in sources :

Example 1 with GidGenerator

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

the class GenerateXcodeProjectFileTask method configure.

@Override
protected void configure(XcodeProjectFile projectFile) {
    PBXProject project = new PBXProject(projectPath);
    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()) {
        if (xcodeTarget.isBuildable()) {
            project.getTargets().add(toGradlePbxTarget(xcodeTarget));
        } else {
            getLogger().warn("'" + xcodeTarget.getName() + "' component in project '" + projectPath + "' is not buildable.");
        }
        project.getTargets().add(toIndexPbxTarget(xcodeTarget));
        if (!xcodeTarget.isUnitTest() && xcodeTarget.getDebugOutputFile().isPresent()) {
            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);
        }
    }
    // Create build configuration at the project level from all target's build configuration
    project.getTargets().stream().flatMap(it -> it.getBuildConfigurationList().getBuildConfigurationsByName().asMap().keySet().stream()).forEach(project.getBuildConfigurationList().getBuildConfigurationsByName()::getUnchecked);
    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 : DefaultXcodeProject(org.gradle.ide.xcode.internal.DefaultXcodeProject) PBXProject(org.gradle.ide.xcode.internal.xcodeproj.PBXProject) PBXSourcesBuildPhase(org.gradle.ide.xcode.internal.xcodeproj.PBXSourcesBuildPhase) HashMap(java.util.HashMap) FileCollection(org.gradle.api.file.FileCollection) DisableCachingByDefault(org.gradle.work.DisableCachingByDefault) GidGenerator(org.gradle.ide.xcode.internal.xcodeproj.GidGenerator) ArrayList(java.util.ArrayList) PBXFileReference(org.gradle.ide.xcode.internal.xcodeproj.PBXFileReference) Inject(javax.inject.Inject) TEST_DEBUG(org.gradle.ide.xcode.internal.DefaultXcodeProject.TEST_DEBUG) Provider(org.gradle.api.provider.Provider) Optional(com.google.common.base.Optional) Map(java.util.Map) XcodeBinary(org.gradle.ide.xcode.internal.XcodeBinary) NSString(com.dd.plist.NSString) XcodeProjectFile(org.gradle.ide.xcode.tasks.internal.XcodeProjectFile) XcodePropertyAdapter(org.gradle.ide.xcode.internal.XcodePropertyAdapter) PBXLegacyTarget(org.gradle.ide.xcode.internal.xcodeproj.PBXLegacyTarget) PBXShellScriptBuildPhase(org.gradle.ide.xcode.internal.xcodeproj.PBXShellScriptBuildPhase) Incubating(org.gradle.api.Incubating) Internal(org.gradle.api.tasks.Internal) PBXTarget(org.gradle.ide.xcode.internal.xcodeproj.PBXTarget) PropertyListGeneratorTask(org.gradle.plugins.ide.api.PropertyListGeneratorTask) NSDictionary(com.dd.plist.NSDictionary) Action(org.gradle.api.Action) SwiftVersion(org.gradle.language.swift.SwiftVersion) PBXNativeTarget(org.gradle.ide.xcode.internal.xcodeproj.PBXNativeTarget) XcodeUtils.toSpaceSeparatedList(org.gradle.ide.xcode.internal.XcodeUtils.toSpaceSeparatedList) Collection(java.util.Collection) PBXBuildFile(org.gradle.ide.xcode.internal.xcodeproj.PBXBuildFile) Cast(org.gradle.internal.Cast) Collectors(java.util.stream.Collectors) PBXGroup(org.gradle.ide.xcode.internal.xcodeproj.PBXGroup) File(java.io.File) Objects(java.util.Objects) Consumer(java.util.function.Consumer) XcodeprojSerializer(org.gradle.ide.xcode.internal.xcodeproj.XcodeprojSerializer) MachineArchitecture(org.gradle.nativeplatform.MachineArchitecture) XcodeProject(org.gradle.ide.xcode.XcodeProject) List(java.util.List) PBXReference(org.gradle.ide.xcode.internal.xcodeproj.PBXReference) Joiner(com.google.common.base.Joiner) XcodeTarget(org.gradle.ide.xcode.internal.XcodeTarget) 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 NSString (com.dd.plist.NSString)1 Joiner (com.google.common.base.Joiner)1 Optional (com.google.common.base.Optional)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Action (org.gradle.api.Action)1 Incubating (org.gradle.api.Incubating)1 FileCollection (org.gradle.api.file.FileCollection)1 Provider (org.gradle.api.provider.Provider)1 Internal (org.gradle.api.tasks.Internal)1 XcodeProject (org.gradle.ide.xcode.XcodeProject)1