From 24624776cc23dfacac20eb554ccefe268f3b1a0a Mon Sep 17 00:00:00 2001 From: Peter Schmitt Date: Mon, 14 Aug 2017 13:57:29 -0400 Subject: Delete unused buck iOS support Change-Id: I56592ed4e507389d329377436223716c00348869 --- third_party/java/buck-ios-support/BUILD | 21 - third_party/java/buck-ios-support/LICENSE | 202 --------- third_party/java/buck-ios-support/METADATA | 23 -- .../java/com/facebook/buck/apple/FileTypes.java | 121 ------ .../facebook/buck/apple/xcode/GidGenerator.java | 50 --- .../buck/apple/xcode/XcodeprojSerializer.java | 140 ------- .../apple/xcode/xcodeproj/PBXAggregateTarget.java | 31 -- .../buck/apple/xcode/xcodeproj/PBXBuildFile.java | 80 ---- .../buck/apple/xcode/xcodeproj/PBXBuildPhase.java | 44 -- .../buck/apple/xcode/xcodeproj/PBXBuildStyle.java | 61 --- .../buck/apple/xcode/xcodeproj/PBXContainer.java | 28 -- .../apple/xcode/xcodeproj/PBXContainerItem.java | 36 -- .../xcode/xcodeproj/PBXContainerItemProxy.java | 88 ---- .../xcode/xcodeproj/PBXCopyFilesBuildPhase.java | 85 ---- .../apple/xcode/xcodeproj/PBXFileReference.java | 78 ---- .../xcode/xcodeproj/PBXFrameworksBuildPhase.java | 28 -- .../buck/apple/xcode/xcodeproj/PBXGroup.java | 165 -------- .../xcode/xcodeproj/PBXHeadersBuildPhase.java | 28 -- .../apple/xcode/xcodeproj/PBXNativeTarget.java | 32 -- .../buck/apple/xcode/xcodeproj/PBXObject.java | 67 --- .../buck/apple/xcode/xcodeproj/PBXProject.java | 102 ----- .../buck/apple/xcode/xcodeproj/PBXProjectItem.java | 24 -- .../buck/apple/xcode/xcodeproj/PBXReference.java | 158 -------- .../xcode/xcodeproj/PBXResourcesBuildPhase.java | 30 -- .../xcode/xcodeproj/PBXShellScriptBuildPhase.java | 130 ------ .../xcode/xcodeproj/PBXSourcesBuildPhase.java | 29 -- .../buck/apple/xcode/xcodeproj/PBXTarget.java | 140 ------- .../apple/xcode/xcodeproj/PBXTargetDependency.java | 53 --- .../apple/xcode/xcodeproj/PBXVariantGroup.java | 96 ----- .../buck/apple/xcode/xcodeproj/SourceTreePath.java | 65 --- .../xcode/xcodeproj/XCBuildConfiguration.java | 55 --- .../apple/xcode/xcodeproj/XCConfigurationList.java | 82 ---- .../buck/apple/xcode/xcodeproj/XCVersionGroup.java | 114 ------ .../java/com/facebook/buck/log/Logger.java | 451 --------------------- 34 files changed, 2937 deletions(-) delete mode 100644 third_party/java/buck-ios-support/BUILD delete mode 100644 third_party/java/buck-ios-support/LICENSE delete mode 100644 third_party/java/buck-ios-support/METADATA delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/FileTypes.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/GidGenerator.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/XcodeprojSerializer.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXAggregateTarget.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXBuildFile.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXBuildPhase.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXBuildStyle.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXContainer.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXContainerItem.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXContainerItemProxy.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXCopyFilesBuildPhase.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXFileReference.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXFrameworksBuildPhase.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXGroup.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXHeadersBuildPhase.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXNativeTarget.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXObject.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXProject.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXProjectItem.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXReference.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXResourcesBuildPhase.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXShellScriptBuildPhase.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXSourcesBuildPhase.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXTarget.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXTargetDependency.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXVariantGroup.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/SourceTreePath.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/XCBuildConfiguration.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/XCConfigurationList.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/XCVersionGroup.java delete mode 100644 third_party/java/buck-ios-support/java/com/facebook/buck/log/Logger.java (limited to 'third_party/java') diff --git a/third_party/java/buck-ios-support/BUILD b/third_party/java/buck-ios-support/BUILD deleted file mode 100644 index fd84b25b2d..0000000000 --- a/third_party/java/buck-ios-support/BUILD +++ /dev/null @@ -1,21 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # Apache 2.0 - -filegroup( - name = "srcs", - srcs = glob(["**"]), - visibility = ["//third_party:__pkg__"], -) - -java_library( - name = "buck-ios-support", - srcs = glob( - ["java/**/*.java"], - ), - deps = [ - "//third_party:guava", - "//third_party:jsr305", - "//third_party/java/dd_plist", - ], -) diff --git a/third_party/java/buck-ios-support/LICENSE b/third_party/java/buck-ios-support/LICENSE deleted file mode 100644 index d645695673..0000000000 --- a/third_party/java/buck-ios-support/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/third_party/java/buck-ios-support/METADATA b/third_party/java/buck-ios-support/METADATA deleted file mode 100644 index 2b98083782..0000000000 --- a/third_party/java/buck-ios-support/METADATA +++ /dev/null @@ -1,23 +0,0 @@ -# This copy is stripped down to only include the files needed for Xcode project -# generation, specifically: -# com/facebook/buck/apple/{FileTypes,xcode/{xcodeproj/**,GidGenerator,XcodeprojSerializer}}.java - -name: "Buck" -description: "Buck: An Android (and Java!) build tool" - -third_party { - url { - type: GIT - value: "https://github.com/facebook/buck" - } - version: "2ff4f45a971776afcfbe88333d78c4ca6bf03df9" - last_upgrade_date { year: 2014 month: 7 day: 29 } - local_modifications: - "* Add FILE_REFERENCE(2) to the PBXContainerItemProxy.ProxyType enum. " - "* Update LastUpgradeCheck from 600 to 610 " - "* Add logic to automatically detect XCVersionGroup type even if there " - " is no currentVersion set " - "* Removed code not used by Bazel. " - "* Add WATCH_OS1_EXTENSION and WATCH_OS1_APPLICATION to " - " PBXTarget.ProductType" -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/FileTypes.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/FileTypes.java deleted file mode 100644 index 1ea0c04831..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/FileTypes.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2014-present Facebook, Inc. - * - * 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 com.facebook.buck.apple; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; - -/** - * File types used in Apple targets. - */ -public final class FileTypes { - - // Utility class. Do not instantiate. - private FileTypes() { } - - /** - * Map of file extension to Apple UTI (Uniform Type Identifier). - */ - public static final ImmutableMap FILE_EXTENSION_TO_UTI = - ImmutableMap.builder() - .put("a", "archive.ar") - .put("app", "wrapper.application") - .put("appex", "wrapper.app-extension") - .put("bdic", "file") - .put("bin", "archive.macbinary") - .put("bmp", "image.bmp") - .put("bundle", "wrapper.cfbundle") - .put("c", "sourcecode.c.c") - .put("cc", "sourcecode.cpp.cpp") - .put("cpp", "sourcecode.cpp.cpp") - .put("css", "text.css") - .put("cxx", "sourcecode.cpp.cpp") - .put("dart", "sourcecode") - .put("dylib", "compiled.mach-o.dylib") - .put("exp", "sourcecode.exports") - .put("framework", "wrapper.framework") - .put("fsh", "sourcecode.glsl") - .put("gyp", "sourcecode") - .put("gypi", "text") - .put("h", "sourcecode.c.h") - .put("hxx", "sourcecode.cpp.h") - .put("icns", "image.icns") - .put("java", "sourcecode.java") - .put("jar", "archive.jar") - .put("jpeg", "image.jpeg") - .put("jpg", "image.jpeg") - .put("js", "sourcecode.javascript") - .put("json", "text.json") - .put("m", "sourcecode.c.objc") - .put("mm", "sourcecode.cpp.objcpp") - .put("nib", "wrapper.nib") - .put("o", "compiled.mach-o.objfile") - .put("octest", "wrapper.cfbundle") - .put("pdf", "image.pdf") - .put("pl", "text.script.perl") - .put("plist", "text.plist.xml") - .put("pm", "text.script.perl") - .put("png", "image.png") - .put("proto", "text") - .put("py", "text.script.python") - .put("r", "sourcecode.rez") - .put("rez", "sourcecode.rez") - .put("rtf", "text.rtf") - .put("s", "sourcecode.asm") - .put("storyboard", "file.storyboard") - .put("strings", "text.plist.strings") - .put("tif", "image.tiff") - .put("tiff", "image.tiff") - .put("tcc", "sourcecode.cpp.cpp") - .put("ttf", "file") - .put("vsh", "sourcecode.glsl") - .put("xcassets", "folder.assetcatalog") - .put("xcconfig", "text.xcconfig") - .put("xcodeproj", "wrapper.pb-project") - .put("xcdatamodel", "wrapper.xcdatamodel") - .put("xcdatamodeld", "wrapper.xcdatamodeld") - .put("xctest", "wrapper.cfbundle") - .put("xib", "file.xib") - .put("y", "sourcecode.yacc") - .put("zip", "archive.zip") - .build(); - - /** - * Set of UTIs which only work as "lastKnownFileType" and not "explicitFileType" - * in a PBXFileReference. - * - * Yes, really. Because Xcode. - */ - public static final ImmutableSet EXPLICIT_FILE_TYPE_BROKEN_UTIS = - ImmutableSet.of("file.xib"); - - /** - * Multimap of Apple UTI (Uniform Type Identifier) to file extension(s). - */ - public static final ImmutableMultimap UTI_TO_FILE_EXTENSIONS; - - static { - // Invert the map of (file extension -> UTI) pairs to - // (UTI -> [file extension 1, ...]) pairs. - ImmutableMultimap.Builder builder = ImmutableMultimap.builder(); - for (ImmutableMap.Entry entry : FILE_EXTENSION_TO_UTI.entrySet()) { - builder.put(entry.getValue(), entry.getKey()); - } - UTI_TO_FILE_EXTENSIONS = builder.build(); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/GidGenerator.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/GidGenerator.java deleted file mode 100644 index 03395a05ba..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/GidGenerator.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode; - -import com.google.common.collect.Sets; - -import java.util.Set; - -/** - * Generator for Global ID (GID) which are present on every xcode project object. - * - * The GID is a 96 bit identifier that's unique on a per-project basis. - */ -public class GidGenerator { - private final Set generatedAndReservedIds; - - public GidGenerator(Set reservedIds) { - generatedAndReservedIds = Sets.newHashSet(reservedIds); - } - - /** - * Generate a stable GID based on the class name and hash of some object info. - * - * GIDs generated this way will be in the form of - * {@code } - */ - public String generateGid(String pbxClassName, int hash) { - int counter = 0; - String gid; - do { - gid = String.format("%08X%08X%08X", pbxClassName.hashCode(), hash, counter++); - } while (generatedAndReservedIds.contains(gid)); - generatedAndReservedIds.add(gid); - return gid; - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/XcodeprojSerializer.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/XcodeprojSerializer.java deleted file mode 100644 index b43081f90a..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/XcodeprojSerializer.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode; - -import com.dd.plist.NSArray; -import com.dd.plist.NSDictionary; -import com.dd.plist.NSObject; -import com.dd.plist.NSString; -import com.facebook.buck.log.Logger; -import com.facebook.buck.apple.xcode.xcodeproj.PBXObject; -import com.facebook.buck.apple.xcode.xcodeproj.PBXProject; - -import java.util.List; - -import javax.annotation.concurrent.NotThreadSafe; - -/** - * Serializer that handles conversion of an in-memory object graph representation of an xcode - * project (instances of {@link PBXObject}) into an Apple property list. - * - * Serialization proceeds from the root object, a ${link PBXProject} instance, to all of its - * referenced objects. Each object being visited calls back into this class ({@link #addField}) to - * populate the plist representation with its fields. - */ -@NotThreadSafe -public class XcodeprojSerializer { - private static final Logger LOG = Logger.get(XcodeprojSerializer.class); - - private final PBXProject rootObject; - private final NSDictionary objects; - private final GidGenerator gidGenerator; - private NSDictionary currentObject; - - public XcodeprojSerializer(GidGenerator gidGenerator, PBXProject project) { - rootObject = project; - objects = new NSDictionary(); - this.gidGenerator = gidGenerator; - } - - /** - * Generate a plist serialization of project bound to this serializer. - */ - public NSDictionary toPlist() { - serializeObject(rootObject); - - NSDictionary root = new NSDictionary(); - root.put("archiveVersion", "1"); - root.put("classes", new NSDictionary()); - root.put("objectVersion", "46"); - root.put("objects", objects); - root.put("rootObject", rootObject.getGlobalID()); - - return root; - } - - /** - * Serialize a {@link PBXObject} and its recursive descendants into the object dictionary. - * - * @return the GID of the serialized object - * - * @see PBXObject#serializeInto - */ - private String serializeObject(PBXObject obj) { - if (obj.getGlobalID() == null) { - obj.setGlobalID(obj.generateGid(gidGenerator)); - LOG.verbose("Set new object GID: %s", obj); - } else { - // Check that the object has already been serialized. - NSObject object = objects.get(obj.getGlobalID()); - if (object != null) { - LOG.verbose("Object %s found, returning existing object %s", obj, object); - return obj.getGlobalID(); - } else { - LOG.verbose("Object already had GID set: %s", obj); - } - } - - // Save the existing object being deserialized. - NSDictionary stack = currentObject; - - currentObject = new NSDictionary(); - currentObject.put("isa", obj.isa()); - obj.serializeInto(this); - objects.put(obj.getGlobalID(), currentObject); - - // Restore the existing object being deserialized. - currentObject = stack; - return obj.getGlobalID(); - } - - public void addField(String name, PBXObject obj) { - if (obj != null) { - String gid = serializeObject(obj); - currentObject.put(name, gid); - } - } - - public void addField(String name, int val) { - currentObject.put(name, val); - } - - public void addField(String name, String val) { - if (val != null) { - currentObject.put(name, val); - } - } - - public void addField(String name, boolean val) { - currentObject.put(name, val); - } - - public void addField(String name, List objectList) { - NSArray array = new NSArray(objectList.size()); - for (int i = 0; i < objectList.size(); i++) { - String gid = serializeObject(objectList.get(i)); - array.setValue(i, new NSString(gid)); - } - currentObject.put(name, array); - } - - public void addField(String name, NSObject v) { - if (v != null) { - currentObject.put(name, v); - } - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXAggregateTarget.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXAggregateTarget.java deleted file mode 100644 index 1e6601004f..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXAggregateTarget.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -/** - * Target backed by shell scripts or nothing (only specifying dependencies). - */ -public class PBXAggregateTarget extends PBXTarget { - public PBXAggregateTarget(String name, ProductType productType) { - super(name, productType); - } - - @Override - public String isa() { - return "PBXAggregateTarget"; - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXBuildFile.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXBuildFile.java deleted file mode 100644 index cdab5b64c7..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXBuildFile.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.dd.plist.NSDictionary; -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; - -/** - * File referenced by a build phase, unique to each build phase. - * - * Contains a dictionary {@link #settings} which holds additional information to be interpreted by - * the particular phase referencing this object, e.g.: - * - * - {@link PBXHeadersBuildPhase } may read {"ATTRIBUTES": ["Public"]} and interpret - * the build file as a public (exported) header. - * - {@link PBXSourcesBuildPhase } may read {"COMPILER_FLAGS": "-foo"} and interpret - * that this file should be compiled with the additional flag {@code "-foo" }. - */ -public class PBXBuildFile extends PBXProjectItem { - private final PBXReference fileRef; - private Optional settings; - - public PBXBuildFile(PBXReference fileRef) { - this.fileRef = Preconditions.checkNotNull(fileRef); - this.settings = Optional.absent(); - } - - public PBXReference getFileRef() { - return fileRef; - } - - public Optional getSettings() { - return settings; - } - - public void setSettings(Optional v) { - settings = v; - } - - @Override - public String isa() { - return "PBXBuildFile"; - } - - @Override - public int stableHash() { - return fileRef.stableHash(); - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - s.addField("fileRef", fileRef); - if (settings.isPresent()) { - s.addField("settings", settings.get()); - } - } - - @Override - public String toString() { - return String.format("%s fileRef=%s settings=%s", super.toString(), fileRef, settings); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXBuildPhase.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXBuildPhase.java deleted file mode 100644 index 96d0cd336a..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXBuildPhase.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.collect.Lists; - -import java.util.List; - -/** - * Superclass of build phases. Each build phase represents one step in building a target. - */ -public abstract class PBXBuildPhase extends PBXProjectItem { - private final List files; - - public PBXBuildPhase() { - this.files = Lists.newArrayList(); - } - - public List getFiles() { - return files; - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - s.addField("files", files); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXBuildStyle.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXBuildStyle.java deleted file mode 100644 index be572d557c..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXBuildStyle.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.dd.plist.NSDictionary; -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.base.Preconditions; - -public class PBXBuildStyle extends PBXProjectItem { - private final String name; - private NSDictionary buildSettings; - - public PBXBuildStyle(String name) { - this.name = Preconditions.checkNotNull(name); - this.buildSettings = new NSDictionary(); - } - - public String getName() { - return name; - } - - public NSDictionary getBuildSettings() { - return buildSettings; - } - - public void setBuildSettings(NSDictionary buildSettings) { - this.buildSettings = buildSettings; - } - - @Override - public String isa() { - return "PBXBuildStyle"; - } - - @Override - public int stableHash() { - return name.hashCode(); - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - s.addField("name", name); - s.addField("buildSettings", buildSettings); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXContainer.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXContainer.java deleted file mode 100644 index 6954f7ffed..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXContainer.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -/** - * Superclass of all container types. This is here to reflect Xcode's object hierarchy, and does - * not implement any special functionality. - */ -public abstract class PBXContainer extends PBXObject { - @Override - public String isa() { - return "PBXContainer"; - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXContainerItem.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXContainerItem.java deleted file mode 100644 index c182b8ad08..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXContainerItem.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.xcode.XcodeprojSerializer; - -/** - * Superclass in Xcode's object hierarchy, has no non-structural functionality here. - */ -public abstract class PBXContainerItem extends PBXObject { - - @Override - public String isa() { - return "PBXContainerItem"; - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXContainerItemProxy.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXContainerItemProxy.java deleted file mode 100644 index 72badae239..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXContainerItemProxy.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.base.Preconditions; - -/** - * Reference to another object used by {@link PBXTargetDependency}. Can reference a remote file - * by specifying the {@link PBXFileReference} to the remote project file, and the GID of the object - * within that file. - */ -public class PBXContainerItemProxy extends PBXContainerItem { - public enum ProxyType { - TARGET_REFERENCE(1), - FILE_REFERENCE(2); - - private final int intValue; - private ProxyType(int intValue) { - this.intValue = intValue; - } - - public int getIntValue() { - return intValue; - } - } - - private final PBXFileReference containerPortal; - private final String remoteGlobalIDString; - private final ProxyType proxyType; - - public PBXContainerItemProxy( - PBXFileReference containerPortal, - String remoteGlobalIDString, - ProxyType proxyType) { - Preconditions.checkNotNull(containerPortal); - Preconditions.checkNotNull(remoteGlobalIDString); - Preconditions.checkNotNull(proxyType); - this.containerPortal = containerPortal; - this.remoteGlobalIDString = remoteGlobalIDString; - this.proxyType = proxyType; - } - - public PBXFileReference getContainerPortal() { - return containerPortal; - } - - public String getRemoteGlobalIDString() { - return remoteGlobalIDString; - } - - public ProxyType getProxyType() { - return proxyType; - } - - @Override - public String isa() { - return "PBXContainerItemProxy"; - } - - @Override - public int stableHash() { - return remoteGlobalIDString.hashCode(); - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - s.addField("containerPortal", containerPortal); - s.addField("remoteGlobalIDString", remoteGlobalIDString); - s.addField("proxyType", proxyType.getIntValue()); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXCopyFilesBuildPhase.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXCopyFilesBuildPhase.java deleted file mode 100644 index fcf2ed5e1b..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXCopyFilesBuildPhase.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.base.Preconditions; - -public class PBXCopyFilesBuildPhase extends PBXBuildPhase { - /** - * The prefix path, this does not use SourceTreePath and build variables but rather some sort of - * enum. - */ - public enum Destination { - ABSOLUTE(0), - WRAPPER(1), - EXECUTABLES(6), - RESOURCES(7), - FRAMEWORKS(10), - SHARED_FRAMEWORKS(11), - SHARED_SUPPORT(12), - PLUGINS(13), - JAVA_RESOURCES(15), - PRODUCTS(16), - ; - - private int value; - - public int getValue() { - return value; - } - - private Destination(int value) { - this.value = value; - } - } - - /** - * Base path of destination folder. - */ - private Destination dstSubfolderSpec; - - /** - * Subdirectory under the destination folder. - */ - private String path; - - public PBXCopyFilesBuildPhase(Destination dstSubfolderSpec, String path) { - this.dstSubfolderSpec = Preconditions.checkNotNull(dstSubfolderSpec); - this.path = Preconditions.checkNotNull(path); - } - - public Destination getDstSubfolderSpec() { - return dstSubfolderSpec; - } - - public String getPath() { - return path; - } - - @Override - public String isa() { - return "PBXCopyFilesBuildPhase"; - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - s.addField("dstSubfolderSpec", dstSubfolderSpec.getValue()); - s.addField("dstPath", path); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXFileReference.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXFileReference.java deleted file mode 100644 index 50b9144309..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXFileReference.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.FileTypes; -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.base.Optional; -import com.google.common.io.Files; - -/** - * Reference to a concrete file. - */ -public class PBXFileReference extends PBXReference { - private Optional explicitFileType; - private Optional lastKnownFileType; - - public PBXFileReference(String name, String path, SourceTree sourceTree) { - super(name, path, sourceTree); - - // this is necessary to prevent O(n^2) behavior in xcode project loading - String fileType = FileTypes.FILE_EXTENSION_TO_UTI.get(Files.getFileExtension(name)); - if (FileTypes.EXPLICIT_FILE_TYPE_BROKEN_UTIS.contains(fileType)) { - explicitFileType = Optional.absent(); - lastKnownFileType = Optional.of(fileType); - } else { - explicitFileType = Optional.fromNullable(fileType); - lastKnownFileType = Optional.absent(); - } - } - - public Optional getExplicitFileType() { - return explicitFileType; - } - - public void setExplicitFileType(Optional explicitFileType) { - this.explicitFileType = explicitFileType; - } - - @Override - public String isa() { - return "PBXFileReference"; - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - if (explicitFileType.isPresent()) { - s.addField("explicitFileType", explicitFileType.get()); - } - - if (lastKnownFileType.isPresent()) { - s.addField("lastKnownFileType", lastKnownFileType.get()); - } - } - - @Override - public String toString() { - return String.format( - "%s explicitFileType=%s", - super.toString(), - getExplicitFileType()); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXFrameworksBuildPhase.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXFrameworksBuildPhase.java deleted file mode 100644 index be4b613bc1..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXFrameworksBuildPhase.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -/** - * Build phase representing the linking step of a target. Contains references to libraries and - * system frameworks. In library targets, it may alter the include path. - */ -public class PBXFrameworksBuildPhase extends PBXBuildPhase { - @Override - public String isa() { - return "PBXFrameworksBuildPhase"; - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXGroup.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXGroup.java deleted file mode 100644 index dc636b7969..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXGroup.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.Lists; -import com.google.common.base.Preconditions; - -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import javax.annotation.Nullable; - -/** - * A collection of files in Xcode's virtual filesystem hierarchy. - */ -public class PBXGroup extends PBXReference { - /** - * Method by which group contents will be sorted. - */ - public enum SortPolicy { - /** - * By name, in default Java sort order. - */ - BY_NAME, - - /** - * Group contents will not be sorted, and will remain in the - * order they were added. - */ - UNSORTED; - } - - // Unfortunately, we can't determine this at constructor time, because CacheBuilder - // calls our constructor and it's not easy to pass arguments to it. - private SortPolicy sortPolicy; - - private final List children; - - private final LoadingCache childGroupsByName; - private final LoadingCache childVariantGroupsByName; - private final LoadingCache fileReferencesBySourceTreePath; - private final LoadingCache childVersionGroupsBySourceTreePath; - - public PBXGroup(String name, @Nullable String path, SourceTree sourceTree) { - super(name, path, sourceTree); - - sortPolicy = SortPolicy.BY_NAME; - children = Lists.newArrayList(); - - childGroupsByName = CacheBuilder.newBuilder().build( - new CacheLoader() { - @Override - public PBXGroup load(String key) throws Exception { - PBXGroup group = new PBXGroup(key, null, SourceTree.GROUP); - children.add(group); - return group; - } - }); - - childVariantGroupsByName = CacheBuilder.newBuilder().build( - new CacheLoader() { - @Override - public PBXVariantGroup load(String key) throws Exception { - PBXVariantGroup group = new PBXVariantGroup(key, null, SourceTree.GROUP); - children.add(group); - return group; - } - }); - - fileReferencesBySourceTreePath = CacheBuilder.newBuilder().build( - new CacheLoader() { - @Override - public PBXFileReference load(SourceTreePath key) throws Exception { - PBXFileReference ref = new PBXFileReference( - key.getPath().getFileName().toString(), - key.getPath().toString(), - key.getSourceTree()); - children.add(ref); - return ref; - } - }); - - childVersionGroupsBySourceTreePath = CacheBuilder.newBuilder().build( - new CacheLoader() { - @Override - public XCVersionGroup load(SourceTreePath key) throws Exception { - XCVersionGroup ref = new XCVersionGroup( - key.getPath().getFileName().toString(), - key.getPath().toString(), - key.getSourceTree()); - children.add(ref); - return ref; - } - }); - } - - public PBXGroup getOrCreateChildGroupByName(String name) { - return childGroupsByName.getUnchecked(name); - } - - public PBXVariantGroup getOrCreateChildVariantGroupByName(String name) { - return childVariantGroupsByName.getUnchecked(name); - } - - public PBXFileReference getOrCreateFileReferenceBySourceTreePath(SourceTreePath sourceTreePath) { - return fileReferencesBySourceTreePath.getUnchecked(sourceTreePath); - } - - public XCVersionGroup getOrCreateChildVersionGroupsBySourceTreePath( - SourceTreePath sourceTreePath) { - return childVersionGroupsBySourceTreePath.getUnchecked(sourceTreePath); - } - - public List getChildren() { - return children; - } - - public void setSortPolicy(SortPolicy sortPolicy) { - this.sortPolicy = Preconditions.checkNotNull(sortPolicy); - } - - public SortPolicy getSortPolicy() { - return sortPolicy; - } - - @Override - public String isa() { - return "PBXGroup"; - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - if (sortPolicy == SortPolicy.BY_NAME) { - Collections.sort(children, new Comparator() { - @Override - public int compare(PBXReference o1, PBXReference o2) { - return o1.getName().compareTo(o2.getName()); - } - }); - } - - s.addField("children", children); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXHeadersBuildPhase.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXHeadersBuildPhase.java deleted file mode 100644 index 3793d2db38..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXHeadersBuildPhase.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -/** - * Build phase that copies header files into the output headers directory. Does nothing for binary - * and test rules. - */ -public class PBXHeadersBuildPhase extends PBXBuildPhase { - @Override - public String isa() { - return "PBXHeadersBuildPhase"; - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXNativeTarget.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXNativeTarget.java deleted file mode 100644 index a99c6b76c9..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXNativeTarget.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -/** - * Concrete target type representing targets built by xcode itself, rather than an external build - * system. - */ -public class PBXNativeTarget extends PBXTarget { - public PBXNativeTarget(String name, ProductType productType) { - super(name, productType); - } - - @Override - public String isa() { - return "PBXNativeTarget"; - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXObject.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXObject.java deleted file mode 100644 index d665f7549c..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXObject.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.xcode.GidGenerator; -import com.facebook.buck.apple.xcode.XcodeprojSerializer; - -import javax.annotation.Nullable; - -public abstract class PBXObject { - @Nullable - private String globalID; - - @Nullable - public String getGlobalID() { - return globalID; - } - - public void setGlobalID(String gid) { - globalID = gid; - } - - /** - * @return Type name of the serialized object. - */ - public abstract String isa(); - - /** - * Populates the serializer with the fields of this object. - */ - public void serializeInto(@SuppressWarnings("unused") XcodeprojSerializer serializer) { - } - - /** - * This method is used to generate stable GIDs and must be stable for identical contents. - * Returning a constant value is ok but will make the generated project order-dependent. - */ - public int stableHash() { - return 0; - } - - @Override - public String toString() { - return String.format("%s isa=%s gid=%s", super.toString(), isa(), getGlobalID()); - } - - /** - * Generate a stable GID. - */ - public final String generateGid(GidGenerator generator) { - return generator.generateGid(isa(), stableHash()); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXProject.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXProject.java deleted file mode 100644 index 1eec5e9fdd..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXProject.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.base.Function; -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; -import com.google.common.collect.Ordering; -import com.dd.plist.NSDictionary; - -import java.util.Collections; -import java.util.List; - -/** - * The root object representing the project itself. - */ -public class PBXProject extends PBXContainer { - private String name; - private final PBXGroup mainGroup; - private final List targets; - private final XCConfigurationList buildConfigurationList; - private final String compatibilityVersion; - - public PBXProject(String name) { - this.name = Preconditions.checkNotNull(name); - this.mainGroup = new PBXGroup("mainGroup", null, PBXReference.SourceTree.GROUP); - this.targets = Lists.newArrayList(); - this.buildConfigurationList = new XCConfigurationList(); - this.compatibilityVersion = "Xcode 3.2"; - } - - public String getName() { - return name; - } - - public void setName(String v) { - name = v; - } - - public PBXGroup getMainGroup() { - return mainGroup; - } - - public List getTargets() { - return targets; - } - - public XCConfigurationList getBuildConfigurationList() { - return buildConfigurationList; - } - - public String getCompatibilityVersion() { - return compatibilityVersion; - } - - @Override - public String isa() { - return "PBXProject"; - } - - @Override - public int stableHash() { - return name.hashCode(); - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - s.addField("mainGroup", mainGroup); - - Collections.sort(targets, Ordering.natural().onResultOf(new Function() { - @Override - public String apply(PBXTarget input) { - return input.getName(); - } - })); - s.addField("targets", targets); - s.addField("buildConfigurationList", buildConfigurationList); - s.addField("compatibilityVersion", compatibilityVersion); - - NSDictionary d = new NSDictionary(); - d.put("LastUpgradeCheck", "0610"); - - s.addField("attributes", d); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXProjectItem.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXProjectItem.java deleted file mode 100644 index 2b9003427b..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXProjectItem.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -public abstract class PBXProjectItem extends PBXContainerItem { - @Override - public String isa() { - return "PBXProjectItem"; - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXReference.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXReference.java deleted file mode 100644 index a7bed6d35b..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXReference.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.base.CharMatcher; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; - -import javax.annotation.Nullable; - -/** - * Superclass for file, directories, and groups. Xcode's virtual file hierarchy are made of these - * objects. - */ -public class PBXReference extends PBXContainerItem { - public enum SourceTree { - /** - * Relative to the path of the group containing this. - */ - GROUP(""), - - /** - * Absolute system path. - */ - ABSOLUTE(""), - /** - * Relative to the build setting {@code BUILT_PRODUCTS_DIR}. - */ - BUILT_PRODUCTS_DIR("BUILT_PRODUCTS_DIR"), - - /** - * Relative to the build setting {@code SDKROOT}. - */ - SDKROOT("SDKROOT"), - - /** - * Relative to the directory containing the project file {@code SOURCE_ROOT}. - */ - SOURCE_ROOT("SOURCE_ROOT"), - - /** - * Relative to the Developer content directory inside the Xcode application - * (e.g. {@code /Applications/Xcode.app/Contents/Developer}). - */ - DEVELOPER_DIR("DEVELOPER_DIR"), - ; - - private final String rep; - - SourceTree(String str) { - rep = str; - } - - @Override - public String toString() { - return rep; - } - - /** - * Return a sourceTree given a build setting that is typically used as a source tree prefix. - * - * The build setting may be optionally prefixed by '$' which will be stripped. - */ - public static Optional fromBuildSetting(String buildSetting) { - switch (CharMatcher.is('$').trimLeadingFrom(buildSetting)) { - case "BUILT_PRODUCTS_DIR": - return Optional.of(BUILT_PRODUCTS_DIR); - case "SDKROOT": - return Optional.of(SDKROOT); - case "SOURCE_ROOT": - return Optional.of(SOURCE_ROOT); - case "DEVELOPER_DIR": - return Optional.of(DEVELOPER_DIR); - default: - return Optional.absent(); - } - } - } - - private final String name; - @Nullable private String path; - - /** - * The "base" path of the reference. The absolute path is resolved by prepending the resolved - * base path. - */ - private SourceTree sourceTree; - - public PBXReference(String name, @Nullable String path, SourceTree sourceTree) { - this.name = Preconditions.checkNotNull(name); - this.path = path; - this.sourceTree = Preconditions.checkNotNull(sourceTree); - } - - public String getName() { - return name; - } - - @Nullable - public String getPath() { - return path; - } - public void setPath(String v) { - path = v; - } - public SourceTree getSourceTree() { - return sourceTree; - } - public void setSourceTree(SourceTree v) { - sourceTree = v; - } - - @Override - public String isa() { - return "PBXReference"; - } - - @Override - public int stableHash() { - return name.hashCode(); - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - s.addField("name", name); - if (path != null) { - s.addField("path", path); - } - s.addField("sourceTree", sourceTree.toString()); - } - - @Override - public String toString() { - return String.format( - "%s name=%s path=%s sourceTree=%s", - super.toString(), - getName(), - getPath(), - getSourceTree()); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXResourcesBuildPhase.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXResourcesBuildPhase.java deleted file mode 100644 index e0fd771fa2..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXResourcesBuildPhase.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -/** - * Lists the files to be copied into the output resources directory for the containing - * {@link PBXTarget}. Has no effect in library rules. - * - * A target should contain at most one of this build phase. - */ -public class PBXResourcesBuildPhase extends PBXBuildPhase { - @Override - public String isa() { - return "PBXResourcesBuildPhase"; - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXShellScriptBuildPhase.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXShellScriptBuildPhase.java deleted file mode 100644 index 7192826a5c..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXShellScriptBuildPhase.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2014-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.dd.plist.NSArray; -import com.dd.plist.NSString; -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.collect.Lists; - -import java.util.List; - -import javax.annotation.Nullable; - -/** - * Build phase which represents running a shell script. - */ -public class PBXShellScriptBuildPhase extends PBXBuildPhase { - private List inputPaths; - private List outputPaths; - @Nullable private String shellPath; - @Nullable private String shellScript; - - private static final NSString DEFAULT_SHELL_PATH = new NSString("/bin/sh"); - private static final NSString DEFAULT_SHELL_SCRIPT = new NSString(""); - - public PBXShellScriptBuildPhase() { - this.inputPaths = Lists.newArrayList(); - this.outputPaths = Lists.newArrayList(); - } - - @Override - public String isa() { - return "PBXShellScriptBuildPhase"; - } - - /** - * Returns the list (possibly empty) of files passed as input to the shell script. - * May not be actual paths, because they can have variable interpolations. - */ - public List getInputPaths() { - return inputPaths; - } - - /** - * Returns the list (possibly empty) of files created as output of the shell script. - * May not be actual paths, because they can have variable interpolations. - */ - public List getOutputPaths() { - return outputPaths; - } - - /** - * Returns the path to the shell under which the script is to be executed. - * Defaults to "/bin/sh". - */ - @Nullable - public String getShellPath() { - return shellPath; - } - - /** - * Sets the path to the shell under which the script is to be executed. - */ - public void setShellPath(String shellPath) { - this.shellPath = shellPath; - } - - /** - * Gets the contents of the shell script to execute under the shell - * returned by {@link #getShellPath()}. - */ - @Nullable - public String getShellScript() { - return shellScript; - } - - /** - * Sets the contents of the script to execute. - */ - public void setShellScript(String shellScript) { - this.shellScript = shellScript; - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - NSArray inputPathsArray = new NSArray(inputPaths.size()); - for (int i = 0; i < inputPaths.size(); i++) { - inputPathsArray.setValue(i, new NSString(inputPaths.get(i))); - } - s.addField("inputPaths", inputPathsArray); - - NSArray outputPathsArray = new NSArray(outputPaths.size()); - for (int i = 0; i < outputPaths.size(); i++) { - outputPathsArray.setValue(i, new NSString(outputPaths.get(i))); - } - s.addField("outputPaths", outputPathsArray); - - NSString shellPathString; - if (shellPath == null) { - shellPathString = DEFAULT_SHELL_PATH; - } else { - shellPathString = new NSString(shellPath); - } - s.addField("shellPath", shellPathString); - - NSString shellScriptString; - if (shellScript == null) { - shellScriptString = DEFAULT_SHELL_SCRIPT; - } else { - shellScriptString = new NSString(shellScript); - } - s.addField("shellScript", shellScriptString); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXSourcesBuildPhase.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXSourcesBuildPhase.java deleted file mode 100644 index 8a43dc7884..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXSourcesBuildPhase.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -/** - * Lists the files to be compiled for the containing {@link PBXTarget}. - * - * A target should contain at most one of this build phase. - */ -public class PBXSourcesBuildPhase extends PBXBuildPhase { - @Override - public String isa() { - return "PBXSourcesBuildPhase"; - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXTarget.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXTarget.java deleted file mode 100644 index 7aa16ae06c..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXTarget.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; - -import java.util.List; - -import javax.annotation.Nullable; - -/** - * Information for building a specific artifact (a library, binary, or test). - */ -public abstract class PBXTarget extends PBXProjectItem { - public enum ProductType { - STATIC_LIBRARY("com.apple.product-type.library.static"), - DYNAMIC_LIBRARY("com.apple.product-type.library.dynamic"), - TOOL("com.apple.product-type.tool"), - BUNDLE("com.apple.product-type.bundle"), - FRAMEWORK("com.apple.product-type.framework"), - STATIC_FRAMEWORK("com.apple.product-type.framework.static"), - APPLICATION("com.apple.product-type.application"), - UNIT_TEST("com.apple.product-type.bundle.unit-test"), - IN_APP_PURCHASE_CONTENT("com.apple.product-type.in-app-purchase-content"), - APP_EXTENSION("com.apple.product-type.app-extension"), - WATCH_OS1_APPLICATION("com.apple.product-type.application.watchapp"), - WATCH_OS1_EXTENSION("com.apple.product-type.watchkit-extension"); - - public final String identifier; - private ProductType(String identifier) { - this.identifier = identifier; - } - - @Override - public String toString() { - return identifier; - } - } - - private final String name; - private final ProductType productType; - private final List dependencies; - private final List buildPhases; - private final XCConfigurationList buildConfigurationList; - @Nullable private String productName; - @Nullable private PBXFileReference productReference; - - public PBXTarget(String name, ProductType productType) { - this.name = Preconditions.checkNotNull(name); - this.productType = Preconditions.checkNotNull(productType); - this.dependencies = Lists.newArrayList(); - this.buildPhases = Lists.newArrayList(); - this.buildConfigurationList = new XCConfigurationList(); - } - - public String getName() { - return name; - } - - public ProductType getProductType() { - return productType; - } - - public List getDependencies() { - return dependencies; - } - - public List getBuildPhases() { - return buildPhases; - } - - public XCConfigurationList getBuildConfigurationList() { - return buildConfigurationList; - } - - @Nullable - public String getProductName() { - return productName; - } - - public void setProductName(String productName) { - this.productName = productName; - } - - @Nullable - public PBXFileReference getProductReference() { - return productReference; - } - - public void setProductReference(PBXFileReference v) { - productReference = v; - } - - @Override - public String isa() { - return "PBXTarget"; - } - - @Override - public int stableHash() { - return name.hashCode(); - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - s.addField("name", name); - if (productType != null) { - s.addField("productType", productType.toString()); - } - if (productName != null) { - s.addField("productName", productName); - } - if (productReference != null) { - s.addField("productReference", productReference); - } - s.addField("dependencies", dependencies); - s.addField("buildPhases", buildPhases); - if (buildConfigurationList != null) { - s.addField("buildConfigurationList", buildConfigurationList); - } - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXTargetDependency.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXTargetDependency.java deleted file mode 100644 index 164e196248..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXTargetDependency.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.base.Preconditions; - -/** - * Element of the {@link PBXTarget#dependencies}. Represents a dependency of one target upon another - * target. - */ -public class PBXTargetDependency extends PBXProjectItem { - private final PBXContainerItemProxy targetProxy; - - public PBXTargetDependency(PBXContainerItemProxy targetProxy) { - this.targetProxy = Preconditions.checkNotNull(targetProxy); - } - - @Override - public String isa() { - return "PBXTargetDependency"; - } - - public PBXContainerItemProxy getTargetProxy() { - return targetProxy; - } - - @Override - public int stableHash() { - return targetProxy.stableHash(); - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - s.addField("targetProxy", getTargetProxy()); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXVariantGroup.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXVariantGroup.java deleted file mode 100644 index b1e351aeb9..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/PBXVariantGroup.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2014-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.google.common.base.Preconditions; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; - -import java.util.Objects; - -import javax.annotation.Nullable; - -public class PBXVariantGroup extends PBXGroup { - - private final LoadingCache - variantFileReferencesByNameAndSourceTreePath; - - public PBXVariantGroup(String name, @Nullable String path, SourceTree sourceTree) { - super(name, path, sourceTree); - - variantFileReferencesByNameAndSourceTreePath = CacheBuilder.newBuilder().build( - new CacheLoader() { - @Override - public PBXFileReference load(VirtualNameAndSourceTreePath key) throws Exception { - PBXFileReference ref = new PBXFileReference( - key.getVirtualName(), - key.getSourceTreePath().getPath().toString(), - key.getSourceTreePath().getSourceTree()); - getChildren().add(ref); - return ref; - } - }); - } - - public PBXFileReference getOrCreateVariantFileReferenceByNameAndSourceTreePath( - String virtualName, - SourceTreePath sourceTreePath) { - VirtualNameAndSourceTreePath key = - new VirtualNameAndSourceTreePath(virtualName, sourceTreePath); - return variantFileReferencesByNameAndSourceTreePath.getUnchecked(key); - } - - @Override - public String isa() { - return "PBXVariantGroup"; - } - - private static class VirtualNameAndSourceTreePath { - private final String virtualName; - private final SourceTreePath sourceTreePath; - - public VirtualNameAndSourceTreePath(String virtualName, SourceTreePath sourceTreePath) { - this.virtualName = Preconditions.checkNotNull(virtualName); - this.sourceTreePath = Preconditions.checkNotNull(sourceTreePath); - } - - public String getVirtualName() { - return virtualName; - } - - public SourceTreePath getSourceTreePath() { - return sourceTreePath; - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof VirtualNameAndSourceTreePath)) { - return false; - } - - VirtualNameAndSourceTreePath that = (VirtualNameAndSourceTreePath) other; - return Objects.equals(this.virtualName, that.virtualName) && - Objects.equals(this.sourceTreePath, that.sourceTreePath); - } - - @Override - public int hashCode() { - return Objects.hash(virtualName, sourceTreePath); - } - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/SourceTreePath.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/SourceTreePath.java deleted file mode 100644 index dc49f76bb8..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/SourceTreePath.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.google.common.base.Preconditions; - -import java.nio.file.Path; -import java.util.Objects; - -/** - * Utility class representing a tuple of (SourceTree, Path) used for uniquely describing a file - * reference in a group. - */ -public class SourceTreePath { - private final PBXReference.SourceTree sourceTree; - private final Path path; - - public SourceTreePath(PBXReference.SourceTree sourceTree, Path path) { - this.sourceTree = Preconditions.checkNotNull(sourceTree); - Preconditions.checkState( - path != null && path.toString().length() > 0, - "A path to a file cannot be null or empty"); - path = path.normalize(); - Preconditions.checkState(path.toString().length() > 0, "A path to a file cannot be empty"); - this.path = path; - } - - public PBXReference.SourceTree getSourceTree() { - return sourceTree; - } - - public Path getPath() { - return path; - } - - @Override - public int hashCode() { - return Objects.hash(sourceTree, path); - } - - @Override - public boolean equals(Object other) { - if (other == null || !(other instanceof SourceTreePath)) { - return false; - } - - SourceTreePath that = (SourceTreePath) other; - return Objects.equals(this.sourceTree, that.sourceTree) && - Objects.equals(this.path, that.path); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/XCBuildConfiguration.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/XCBuildConfiguration.java deleted file mode 100644 index f55ccfc933..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/XCBuildConfiguration.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import javax.annotation.Nullable; - -import com.facebook.buck.apple.xcode.XcodeprojSerializer; - -/** - * Build configuration containing a file reference ton an xcconfig file and additional inline - * settings. - */ -public class XCBuildConfiguration extends PBXBuildStyle { - @Nullable private PBXFileReference baseConfigurationReference; - - public XCBuildConfiguration(String name) { - super(name); - } - - @Nullable - public PBXFileReference getBaseConfigurationReference() { - return baseConfigurationReference; - } - public void setBaseConfigurationReference(PBXFileReference v) { - baseConfigurationReference = v; - } - - @Override - public String isa() { - return "XCBuildConfiguration"; - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - if (baseConfigurationReference != null) { - s.addField("baseConfigurationReference", baseConfigurationReference); - } - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/XCConfigurationList.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/XCConfigurationList.java deleted file mode 100644 index 048ffa7aeb..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/XCConfigurationList.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.base.Optional; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.Lists; - -import java.util.Comparator; -import java.util.Collections; -import java.util.List; - -/** - * List of build configurations. - */ -public class XCConfigurationList extends PBXProjectItem { - private List buildConfigurations; - private Optional defaultConfigurationName; - private boolean defaultConfigurationIsVisible; - - private final LoadingCache buildConfigurationsByName; - - public XCConfigurationList() { - buildConfigurations = Lists.newArrayList(); - defaultConfigurationName = Optional.absent(); - defaultConfigurationIsVisible = false; - - buildConfigurationsByName = CacheBuilder.newBuilder().build( - new CacheLoader() { - @Override - public XCBuildConfiguration load(String key) throws Exception { - XCBuildConfiguration configuration = new XCBuildConfiguration(key); - buildConfigurations.add(configuration); - return configuration; - } - }); - } - - public LoadingCache getBuildConfigurationsByName() { - return buildConfigurationsByName; - } - - @Override - public String isa() { - return "XCConfigurationList"; - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - Collections.sort(buildConfigurations, new Comparator() { - @Override - public int compare(XCBuildConfiguration o1, XCBuildConfiguration o2) { - return o1.getName().compareTo(o2.getName()); - } - }); - s.addField("buildConfigurations", buildConfigurations); - - if (defaultConfigurationName.isPresent()) { - s.addField("defaultConfigurationName", defaultConfigurationName.get()); - } - s.addField("defaultConfigurationIsVisible", defaultConfigurationIsVisible); - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/XCVersionGroup.java b/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/XCVersionGroup.java deleted file mode 100644 index acd8458a97..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/apple/xcode/xcodeproj/XCVersionGroup.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2013-present Facebook, Inc. - * - * 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 com.facebook.buck.apple.xcode.xcodeproj; - -import com.facebook.buck.apple.xcode.XcodeprojSerializer; -import com.google.common.base.Optional; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; -import com.google.common.io.Files; - -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class XCVersionGroup extends PBXReference { - private static final ImmutableMap FILE_EXTENSION_TO_UTI = ImmutableMap.of( - "xcdatamodeld", "wrapper.xcdatamodel"); - - private Optional currentVersion; - - private final List children; - - private final LoadingCache fileReferencesBySourceTreePath; - - public XCVersionGroup(String name, String path, SourceTree sourceTree) { - super(name, path, sourceTree); - children = Lists.newArrayList(); - - fileReferencesBySourceTreePath = CacheBuilder.newBuilder().build( - new CacheLoader() { - @Override - public PBXFileReference load(SourceTreePath key) throws Exception { - PBXFileReference ref = new PBXFileReference( - key.getPath().getFileName().toString(), - key.getPath().toString(), - key.getSourceTree()); - children.add(ref); - return ref; - } - }); - - currentVersion = Optional.absent(); - } - - /** - * The file type of the version group, which is the type of each file. If the current version is - * set, then this method returns the type of the item that is the current version. Otherwise, it - * attempts to autodetect the type based on the name, or {@link Optional#absent()} if it could - * not be autodetected. - */ - public Optional getVersionGroupType() { - if (currentVersion.isPresent()) { - return currentVersion.get().getExplicitFileType(); - } - return Optional.fromNullable(FILE_EXTENSION_TO_UTI.get(Files.getFileExtension(getName()))); - } - - public Optional getCurrentVersion() { return currentVersion; } - - public void setCurrentVersion(Optional v) { currentVersion = v; } - - public List getChildren() { - return children; - } - - public PBXFileReference getOrCreateFileReferenceBySourceTreePath(SourceTreePath sourceTreePath) { - return fileReferencesBySourceTreePath.getUnchecked(sourceTreePath); - } - - @Override - public String isa() { - return "XCVersionGroup"; - } - - @Override - public void serializeInto(XcodeprojSerializer s) { - super.serializeInto(s); - - Collections.sort(children, new Comparator() { - @Override - public int compare(PBXReference o1, PBXReference o2) { - return o1.getName().compareTo(o2.getName()); - } - }); - s.addField("children", children); - - - if (currentVersion.isPresent()) { - s.addField("currentVersion", currentVersion.get()); - } - - Optional versionGroupType = getVersionGroupType(); - if (versionGroupType.isPresent()) { - s.addField("versionGroupType", versionGroupType.get()); - } - } -} diff --git a/third_party/java/buck-ios-support/java/com/facebook/buck/log/Logger.java b/third_party/java/buck-ios-support/java/com/facebook/buck/log/Logger.java deleted file mode 100644 index 2c1fdb3e3c..0000000000 --- a/third_party/java/buck-ios-support/java/com/facebook/buck/log/Logger.java +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Copyright 2014-present Facebook, Inc. - * - * 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. - */ - -/* - * Copyright 2010 Proofpoint, Inc. - * - * 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 com.facebook.buck.log; - -import java.util.IllegalFormatException; - -import static java.lang.String.format; -import static java.util.Arrays.asList; -import static java.util.logging.Level.FINE; -import static java.util.logging.Level.FINER; -import static java.util.logging.Level.INFO; -import static java.util.logging.Level.SEVERE; -import static java.util.logging.Level.WARNING; - -// This is open source software that we'd like to modify as little as -// possible, and it doesn't match our coding style. -@SuppressWarnings({"PMD", "checkstyle:leftcurly", "checkstyle:rightcurly", "checkstyle:linelength"}) -public class Logger -{ - private final java.util.logging.Logger logger; - - Logger(java.util.logging.Logger logger) - { - this.logger = logger; - } - - /** - * Gets a logger named after a class' fully qualified name. - * - * @param clazz the class - * @return the named logger - */ - public static Logger get(Class clazz) - { - return get(clazz.getName()); - } - - /** - * Gets a named logger - * - * @param name the name of the logger - * @return the named logger - */ - public static Logger get(String name) - { - java.util.logging.Logger logger = java.util.logging.Logger.getLogger(name); - return new Logger(logger); - } - - /** - * Logs a message at VERBOSE level. - * - * @param exception an exception associated with the verbose message being logged - * @param message a literal message to log - */ - public void verbose(Throwable exception, String message) - { - logger.log(FINER, message, exception); - } - - /** - * Logs a message at VERBOSE level. - * - * @param message a literal message to log - */ - public void verbose(String message) - { - logger.finer(message); - } - - /** - * Logs a message at VERBOSE level. - *
- * Usage example: - *
-     *    logger.verbose("value is %s (%d ms)", value, time);
-     * 
- * If the format string is invalid or the arguments are insufficient, an error will be logged and execution - * will continue. - * - * @param format a format string compatible with String.format() - * @param args arguments for the format string - */ - public void verbose(String format, Object... args) - { - if (logger.isLoggable(FINER)) { - String message; - try { - message = format(format, args); - } - catch (IllegalFormatException e) { - logger.log(SEVERE, illegalFormatMessageFor("VERBOSE", format, args), e); - message = rawMessageFor(format, args); - } - logger.finer(message); - } - } - - /** - * Logs a message at VERBOSE level. - *
- * Usage example: - *
-     *    logger.verbose(e, "value is %s (%d ms)", value, time);
-     * 
- * If the format string is invalid or the arguments are insufficient, an error will be logged and execution - * will continue. - * - * @param exception an exception associated with the verbose message being logged - * @param format a format string compatible with String.format() - * @param args arguments for the format string - */ - public void verbose(Throwable exception, String format, Object... args) - { - if (logger.isLoggable(FINER)) { - String message; - try { - message = format(format, args); - } - catch (IllegalFormatException e) { - logger.log(SEVERE, illegalFormatMessageFor("VERBOSE", format, args), e); - message = rawMessageFor(format, args); - } - logger.log(FINER, message, exception); - } - } - - /** - * Logs a message at DEBUG level. - * - * @param exception an exception associated with the debug message being logged - * @param message a literal message to log - */ - public void debug(Throwable exception, String message) - { - logger.log(FINE, message, exception); - } - - /** - * Logs a message at DEBUG level. - * - * @param message a literal message to log - */ - public void debug(String message) - { - logger.fine(message); - } - - /** - * Logs a message at DEBUG level. - *
- * Usage example: - *
-     *    logger.debug("value is %s (%d ms)", value, time);
-     * 
- * If the format string is invalid or the arguments are insufficient, an error will be logged and execution - * will continue. - * - * @param format a format string compatible with String.format() - * @param args arguments for the format string - */ - public void debug(String format, Object... args) - { - if (logger.isLoggable(FINE)) { - String message; - try { - message = format(format, args); - } - catch (IllegalFormatException e) { - logger.log(SEVERE, illegalFormatMessageFor("DEBUG", format, args), e); - message = rawMessageFor(format, args); - } - logger.fine(message); - } - } - - /** - * Logs a message at DEBUG level. - *
- * Usage example: - *
-     *    logger.debug(e, "value is %s (%d ms)", value, time);
-     * 
- * If the format string is invalid or the arguments are insufficient, an error will be logged and execution - * will continue. - * - * @param exception an exception associated with the debug message being logged - * @param format a format string compatible with String.format() - * @param args arguments for the format string - */ - public void debug(Throwable exception, String format, Object... args) - { - if (logger.isLoggable(FINE)) { - String message; - try { - message = format(format, args); - } - catch (IllegalFormatException e) { - logger.log(SEVERE, illegalFormatMessageFor("DEBUG", format, args), e); - message = rawMessageFor(format, args); - } - logger.log(FINE, message, exception); - } - } - - /** - * Logs a message at INFO level. - * - * @param message a literal message to log - */ - public void info(String message) - { - logger.info(message); - } - - /** - * Logs a message at INFO level. - *
- * Usage example: - *
-     *    logger.info("value is %s (%d ms)", value, time);
-     * 
- * If the format string is invalid or the arguments are insufficient, an error will be logged and execution - * will continue. - * - * @param format a format string compatible with String.format() - * @param args arguments for the format string - */ - public void info(String format, Object... args) - { - if (logger.isLoggable(INFO)) { - String message; - try { - message = format(format, args); - } - catch (IllegalFormatException e) { - logger.log(SEVERE, illegalFormatMessageFor("INFO", format, args), e); - message = rawMessageFor(format, args); - } - logger.info(message); - } - } - - /** - * Logs a message at WARN level. - * - * @param exception an exception associated with the warning being logged - * @param message a literal message to log - */ - public void warn(Throwable exception, String message) - { - logger.log(WARNING, message, exception); - } - - /** - * Logs a message at WARN level. - * - * @param message a literal message to log - */ - public void warn(String message) - { - logger.warning(message); - } - - /** - * Logs a message at WARN level. - *
- * Usage example: - *
-     *    logger.warn(e, "something bad happened when connecting to %s:%d", host, port);
-     * 
- * If the format string is invalid or the arguments are insufficient, an error will be logged and execution - * will continue. - * - * @param exception an exception associated with the warning being logged - * @param format a format string compatible with String.format() - * @param args arguments for the format string - */ - public void warn(Throwable exception, String format, Object... args) - { - if (logger.isLoggable(WARNING)) { - String message; - try { - message = format(format, args); - } - catch (IllegalFormatException e) { - logger.log(SEVERE, illegalFormatMessageFor("WARN", format, args), e); - message = rawMessageFor(format, args); - } - logger.log(WARNING, message, exception); - } - } - - /** - * Logs a message at WARN level. - *
- * Usage example: - *
-     *    logger.warn("something bad happened when connecting to %s:%d", host, port);
-     * 
- * If the format string is invalid or the arguments are insufficient, an error will be logged and execution - * will continue. - * - * @param format a format string compatible with String.format() - * @param args arguments for the format string - */ - public void warn(String format, Object... args) - { - warn(null, format, args); - } - - /** - * Logs a message at ERROR level. - * - * @param exception an exception associated with the error being logged - * @param message a literal message to log - */ - public void error(Throwable exception, String message) - { - logger.log(SEVERE, message, exception); - } - - /** - * Logs a message at ERROR level. - * - * @param message a literal message to log - */ - public void error(String message) - { - logger.severe(message); - } - - /** - * Logs a message at ERROR level. - *
- * Usage example: - *
-     *    logger.error(e, "something really bad happened when connecting to %s:%d", host, port);
-     * 
- * If the format string is invalid or the arguments are insufficient, an error will be logged and execution - * will continue. - * - * @param exception an exception associated with the error being logged - * @param format a format string compatible with String.format() - * @param args arguments for the format string - */ - public void error(Throwable exception, String format, Object... args) - { - if (logger.isLoggable(SEVERE)) { - String message; - try { - message = format(format, args); - } - catch (IllegalFormatException e) { - logger.log(SEVERE, illegalFormatMessageFor("ERROR", format, args), e); - message = rawMessageFor(format, args); - } - logger.log(SEVERE, message, exception); - } - } - - /** - * Logs a message at ERROR level. The value of {@code exception.getMessage()} will be used as the log message. - *
- * Usage example: - *
-     *    logger.error(e);
-     * 
- * - * @param exception an exception associated with the error being logged - */ - public void error(Throwable exception) - { - if (logger.isLoggable(SEVERE)) { - logger.log(SEVERE, exception.getMessage(), exception); - } - } - - /** - * Logs a message at ERROR level. - *
- * Usage example: - *
-     *    logger.error("something really bad happened when connecting to %s:%d", host, port);
-     * 
- * If the format string is invalid or the arguments are insufficient, an error will be logged and execution - * will continue. - * - * @param format a format string compatible with String.format() - * @param args arguments for the format string - */ - public void error(String format, Object... args) - { - error(null, format, args); - } - - public boolean isVerboseEnabled() - { - return logger.isLoggable(FINER); - } - - public boolean isDebugEnabled() - { - return logger.isLoggable(FINE); - } - - public boolean isInfoEnabled() - { - return logger.isLoggable(INFO); - } - - private String illegalFormatMessageFor(String level, String message, Object... args) - { - return format("Invalid format string while trying to log: %s '%s' %s", level, message, asList(args)); - } - - private String rawMessageFor(String format, Object... args) - { - return format("'%s' %s", format, asList(args)); - } -} -- cgit v1.2.3