├── .github ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── PULL_REQUEST_TEMPLATE.md └── dco.yml ├── .gitignore ├── LICENSE ├── README.md ├── build-scan └── buildScanUserData.gradle ├── build.gradle.kts ├── c └── application │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ └── main │ └── c │ └── main.c ├── cpp ├── application │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ └── main │ │ ├── cpp │ │ ├── add.cpp │ │ ├── copy_ctor_assign.cpp │ │ ├── destructor.cpp │ │ ├── get.cpp │ │ ├── join.cpp │ │ ├── main.cpp │ │ ├── message.cpp │ │ ├── remove.cpp │ │ ├── size.cpp │ │ └── split.cpp │ │ └── headers │ │ ├── linked_list.h │ │ ├── message.h │ │ ├── node.h │ │ └── string_utils.h ├── autotools-library │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ ├── add.cpp │ │ │ ├── copy_ctor_assign.cpp │ │ │ ├── destructor.cpp │ │ │ ├── get.cpp │ │ │ ├── join.cpp │ │ │ ├── main.cpp │ │ │ ├── message.cpp │ │ │ ├── remove.cpp │ │ │ ├── size.cpp │ │ │ └── split.cpp │ │ │ └── headers │ │ │ ├── linked_list.h │ │ │ ├── message.h │ │ │ ├── node.h │ │ │ └── string_utils.h │ ├── build-wrapper-plugin │ │ ├── build.gradle.kts │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── settings.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── gradle │ │ │ └── samples │ │ │ ├── plugins │ │ │ ├── WrappedNativeApplicationPlugin.java │ │ │ ├── WrappedNativeBasePlugin.java │ │ │ ├── WrappedNativeLibraryPlugin.java │ │ │ ├── autotools │ │ │ │ ├── AutotoolsExtension.java │ │ │ │ └── AutotoolsLibraryPlugin.java │ │ │ └── cmake │ │ │ │ ├── CMakeApplicationPlugin.java │ │ │ │ ├── CMakeExtension.java │ │ │ │ └── CMakeLibraryPlugin.java │ │ │ └── tasks │ │ │ ├── CMake.java │ │ │ ├── ConfigureTask.java │ │ │ ├── DownloadZipAndUnpack.java │ │ │ └── Make.java │ ├── build.gradle │ ├── curl │ │ └── build.gradle │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── binary-dependencies │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ └── main │ │ ├── cpp │ │ ├── join.cpp │ │ ├── main.cpp │ │ ├── message.cpp │ │ └── split.cpp │ │ └── headers │ │ ├── message.h │ │ └── string_utils.h ├── cmake-library │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ ├── main.cpp │ │ │ └── message.cpp │ │ │ └── headers │ │ │ └── message.h │ ├── build-wrapper-plugin │ │ ├── build.gradle.kts │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── settings.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── gradle │ │ │ └── samples │ │ │ ├── plugins │ │ │ ├── WrappedNativeApplicationPlugin.java │ │ │ ├── WrappedNativeBasePlugin.java │ │ │ ├── WrappedNativeLibraryPlugin.java │ │ │ ├── autotools │ │ │ │ ├── AutotoolsExtension.java │ │ │ │ └── AutotoolsLibraryPlugin.java │ │ │ └── cmake │ │ │ │ ├── CMakeApplicationPlugin.java │ │ │ │ ├── CMakeExtension.java │ │ │ │ └── CMakeLibraryPlugin.java │ │ │ └── tasks │ │ │ ├── CMake.java │ │ │ ├── ConfigureTask.java │ │ │ ├── DownloadZipAndUnpack.java │ │ │ └── Make.java │ ├── build.gradle │ ├── custom-publication-plugin │ │ ├── build.gradle.kts │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── settings.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── gradle │ │ │ └── samples │ │ │ └── plugins │ │ │ └── CustomPublicationPlugin.java │ ├── gradlew │ ├── gradlew.bat │ ├── list │ │ ├── CMakeLists.txt │ │ ├── build.gradle │ │ └── src │ │ │ └── list │ │ │ ├── CMakeLists.txt │ │ │ ├── add.cpp │ │ │ ├── copy_ctor_assign.cpp │ │ │ ├── destructor.cpp │ │ │ ├── get.cpp │ │ │ ├── include │ │ │ ├── linked_list.h │ │ │ └── node.h │ │ │ ├── remove.cpp │ │ │ └── size.cpp │ ├── settings.gradle │ └── utilities │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ ├── cpp │ │ ├── join.cpp │ │ └── split.cpp │ │ └── public │ │ └── string_utils.h ├── cmake-source-dependencies │ └── .gitignore ├── composite-build │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── list-library │ │ ├── build.gradle │ │ ├── settings.gradle │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ ├── add.cpp │ │ │ ├── copy_ctor_assign.cpp │ │ │ ├── destructor.cpp │ │ │ ├── get.cpp │ │ │ ├── remove.cpp │ │ │ └── size.cpp │ │ │ ├── headers │ │ │ └── node.h │ │ │ └── public │ │ │ └── linked_list.h │ ├── settings.gradle │ ├── src │ │ └── main │ │ │ ├── cpp │ │ │ ├── main.cpp │ │ │ └── message.cpp │ │ │ └── headers │ │ │ └── message.h │ └── utilities-library │ │ ├── build.gradle │ │ ├── settings.gradle │ │ └── src │ │ └── main │ │ ├── cpp │ │ ├── join.cpp │ │ └── split.cpp │ │ └── public │ │ └── string_utils.h ├── dependency-on-upstream-branch │ ├── .gitignore │ └── app │ │ ├── build.gradle │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── settings.gradle │ │ └── src │ │ └── main │ │ ├── cpp │ │ ├── main.cpp │ │ └── message.cpp │ │ └── headers │ │ └── message.h ├── header-only-library │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── header-gradle-plugin │ │ ├── build.gradle.kts │ │ ├── settings.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── gradle │ │ │ └── samples │ │ │ ├── plugins │ │ │ └── CppHeaderLibraryPlugin.java │ │ │ └── tasks │ │ │ └── GenerateDummyCppSource.java │ ├── settings.gradle │ └── src │ │ ├── main │ │ └── public │ │ │ └── linked_list.h │ │ └── test │ │ └── cpp │ │ ├── linked_list_test.cpp │ │ └── main.cpp ├── injected-plugins │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── plugins │ │ ├── build.gradle │ │ ├── settings.gradle │ │ └── src │ │ │ └── main │ │ │ └── groovy │ │ │ └── org │ │ │ └── gradle │ │ │ └── cpp │ │ │ └── samples │ │ │ ├── CommonPlugin.groovy │ │ │ ├── ListBuildPlugin.groovy │ │ │ └── UtilitiesBuildPlugin.groovy │ ├── repos │ │ └── .gitignore │ ├── settings.gradle │ └── src │ │ └── main │ │ ├── cpp │ │ ├── main.cpp │ │ └── message.cpp │ │ └── headers │ │ └── message.h ├── library-with-tests │ ├── build-wrapper-plugin │ │ ├── build.gradle.kts │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── settings.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── gradle │ │ │ └── samples │ │ │ ├── plugins │ │ │ ├── WrappedNativeApplicationPlugin.java │ │ │ ├── WrappedNativeBasePlugin.java │ │ │ ├── WrappedNativeLibraryPlugin.java │ │ │ ├── autotools │ │ │ │ ├── AutotoolsExtension.java │ │ │ │ └── AutotoolsLibraryPlugin.java │ │ │ └── cmake │ │ │ │ ├── CMakeApplicationPlugin.java │ │ │ │ ├── CMakeExtension.java │ │ │ │ └── CMakeLibraryPlugin.java │ │ │ └── tasks │ │ │ ├── CMake.java │ │ │ ├── ConfigureTask.java │ │ │ ├── DownloadZipAndUnpack.java │ │ │ └── Make.java │ ├── build.gradle │ ├── googletest │ │ └── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ ├── main │ │ ├── cpp │ │ │ ├── add.cpp │ │ │ ├── copy_ctor_assign.cpp │ │ │ ├── destructor.cpp │ │ │ ├── get.cpp │ │ │ ├── remove.cpp │ │ │ └── size.cpp │ │ ├── headers │ │ │ └── node.h │ │ └── public │ │ │ └── linked_list.h │ │ └── test │ │ └── cpp │ │ ├── linked_list_test.cpp │ │ └── main.cpp ├── multiple-target-machines │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ └── main │ │ ├── cpp │ │ ├── add.cpp │ │ ├── copy_ctor_assign.cpp │ │ ├── destructor.cpp │ │ ├── get.cpp │ │ ├── join.cpp │ │ ├── main.cpp │ │ ├── message.cpp │ │ ├── remove.cpp │ │ ├── size.cpp │ │ └── split.cpp │ │ └── headers │ │ ├── linked_list.h │ │ ├── message.h │ │ ├── node.h │ │ └── string_utils.h ├── operating-system-specific-dependencies │ ├── ansiConsole │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ └── ansi_console.cpp │ │ │ └── public │ │ │ └── ansi_console.h │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ ├── add.cpp │ │ │ ├── copy_ctor_assign.cpp │ │ │ ├── destructor.cpp │ │ │ ├── get.cpp │ │ │ ├── join.cpp │ │ │ ├── logger.cpp │ │ │ ├── main.cpp │ │ │ ├── remove.cpp │ │ │ ├── size.cpp │ │ │ └── split.cpp │ │ │ └── headers │ │ │ ├── linked_list.h │ │ │ ├── logger.h │ │ │ ├── node.h │ │ │ └── string_utils.h │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── winConsole │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ ├── cpp │ │ └── win_console.cpp │ │ └── public │ │ └── win_console.h ├── prebuilt-binaries │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ └── main │ │ ├── cpp │ │ ├── join.cpp │ │ ├── main.cpp │ │ ├── message.cpp │ │ └── split.cpp │ │ └── headers │ │ ├── message.h │ │ └── string_utils.h ├── prebuilt-repo │ └── org │ │ └── gradle │ │ └── cpp-samples │ │ ├── googletest │ │ └── 1.9.0-gr4-SNAPSHOT │ │ │ ├── googletest-1.9.0-gr4-SNAPSHOT-cpp-api-headers.zip │ │ │ ├── googletest-1.9.0-gr4-SNAPSHOT.module │ │ │ └── googletest-1.9.0-gr4-SNAPSHOT.pom │ │ ├── googletest_debug_linux │ │ └── 1.9.0-gr4-SNAPSHOT │ │ │ ├── googletest_debug_linux-1.9.0-gr4-SNAPSHOT.module │ │ │ ├── googletest_debug_linux-1.9.0-gr4-SNAPSHOT.pom │ │ │ └── googletest_debug_linux-1.9.0-gr4-SNAPSHOT.so │ │ ├── googletest_debug_macos │ │ └── 1.9.0-gr4-SNAPSHOT │ │ │ ├── googletest_debug_macos-1.9.0-gr4-SNAPSHOT.dylib │ │ │ ├── googletest_debug_macos-1.9.0-gr4-SNAPSHOT.module │ │ │ └── googletest_debug_macos-1.9.0-gr4-SNAPSHOT.pom │ │ ├── googletest_debug_windows │ │ └── 1.9.0-gr4-SNAPSHOT │ │ │ ├── googletest_debug_windows-1.9.0-gr4-SNAPSHOT.dll │ │ │ ├── googletest_debug_windows-1.9.0-gr4-SNAPSHOT.lib │ │ │ ├── googletest_debug_windows-1.9.0-gr4-SNAPSHOT.module │ │ │ └── googletest_debug_windows-1.9.0-gr4-SNAPSHOT.pom │ │ ├── googletest_release_linux │ │ └── 1.9.0-gr4-SNAPSHOT │ │ │ ├── googletest_release_linux-1.9.0-gr4-SNAPSHOT.module │ │ │ ├── googletest_release_linux-1.9.0-gr4-SNAPSHOT.pom │ │ │ └── googletest_release_linux-1.9.0-gr4-SNAPSHOT.so │ │ ├── googletest_release_macos │ │ └── 1.9.0-gr4-SNAPSHOT │ │ │ ├── googletest_release_macos-1.9.0-gr4-SNAPSHOT.dylib │ │ │ ├── googletest_release_macos-1.9.0-gr4-SNAPSHOT.module │ │ │ └── googletest_release_macos-1.9.0-gr4-SNAPSHOT.pom │ │ └── googletest_release_windows │ │ └── 1.9.0-gr4-SNAPSHOT │ │ ├── googletest_release_windows-1.9.0-gr4-SNAPSHOT.dll │ │ ├── googletest_release_windows-1.9.0-gr4-SNAPSHOT.lib │ │ ├── googletest_release_windows-1.9.0-gr4-SNAPSHOT.module │ │ └── googletest_release_windows-1.9.0-gr4-SNAPSHOT.pom ├── precompiled-headers │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ └── main │ │ ├── cpp │ │ ├── add.cpp │ │ ├── copy_ctor_assign.cpp │ │ ├── destructor.cpp │ │ ├── get.cpp │ │ ├── join.cpp │ │ ├── main.cpp │ │ ├── message.cpp │ │ ├── remove.cpp │ │ ├── size.cpp │ │ └── split.cpp │ │ └── headers │ │ ├── linked_list.h │ │ ├── message.h │ │ ├── node.h │ │ ├── pch.h │ │ └── string_utils.h ├── provisionable-tool-chains │ ├── build.gradle │ ├── buildSrc │ │ └── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ └── main │ │ ├── cpp │ │ ├── add.cpp │ │ ├── copy_ctor_assign.cpp │ │ ├── destructor.cpp │ │ ├── get.cpp │ │ ├── join.cpp │ │ ├── main.cpp │ │ ├── message.cpp │ │ ├── remove.cpp │ │ ├── size.cpp │ │ └── split.cpp │ │ └── headers │ │ ├── linked_list.h │ │ ├── message.h │ │ ├── node.h │ │ └── string_utils.h ├── publish-macros │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ ├── check_published_macros.cpp │ │ │ ├── main.cpp │ │ │ └── message.cpp │ │ │ └── headers │ │ │ └── message.h │ ├── build.gradle │ ├── cpp-public-macros-plugin │ │ ├── build.gradle.kts │ │ ├── settings.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── gradle │ │ │ └── samples │ │ │ ├── plugins │ │ │ └── CppPublicMacrosPlugin.java │ │ │ └── tasks │ │ │ └── GeneratePublicMacrosManifest.java │ ├── gradlew │ ├── gradlew.bat │ ├── list │ │ ├── build.gradle │ │ └── src │ │ │ ├── main │ │ │ ├── cpp │ │ │ │ ├── add.cpp │ │ │ │ ├── copy_ctor_assign.cpp │ │ │ │ ├── destructor.cpp │ │ │ │ ├── get.cpp │ │ │ │ ├── remove.cpp │ │ │ │ └── size.cpp │ │ │ ├── headers │ │ │ │ └── node.h │ │ │ └── public │ │ │ │ └── linked_list.h │ │ │ └── test │ │ │ └── cpp │ │ │ ├── linked_list_test.cpp │ │ │ └── main.cpp │ ├── settings.gradle │ └── utilities │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ ├── cpp │ │ ├── join.cpp │ │ └── split.cpp │ │ └── public │ │ └── string_utils.h ├── simple-library │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ ├── main │ │ ├── cpp │ │ │ ├── add.cpp │ │ │ ├── copy_ctor_assign.cpp │ │ │ ├── destructor.cpp │ │ │ ├── get.cpp │ │ │ ├── remove.cpp │ │ │ └── size.cpp │ │ ├── headers │ │ │ └── node.h │ │ └── public │ │ │ └── linked_list.h │ │ └── test │ │ └── cpp │ │ ├── linked_list_test.cpp │ │ └── main.cpp ├── source-dependencies │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ └── main │ │ ├── cpp │ │ ├── main.cpp │ │ └── message.cpp │ │ └── headers │ │ └── message.h ├── source-generation │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── static-library │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ ├── main.cpp │ │ │ └── message.cpp │ │ │ └── headers │ │ │ └── message.h │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── list │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ ├── add.cpp │ │ │ ├── copy_ctor_assign.cpp │ │ │ ├── destructor.cpp │ │ │ ├── get.cpp │ │ │ ├── remove.cpp │ │ │ └── size.cpp │ │ │ ├── headers │ │ │ └── node.h │ │ │ └── public │ │ │ └── linked_list.h │ ├── settings.gradle │ └── utilities │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ ├── cpp │ │ ├── join.cpp │ │ └── split.cpp │ │ └── public │ │ └── string_utils.h ├── swift-package-manager-publish │ ├── .gitignore │ └── app │ │ ├── Package.swift │ │ └── Sources │ │ └── App │ │ ├── include │ │ └── message.h │ │ ├── main.cpp │ │ └── message.cpp ├── swift-package-manager │ ├── Package.swift │ ├── Sources │ │ ├── App │ │ │ ├── include │ │ │ │ └── message.h │ │ │ ├── main.cpp │ │ │ └── message.cpp │ │ ├── List │ │ │ ├── add.cpp │ │ │ ├── copy_ctor_assign.cpp │ │ │ ├── destructor.cpp │ │ │ ├── get.cpp │ │ │ ├── include │ │ │ │ ├── linked_list.h │ │ │ │ └── node.h │ │ │ ├── remove.cpp │ │ │ └── size.cpp │ │ └── Utilities │ │ │ ├── include │ │ │ └── string_utils.h │ │ │ ├── join.cpp │ │ │ └── split.cpp │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── transitive-dependencies │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ ├── main.cpp │ │ │ └── message.cpp │ │ │ └── headers │ │ │ └── message.h │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── list │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ ├── add.cpp │ │ │ ├── copy_ctor_assign.cpp │ │ │ ├── destructor.cpp │ │ │ ├── get.cpp │ │ │ ├── remove.cpp │ │ │ └── size.cpp │ │ │ ├── headers │ │ │ └── node.h │ │ │ └── public │ │ │ └── linked_list.h │ ├── settings.gradle │ └── utilities │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ ├── cpp │ │ ├── join.cpp │ │ └── split.cpp │ │ └── public │ │ └── string_utils.h └── windows-resources │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ └── main │ ├── cpp │ ├── add.cpp │ ├── copy_ctor_assign.cpp │ ├── destructor.cpp │ ├── get.cpp │ ├── join.cpp │ ├── main.cpp │ ├── message.cpp │ ├── remove.cpp │ ├── size.cpp │ └── split.cpp │ ├── headers │ ├── linked_list.h │ ├── message.h │ ├── node.h │ ├── resources.h │ └── string_utils.h │ └── rc │ └── resources.rc ├── gradle ├── buildScanInit.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── samples-dev ├── .gitignore ├── README.md ├── build.gradle ├── gradlew ├── plugins │ ├── build.gradle.kts │ ├── settings.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── org │ │ └── gradle │ │ └── samples │ │ └── plugins │ │ ├── SampleGeneratorTask.java │ │ ├── generators │ │ ├── Changes.java │ │ ├── CleanSamplesTask.java │ │ ├── CppLibraryTemplate.java │ │ ├── ExternalRepo.java │ │ ├── GeneratorPlugin.java │ │ ├── GitRepoTask.java │ │ ├── Sample.java │ │ ├── SamplesExtension.java │ │ ├── SamplesManifestTask.java │ │ ├── SourceCopyTask.java │ │ ├── SwiftLibraryTemplate.java │ │ ├── SyncExternalRepoTask.java │ │ ├── Template.java │ │ └── UpdateRepoTask.java │ │ └── wrapper │ │ └── WrapperPlugin.java ├── samples-list.txt └── src │ ├── templates │ ├── build-root │ │ ├── gradlew │ │ └── gradlew.bat │ ├── build-wrapper-plugin │ │ ├── build.gradle.kts │ │ ├── settings.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── gradle │ │ │ └── samples │ │ │ ├── plugins │ │ │ ├── WrappedNativeApplicationPlugin.java │ │ │ ├── WrappedNativeBasePlugin.java │ │ │ ├── WrappedNativeLibraryPlugin.java │ │ │ ├── autotools │ │ │ │ ├── AutotoolsExtension.java │ │ │ │ └── AutotoolsLibraryPlugin.java │ │ │ └── cmake │ │ │ │ ├── CMakeApplicationPlugin.java │ │ │ │ ├── CMakeExtension.java │ │ │ │ └── CMakeLibraryPlugin.java │ │ │ └── tasks │ │ │ ├── CMake.java │ │ │ ├── ConfigureTask.java │ │ │ ├── DownloadZipAndUnpack.java │ │ │ └── Make.java │ ├── c-app │ │ └── src │ │ │ └── main │ │ │ └── c │ │ │ └── main.c │ ├── cpp-ansi-console-lib │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ └── ansi_console.cpp │ │ │ └── public │ │ │ └── ansi_console.h │ ├── cpp-app-check-published-macros │ │ └── src │ │ │ └── main │ │ │ └── cpp │ │ │ └── check_published_macros.cpp │ ├── cpp-app-cmake-build │ │ ├── CMakeLists.txt │ │ ├── build.gradle │ │ └── settings.gradle │ ├── cpp-app-precompiled-header │ │ └── src │ │ │ └── main │ │ │ └── headers │ │ │ └── pch.h │ ├── cpp-app-uses-logger │ │ └── src │ │ │ └── main │ │ │ └── cpp │ │ │ └── main.cpp │ ├── cpp-app-with-curl │ │ └── src │ │ │ └── main │ │ │ └── cpp │ │ │ └── main.cpp │ ├── cpp-app │ │ └── src │ │ │ └── main │ │ │ └── cpp │ │ │ └── main.cpp │ ├── cpp-build-with-list-and-utilities-libraries │ │ ├── build.gradle │ │ ├── list │ │ │ └── build.gradle │ │ ├── settings.gradle │ │ └── utilities │ │ │ └── build.gradle │ ├── cpp-lib-header-only │ │ └── src │ │ │ └── main │ │ │ └── public │ │ │ └── linked_list.h │ ├── cpp-lib-with-api-dep │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ ├── join.cpp │ │ │ └── split.cpp │ │ │ └── public │ │ │ └── string_utils.h │ ├── cpp-lib-with-c-api │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ └── linked_list.cpp │ │ │ └── public │ │ │ └── linked_list.h │ ├── cpp-lib │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ ├── add.cpp │ │ │ ├── copy_ctor_assign.cpp │ │ │ ├── destructor.cpp │ │ │ ├── get.cpp │ │ │ ├── remove.cpp │ │ │ └── size.cpp │ │ │ ├── headers │ │ │ └── node.h │ │ │ └── public │ │ │ └── linked_list.h │ ├── cpp-list-lib-build-with-release │ │ ├── build.gradle │ │ └── settings.gradle │ ├── cpp-list-lib-build │ │ ├── build.gradle │ │ └── settings.gradle │ ├── cpp-list-lib-cmake-build │ │ ├── CMakeLists.txt │ │ ├── build.gradle │ │ └── settings.gradle │ ├── cpp-logger-uses-console │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ └── logger.cpp │ │ │ └── headers │ │ │ └── logger.h │ ├── cpp-message-api │ │ └── src │ │ │ └── main │ │ │ └── public │ │ │ └── message.h │ ├── cpp-message-resources │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ └── message.cpp │ │ │ ├── headers │ │ │ └── resources.h │ │ │ └── rc │ │ │ └── resources.rc │ ├── cpp-message-static │ │ └── src │ │ │ └── main │ │ │ └── cpp │ │ │ └── message.cpp │ ├── cpp-provisionable-tool-chains-build │ │ ├── build.gradle │ │ ├── buildSrc │ │ │ └── build.gradle │ │ └── settings.gradle │ ├── cpp-utilities-lib-build-with-release │ │ ├── build.gradle │ │ └── settings.gradle │ ├── cpp-utilities-lib-build │ │ ├── build.gradle │ │ └── settings.gradle │ ├── cpp-utilities-lib-cmake-build │ │ ├── CMakeLists.txt │ │ ├── build.gradle │ │ └── settings.gradle │ ├── cpp-windows-console-lib │ │ └── src │ │ │ └── main │ │ │ ├── cpp │ │ │ └── win_console.cpp │ │ │ └── public │ │ │ └── win_console.h │ ├── custom-publication-plugin │ │ ├── build.gradle.kts │ │ ├── settings.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── gradle │ │ │ └── samples │ │ │ └── plugins │ │ │ └── CustomPublicationPlugin.java │ ├── release-plugin │ │ ├── build.gradle.kts │ │ ├── settings.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── gradle │ │ │ └── samples │ │ │ └── ReleasePlugin.java │ ├── swift-app-uses-logger │ │ └── src │ │ │ └── main │ │ │ └── swift │ │ │ └── main.swift │ ├── swift-app │ │ └── src │ │ │ ├── main │ │ │ └── swift │ │ │ │ └── main.swift │ │ │ └── test │ │ │ └── swift │ │ │ └── AppTests.swift │ ├── swift-build-with-list-and-utilities-libraries │ │ ├── build.gradle │ │ ├── list │ │ │ └── build.gradle │ │ ├── settings.gradle │ │ └── utilities │ │ │ └── build.gradle │ ├── swift-lib-unusable │ │ └── src │ │ │ └── main │ │ │ └── swift │ │ │ ├── DoNotCompile.swift │ │ │ └── LinkedList.swift │ ├── swift-lib-uses-c-api │ │ └── src │ │ │ ├── main │ │ │ └── swift │ │ │ │ └── LinkedList.swift │ │ │ └── test │ │ │ └── swift │ │ │ └── LinkedListTests.swift │ ├── swift-lib-with-api-dep │ │ └── src │ │ │ ├── main │ │ │ └── swift │ │ │ │ └── Util.swift │ │ │ └── test │ │ │ └── swift │ │ │ └── UtilTests.swift │ ├── swift-lib │ │ └── src │ │ │ ├── main │ │ │ └── swift │ │ │ │ ├── LinkedList.swift │ │ │ │ └── Node.swift │ │ │ └── test │ │ │ └── swift │ │ │ └── LinkedListTests.swift │ ├── swift-linux-console-lib │ │ └── src │ │ │ └── main │ │ │ └── swift │ │ │ └── Console.swift │ ├── swift-list-lib-build-with-release │ │ ├── build.gradle │ │ └── settings.gradle │ ├── swift-list-lib-build │ │ ├── build.gradle │ │ └── settings.gradle │ ├── swift-logger-reports-swift-version │ │ └── src │ │ │ ├── main │ │ │ └── swift │ │ │ │ └── Logger.swift │ │ │ └── test │ │ │ └── swift │ │ │ └── LoggerTests.swift │ ├── swift-logger-uses-console │ │ └── src │ │ │ └── main │ │ │ └── swift │ │ │ └── Logger.swift │ ├── swift-macos-console-lib │ │ └── src │ │ │ └── main │ │ │ └── swift │ │ │ └── Console.swift │ ├── swift-provisionable-tool-chains-build │ │ ├── build.gradle │ │ ├── buildSrc │ │ │ └── build.gradle │ │ └── settings.gradle │ ├── swift-utilities-lib-build-with-release │ │ ├── build.gradle │ │ └── settings.gradle │ ├── swift-utilities-lib-build │ │ ├── build.gradle │ │ └── settings.gradle │ ├── swift3-lib-with-api-dep │ │ └── src │ │ │ ├── main │ │ │ └── swift │ │ │ │ └── Util.swift │ │ │ └── test │ │ │ └── swift │ │ │ └── UtilTests.swift │ ├── swift4-lib-with-api-dep │ │ └── src │ │ │ ├── main │ │ │ └── swift │ │ │ │ └── Util.swift │ │ │ └── test │ │ │ └── swift │ │ │ └── UtilTests.swift │ └── swift5-lib-with-api-dep │ │ └── src │ │ ├── main │ │ └── swift │ │ │ └── Util.swift │ │ └── test │ │ └── swift │ │ └── UtilTests.swift │ └── test │ └── groovy │ └── org │ └── gradle │ └── samples │ ├── DocumentationIntegrationTest.groovy │ ├── ExecuteCSamplesIntegrationTest.groovy │ ├── ExecuteCppSamplesIntegrationTest.groovy │ ├── ExecuteSamplesIntegrationTest.groovy │ ├── ExecuteSwiftSamplesIntegrationTest.groovy │ └── fixtures │ ├── Documentation.groovy │ ├── NativeSample.groovy │ ├── Samples.groovy │ └── SwiftPmRunner.groovy ├── settings.gradle.kts └── swift ├── application ├── build.gradle ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ └── swift │ │ ├── LinkedList.swift │ │ ├── Node.swift │ │ ├── Util.swift │ │ └── main.swift │ └── test │ └── swift │ ├── AppTests.swift │ ├── LinkedListTests.swift │ ├── LinuxMain.swift │ └── UtilTests.swift ├── composite-build ├── build.gradle ├── gradlew ├── gradlew.bat ├── list-library │ ├── build.gradle │ ├── settings.gradle │ └── src │ │ ├── main │ │ └── swift │ │ │ ├── LinkedList.swift │ │ │ └── Node.swift │ │ └── test │ │ └── swift │ │ ├── LinkedListTests.swift │ │ └── LinuxMain.swift ├── settings.gradle ├── src │ ├── main │ │ └── swift │ │ │ └── main.swift │ └── test │ │ └── swift │ │ ├── AppTests.swift │ │ └── LinuxMain.swift └── utilities-library │ ├── build.gradle │ ├── settings.gradle │ └── src │ ├── main │ └── swift │ │ └── Util.swift │ └── test │ └── swift │ ├── LinuxMain.swift │ └── UtilTests.swift ├── cpp-dependencies ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ └── swift │ │ │ ├── LinkedList.swift │ │ │ ├── Util.swift │ │ │ └── main.swift │ │ └── test │ │ └── swift │ │ ├── AppTests.swift │ │ ├── LinkedListTests.swift │ │ ├── LinuxMain.swift │ │ └── UtilTests.swift ├── build.gradle ├── gradlew ├── gradlew.bat ├── list │ ├── build.gradle │ ├── common.gradle │ └── src │ │ └── main │ │ ├── cpp │ │ └── linked_list.cpp │ │ └── public │ │ └── linked_list.h ├── listStatic │ └── build.gradle └── settings.gradle ├── dependency-on-upstream-branch ├── .gitignore └── app │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ ├── main │ └── swift │ │ └── main.swift │ └── test │ └── swift │ ├── AppTests.swift │ └── LinuxMain.swift ├── injected-plugins ├── build.gradle ├── gradlew ├── gradlew.bat ├── plugins │ ├── build.gradle │ ├── settings.gradle │ └── src │ │ └── main │ │ └── groovy │ │ └── org │ │ └── gradle │ │ └── swift │ │ └── samples │ │ ├── CommonPlugin.groovy │ │ ├── GenerateSource.groovy │ │ ├── ListBuildPlugin.groovy │ │ └── UtilitiesBuildPlugin.groovy ├── repos │ └── .gitignore ├── settings.gradle └── src │ ├── main │ └── swift │ │ └── main.swift │ └── test │ └── swift │ ├── AppTests.swift │ └── LinuxMain.swift ├── ios-application ├── build.gradle ├── gradlew ├── gradlew.bat ├── ios-plugin │ ├── build.gradle.kts │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle.kts │ └── src │ │ └── main │ │ └── groovy │ │ └── org │ │ └── gradle │ │ └── samples │ │ ├── plugins │ │ └── IOSApplicationPlugin.groovy │ │ └── tasks │ │ ├── AssetCatalogCompile.groovy │ │ ├── CreateEntitlement.groovy │ │ ├── CreatePackageInformation.groovy │ │ ├── InstallApplicationBundle.groovy │ │ ├── MergePropertyList.groovy │ │ ├── StoryboardCompile.groovy │ │ └── StoryboardLink.groovy ├── settings.gradle └── src │ └── main │ ├── resources │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ └── Info.plist │ └── swift │ ├── AppDelegate.swift │ └── ViewController.swift ├── multiple-target-machines ├── build.gradle ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ └── swift │ │ ├── LinkedList.swift │ │ ├── Node.swift │ │ ├── Util.swift │ │ └── main.swift │ └── test │ └── swift │ ├── AppTests.swift │ ├── LinkedListTests.swift │ ├── LinuxMain.swift │ └── UtilTests.swift ├── operating-system-specific-dependencies ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ └── swift │ │ │ ├── LinkedList.swift │ │ │ ├── Logger.swift │ │ │ ├── Node.swift │ │ │ ├── Util.swift │ │ │ └── main.swift │ │ └── test │ │ └── swift │ │ ├── AppTests.swift │ │ ├── LinkedListTests.swift │ │ ├── LinuxMain.swift │ │ └── UtilTests.swift ├── build.gradle ├── gradlew ├── gradlew.bat ├── linux-console │ ├── build.gradle │ └── src │ │ └── main │ │ └── swift │ │ └── Console.swift ├── macos-console │ ├── build.gradle │ └── src │ │ └── main │ │ └── swift │ │ └── Console.swift └── settings.gradle ├── prebuilt-binaries ├── build.gradle ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ └── swift │ │ ├── Util.swift │ │ └── main.swift │ └── test │ └── swift │ ├── AppTests.swift │ ├── LinuxMain.swift │ └── UtilTests.swift ├── provisionable-tool-chains ├── build.gradle ├── buildSrc │ └── build.gradle ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ └── swift │ │ ├── LinkedList.swift │ │ ├── Node.swift │ │ ├── Util.swift │ │ └── main.swift │ └── test │ └── swift │ ├── AppTests.swift │ ├── LinkedListTests.swift │ ├── LinuxMain.swift │ └── UtilTests.swift ├── simple-library ├── build.gradle ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ └── swift │ │ ├── LinkedList.swift │ │ └── Node.swift │ └── test │ └── swift │ ├── LinkedListTests.swift │ └── LinuxMain.swift ├── source-dependencies ├── build.gradle ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ └── swift │ │ └── main.swift │ └── test │ └── swift │ ├── AppTests.swift │ └── LinuxMain.swift ├── source-generation ├── build.gradle ├── gradlew ├── gradlew.bat └── settings.gradle ├── static-library ├── app │ ├── build.gradle │ └── src │ │ ├── main │ │ └── swift │ │ │ └── main.swift │ │ └── test │ │ └── swift │ │ ├── AppTests.swift │ │ └── LinuxMain.swift ├── build.gradle ├── gradlew ├── gradlew.bat ├── list │ ├── build.gradle │ └── src │ │ ├── main │ │ └── swift │ │ │ ├── LinkedList.swift │ │ │ └── Node.swift │ │ └── test │ │ └── swift │ │ ├── LinkedListTests.swift │ │ └── LinuxMain.swift ├── settings.gradle └── utilities │ ├── build.gradle │ └── src │ ├── main │ └── swift │ │ └── Util.swift │ └── test │ └── swift │ ├── LinuxMain.swift │ └── UtilTests.swift ├── swift-package-manager-publish ├── .gitignore └── app │ ├── Package.swift │ ├── Sources │ └── App │ │ └── main.swift │ └── Tests │ ├── AppTests │ ├── AppTests.swift │ └── LinuxMain.swift │ └── LinuxMain.swift ├── swift-package-manager ├── Package.swift ├── Sources │ ├── App │ │ └── main.swift │ ├── List │ │ ├── LinkedList.swift │ │ └── Node.swift │ └── Utilities │ │ └── Util.swift ├── Tests │ ├── AppTests │ │ ├── AppTests.swift │ │ └── LinuxMain.swift │ ├── ListTests │ │ ├── LinkedListTests.swift │ │ └── LinuxMain.swift │ └── UtilitiesTests │ │ ├── LinuxMain.swift │ │ └── UtilTests.swift ├── build.gradle ├── gradlew ├── gradlew.bat └── settings.gradle ├── swift-versions ├── build.gradle ├── gradlew ├── gradlew.bat ├── settings.gradle ├── swift3-app │ ├── build.gradle │ └── src │ │ ├── main │ │ └── swift │ │ │ ├── LinkedList.swift │ │ │ ├── Logger.swift │ │ │ ├── Node.swift │ │ │ ├── Util.swift │ │ │ └── main.swift │ │ └── test │ │ └── swift │ │ ├── AppTests.swift │ │ ├── LinkedListTests.swift │ │ ├── LinuxMain.swift │ │ ├── LoggerTests.swift │ │ └── UtilTests.swift ├── swift4-app │ ├── build.gradle │ └── src │ │ ├── main │ │ └── swift │ │ │ ├── LinkedList.swift │ │ │ ├── Logger.swift │ │ │ ├── Node.swift │ │ │ ├── Util.swift │ │ │ └── main.swift │ │ └── test │ │ └── swift │ │ ├── AppTests.swift │ │ ├── LinkedListTests.swift │ │ ├── LinuxMain.swift │ │ ├── LoggerTests.swift │ │ └── UtilTests.swift └── swift5-app │ ├── build.gradle │ └── src │ ├── main │ └── swift │ │ ├── LinkedList.swift │ │ ├── Logger.swift │ │ ├── Node.swift │ │ ├── Util.swift │ │ └── main.swift │ └── test │ └── swift │ ├── AppTests.swift │ ├── LinkedListTests.swift │ ├── LinuxMain.swift │ ├── LoggerTests.swift │ └── UtilTests.swift ├── system-library-as-module ├── build.gradle ├── curl │ ├── module.modulemap │ └── shim.h ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ └── swift │ └── main.swift └── transitive-dependencies ├── app ├── build.gradle └── src │ ├── main │ └── swift │ │ └── main.swift │ └── test │ └── swift │ ├── AppTests.swift │ └── LinuxMain.swift ├── build.gradle ├── gradlew ├── gradlew.bat ├── list ├── build.gradle └── src │ ├── main │ └── swift │ │ ├── LinkedList.swift │ │ └── Node.swift │ └── test │ └── swift │ ├── LinkedListTests.swift │ └── LinuxMain.swift ├── settings.gradle └── utilities ├── build.gradle └── src ├── main └── swift │ └── Util.swift └── test └── swift ├── LinuxMain.swift └── UtilTests.swift /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | In order to foster a more inclusive community, Gradle has adopted the [Contributor Covenant](https://www.contributor-covenant.org/version/1/4/code-of-conduct/). 4 | 5 | Contributors must follow the Code of Conduct outlined at [https://gradle.org/conduct/](https://gradle.org/conduct/). 6 | -------------------------------------------------------------------------------- /.github/dco.yml: -------------------------------------------------------------------------------- 1 | # Disable sign-off chcecking for members of the Gradle GitHub organization 2 | require: 3 | members: false 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle Files 2 | build 3 | .gradle 4 | 5 | # Local repository 6 | cpp/repo 7 | cpp/cmake-library/repo 8 | 9 | # Swift Package Manager Files 10 | .build 11 | Packages 12 | Package.resolved 13 | 14 | # Xcode Files 15 | *.xcodeproj 16 | *.xcworkspace 17 | 18 | # Visual Studio Files 19 | 20 | .vs 21 | *.sln 22 | *.vcxproj 23 | *.vcxproj.filters 24 | *.vcxproj.user 25 | 26 | # AppCode/IDEA/Eclipse Files 27 | .idea 28 | *.iml 29 | *.ipr 30 | *.iws 31 | out/ 32 | .project 33 | .classpath 34 | 35 | # Mac OS Junk 36 | .DS_Store 37 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | // This root project is simply a container of sample builds 2 | plugins { 3 | id("org.gradle.samples.wrapper") 4 | } 5 | -------------------------------------------------------------------------------- /c/application/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /c/application/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /c/application/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' -------------------------------------------------------------------------------- /c/application/src/main/c/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | printf("Hello, World!\n"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /cpp/application/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-application' 3 | id 'xcode' 4 | id 'visual-studio' 5 | } 6 | -------------------------------------------------------------------------------- /cpp/application/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/application/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/application/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | -------------------------------------------------------------------------------- /cpp/application/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/application/src/main/cpp/copy_ctor_assign.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | static void copy(const linked_list & source, linked_list * destination) { 6 | for (int i = 0; i < source.size(); ++i) { 7 | destination->add(source.get(i)); 8 | } 9 | } 10 | 11 | linked_list::linked_list(const linked_list & o) { 12 | head_ = NULL; 13 | copy(o, this); 14 | } 15 | 16 | linked_list & linked_list::operator=(const linked_list & rhs) { 17 | head_ = NULL; 18 | copy(rhs, this); 19 | return *this; 20 | } 21 | -------------------------------------------------------------------------------- /cpp/application/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/application/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/application/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/application/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/application/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/application/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/application/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/application/src/main/headers/string_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library of string utility functions. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include "linked_list.h" 10 | 11 | #define UTILITIES_API 12 | 13 | /* 14 | * Splits the given string into a list of tokens. Tokens are separated by one or more whitespace characters. 15 | */ 16 | UTILITIES_API linked_list split(const std::string & source); 17 | 18 | /* 19 | * Joins the list of tokens into a string, separated by space characters. 20 | */ 21 | UTILITIES_API std::string join(const linked_list & source); 22 | -------------------------------------------------------------------------------- /cpp/autotools-library/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "cpp-application" 2 | 3 | dependencies { 4 | implementation project(":curl") 5 | } -------------------------------------------------------------------------------- /cpp/autotools-library/app/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/autotools-library/app/src/main/cpp/copy_ctor_assign.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | static void copy(const linked_list & source, linked_list * destination) { 6 | for (int i = 0; i < source.size(); ++i) { 7 | destination->add(source.get(i)); 8 | } 9 | } 10 | 11 | linked_list::linked_list(const linked_list & o) { 12 | head_ = NULL; 13 | copy(o, this); 14 | } 15 | 16 | linked_list & linked_list::operator=(const linked_list & rhs) { 17 | head_ = NULL; 18 | copy(rhs, this); 19 | return *this; 20 | } 21 | -------------------------------------------------------------------------------- /cpp/autotools-library/app/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/autotools-library/app/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/autotools-library/app/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/autotools-library/app/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/autotools-library/app/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/autotools-library/app/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/autotools-library/app/src/main/headers/string_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library of string utility functions. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include "linked_list.h" 10 | 11 | #define UTILITIES_API 12 | 13 | /* 14 | * Splits the given string into a list of tokens. Tokens are separated by one or more whitespace characters. 15 | */ 16 | UTILITIES_API linked_list split(const std::string & source); 17 | 18 | /* 19 | * Joins the list of tokens into a string, separated by space characters. 20 | */ 21 | UTILITIES_API std::string join(const linked_list & source); 22 | -------------------------------------------------------------------------------- /cpp/autotools-library/build-wrapper-plugin/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/autotools-library/build-wrapper-plugin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/autotools-library/build-wrapper-plugin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "build-wrapper" 2 | -------------------------------------------------------------------------------- /cpp/autotools-library/build-wrapper-plugin/src/main/java/org/gradle/samples/plugins/WrappedNativeBasePlugin.java: -------------------------------------------------------------------------------- 1 | package org.gradle.samples.plugins; 2 | 3 | import org.gradle.api.Plugin; 4 | import org.gradle.api.Project; 5 | 6 | public class WrappedNativeBasePlugin implements Plugin { 7 | @Override 8 | public void apply(Project project) { 9 | // Apply the base plugin, to define 'clean' task and other things 10 | project.getPluginManager().apply("lifecycle-base"); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /cpp/autotools-library/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | allprojects { 3 | apply plugin: 'xcode' 4 | } 5 | -------------------------------------------------------------------------------- /cpp/autotools-library/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/autotools-library/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/autotools-library/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':curl' 2 | 3 | // This is included for convenience. Usually this plugin would be published to a plugin repository instead 4 | includeBuild "build-wrapper-plugin" 5 | -------------------------------------------------------------------------------- /cpp/binary-dependencies/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-application' 3 | id 'xcode' 4 | id 'visual-studio' 5 | } 6 | 7 | repositories { 8 | maven { 9 | url '../repo' 10 | } 11 | } 12 | 13 | application { 14 | dependencies { 15 | implementation 'org.gradle.cpp-samples:list:1.5' 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /cpp/binary-dependencies/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/binary-dependencies/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/binary-dependencies/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | -------------------------------------------------------------------------------- /cpp/binary-dependencies/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/binary-dependencies/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/binary-dependencies/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/binary-dependencies/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/binary-dependencies/src/main/headers/string_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library of string utility functions. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include "linked_list.h" 10 | 11 | #define UTILITIES_API 12 | 13 | /* 14 | * Splits the given string into a list of tokens. Tokens are separated by one or more whitespace characters. 15 | */ 16 | UTILITIES_API linked_list split(const std::string & source); 17 | 18 | /* 19 | * Joins the list of tokens into a string, separated by space characters. 20 | */ 21 | UTILITIES_API std::string join(const linked_list & source); 22 | -------------------------------------------------------------------------------- /cpp/cmake-library/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-application' 3 | } 4 | 5 | dependencies { 6 | implementation project(':utilities') 7 | } 8 | -------------------------------------------------------------------------------- /cpp/cmake-library/app/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/cmake-library/app/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/cmake-library/app/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/cmake-library/build-wrapper-plugin/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/cmake-library/build-wrapper-plugin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/cmake-library/build-wrapper-plugin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "build-wrapper" 2 | -------------------------------------------------------------------------------- /cpp/cmake-library/build-wrapper-plugin/src/main/java/org/gradle/samples/plugins/WrappedNativeBasePlugin.java: -------------------------------------------------------------------------------- 1 | package org.gradle.samples.plugins; 2 | 3 | import org.gradle.api.Plugin; 4 | import org.gradle.api.Project; 5 | 6 | public class WrappedNativeBasePlugin implements Plugin { 7 | @Override 8 | public void apply(Project project) { 9 | // Apply the base plugin, to define 'clean' task and other things 10 | project.getPluginManager().apply("lifecycle-base"); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /cpp/cmake-library/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | apply plugin: 'xcode' 3 | 4 | group = 'org.gradle.cpp-samples' 5 | version = '1.2' 6 | } -------------------------------------------------------------------------------- /cpp/cmake-library/custom-publication-plugin/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/cmake-library/custom-publication-plugin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/cmake-library/custom-publication-plugin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "custom-publication" 2 | -------------------------------------------------------------------------------- /cpp/cmake-library/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/cmake-library/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/cmake-library/list/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(list) 3 | 4 | add_subdirectory(src/list) 5 | -------------------------------------------------------------------------------- /cpp/cmake-library/list/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.gradle.samples.cmake-library' version '1.0' 3 | id 'org.gradle.samples.custom-publication' version '1.0' 4 | } 5 | 6 | group = "org.gradle.cpp-samples" 7 | version = "1.3" 8 | 9 | cmake { 10 | binary = "src/list/liblist.a" 11 | includeDirectory = layout.projectDirectory.dir("src/list/include") 12 | } 13 | 14 | publishing { 15 | repositories { 16 | maven { 17 | url '../repo' 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cpp/cmake-library/list/src/list/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(listLib) 2 | 3 | add_library(list 4 | add.cpp 5 | copy_ctor_assign.cpp 6 | destructor.cpp 7 | get.cpp 8 | remove.cpp 9 | size.cpp) 10 | 11 | target_include_directories(list PUBLIC include) 12 | -------------------------------------------------------------------------------- /cpp/cmake-library/list/src/list/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/cmake-library/list/src/list/copy_ctor_assign.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | static void copy(const linked_list & source, linked_list * destination) { 6 | for (int i = 0; i < source.size(); ++i) { 7 | destination->add(source.get(i)); 8 | } 9 | } 10 | 11 | linked_list::linked_list(const linked_list & o) { 12 | head_ = NULL; 13 | copy(o, this); 14 | } 15 | 16 | linked_list & linked_list::operator=(const linked_list & rhs) { 17 | head_ = NULL; 18 | copy(rhs, this); 19 | return *this; 20 | } 21 | -------------------------------------------------------------------------------- /cpp/cmake-library/list/src/list/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/cmake-library/list/src/list/include/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/cmake-library/list/src/list/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/cmake-library/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'cmake' 2 | 3 | include ":app", ":utilities", ":list" 4 | 5 | // These are included for convenience. Usually these plugins would be published to a plugin repository instead 6 | includeBuild "build-wrapper-plugin" 7 | includeBuild "custom-publication-plugin" 8 | -------------------------------------------------------------------------------- /cpp/cmake-library/utilities/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | id 'org.gradle.samples.custom-publication' version '1.0' 4 | } 5 | 6 | library { 7 | linkage = [Linkage.STATIC] 8 | dependencies { 9 | api project(":list") 10 | } 11 | } 12 | 13 | publishing { 14 | repositories { 15 | maven { 16 | url "../repo" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cpp/cmake-library/utilities/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/cmake-source-dependencies/.gitignore: -------------------------------------------------------------------------------- 1 | list/ 2 | build-wrapper-plugin/ 3 | app/ 4 | utilities/ 5 | -------------------------------------------------------------------------------- /cpp/composite-build/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-application' 3 | id 'xcode' 4 | id 'visual-studio' 5 | } 6 | 7 | application { 8 | dependencies { 9 | implementation 'org.gradle.cpp-samples:utilities:1.2' 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/composite-build/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/composite-build/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/composite-build/list-library/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | id 'xcode' 4 | } 5 | 6 | group = 'org.gradle.cpp-samples' 7 | version = '1.5' 8 | -------------------------------------------------------------------------------- /cpp/composite-build/list-library/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'list' 2 | -------------------------------------------------------------------------------- /cpp/composite-build/list-library/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/composite-build/list-library/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/composite-build/list-library/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/composite-build/list-library/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/composite-build/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | 3 | includeBuild 'list-library' 4 | includeBuild 'utilities-library' 5 | -------------------------------------------------------------------------------- /cpp/composite-build/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/composite-build/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/composite-build/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/composite-build/utilities-library/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | id 'xcode' 4 | } 5 | 6 | group = 'org.gradle.cpp-samples' 7 | version = '1.2' 8 | 9 | library { 10 | dependencies { 11 | api 'org.gradle.cpp-samples:list:1.5' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cpp/composite-build/utilities-library/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'utilities' 2 | -------------------------------------------------------------------------------- /cpp/composite-build/utilities-library/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/dependency-on-upstream-branch/.gitignore: -------------------------------------------------------------------------------- 1 | list-library/ 2 | utilities-library/ 3 | -------------------------------------------------------------------------------- /cpp/dependency-on-upstream-branch/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-application' 3 | id 'xcode' 4 | id 'visual-studio' 5 | } 6 | 7 | group = 'org.gradle.cpp-samples' 8 | 9 | application { 10 | dependencies { 11 | implementation('org.gradle.cpp-samples:utilities') { 12 | version { 13 | branch = 'release' 14 | } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /cpp/dependency-on-upstream-branch/app/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/dependency-on-upstream-branch/app/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/dependency-on-upstream-branch/app/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | 3 | sourceControl { 4 | gitRepository("../utilities-library") { 5 | producesModule("org.gradle.cpp-samples:utilities") 6 | } 7 | gitRepository("../list-library") { 8 | producesModule("org.gradle.cpp-samples:list") 9 | } 10 | } -------------------------------------------------------------------------------- /cpp/dependency-on-upstream-branch/app/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/dependency-on-upstream-branch/app/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/dependency-on-upstream-branch/app/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/header-only-library/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/header-only-library/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/header-only-library/header-gradle-plugin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-gradle-plugin` 3 | } 4 | 5 | group = "org.gradle.samples" 6 | version = "1.0" 7 | 8 | gradlePlugin { 9 | (plugins) { 10 | create("headerOnly") { 11 | id = "org.gradle.samples.cpp-header-library" 12 | implementationClass = "org.gradle.samples.plugins.CppHeaderLibraryPlugin" 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /cpp/header-only-library/header-gradle-plugin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "header-gradle-plugin" -------------------------------------------------------------------------------- /cpp/header-only-library/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "list-header" 2 | 3 | includeBuild "header-gradle-plugin" 4 | -------------------------------------------------------------------------------- /cpp/header-only-library/src/test/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | int main(int argc, char **argv) { 4 | ::testing::InitGoogleTest(&argc, argv); 5 | return RUN_ALL_TESTS(); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /cpp/injected-plugins/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-application' 3 | id 'xcode' 4 | id 'visual-studio' 5 | } 6 | 7 | group = 'org.gradle.cpp-samples' 8 | 9 | application { 10 | dependencies { 11 | implementation 'org.gradle.cpp-samples:utilities:latest.integration' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cpp/injected-plugins/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/injected-plugins/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/injected-plugins/plugins/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'groovy' 3 | id 'java-gradle-plugin' 4 | } 5 | 6 | gradlePlugin { 7 | plugins { 8 | "utilities-build" { 9 | id = "utilities-build" 10 | implementationClass = "org.gradle.cpp.samples.UtilitiesBuildPlugin" 11 | } 12 | "list-build" { 13 | id = "list-build" 14 | implementationClass = "org.gradle.cpp.samples.ListBuildPlugin" 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /cpp/injected-plugins/plugins/settings.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/native-samples/99f9b825ecb0636d7fef75e1a21c0b0c1caadbcb/cpp/injected-plugins/plugins/settings.gradle -------------------------------------------------------------------------------- /cpp/injected-plugins/plugins/src/main/groovy/org/gradle/cpp/samples/CommonPlugin.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.cpp.samples 2 | 3 | import org.gradle.api.* 4 | 5 | class CommonPlugin implements Plugin { 6 | void apply(Project project) { 7 | project.allprojects { 8 | apply plugin: 'cpp-library' 9 | apply plugin: 'xcode' 10 | apply plugin: 'visual-studio' 11 | 12 | group = 'org.gradle.cpp-samples' 13 | version = '1.0-SNAPSHOT' 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cpp/injected-plugins/repos/.gitignore: -------------------------------------------------------------------------------- 1 | list-library/ 2 | utilities-library/ 3 | -------------------------------------------------------------------------------- /cpp/injected-plugins/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | 3 | includeBuild('plugins') 4 | 5 | sourceControl { 6 | gitRepository("repos/utilities-library") { 7 | producesModule("org.gradle.cpp-samples:utilities") 8 | plugins { 9 | id "utilities-build" 10 | } 11 | } 12 | gitRepository("repos/list-library") { 13 | producesModule("org.gradle.cpp-samples:list") 14 | plugins { 15 | id "list-build" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cpp/injected-plugins/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/injected-plugins/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/injected-plugins/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/library-with-tests/build-wrapper-plugin/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/library-with-tests/build-wrapper-plugin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/library-with-tests/build-wrapper-plugin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "build-wrapper" 2 | -------------------------------------------------------------------------------- /cpp/library-with-tests/build-wrapper-plugin/src/main/java/org/gradle/samples/plugins/WrappedNativeBasePlugin.java: -------------------------------------------------------------------------------- 1 | package org.gradle.samples.plugins; 2 | 3 | import org.gradle.api.Plugin; 4 | import org.gradle.api.Project; 5 | 6 | public class WrappedNativeBasePlugin implements Plugin { 7 | @Override 8 | public void apply(Project project) { 9 | // Apply the base plugin, to define 'clean' task and other things 10 | project.getPluginManager().apply("lifecycle-base"); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /cpp/library-with-tests/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | id 'xcode' 4 | id 'maven-publish' 5 | id 'cpp-unit-test' 6 | } 7 | 8 | group = 'org.gradle.cpp-samples' 9 | version = '1.5' 10 | 11 | unitTest { 12 | dependencies { 13 | implementation project(':googletest') 14 | } 15 | 16 | binaries.whenElementKnown(CppTestExecutable) { binary -> 17 | if (binary.targetMachine.operatingSystemFamily.linux) { 18 | binary.linkTask.get().linkerArgs.add('-pthread') 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cpp/library-with-tests/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/library-with-tests/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/library-with-tests/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "list" 2 | include("googletest") 3 | 4 | // This is included for convenience. Usually this plugin would be published to a plugin repository instead 5 | includeBuild "build-wrapper-plugin" 6 | -------------------------------------------------------------------------------- /cpp/library-with-tests/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/library-with-tests/src/main/cpp/copy_ctor_assign.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | static void copy(const linked_list & source, linked_list * destination) { 6 | for (int i = 0; i < source.size(); ++i) { 7 | destination->add(source.get(i)); 8 | } 9 | } 10 | 11 | linked_list::linked_list(const linked_list & o) { 12 | head_ = NULL; 13 | copy(o, this); 14 | } 15 | 16 | linked_list & linked_list::operator=(const linked_list & rhs) { 17 | head_ = NULL; 18 | copy(rhs, this); 19 | return *this; 20 | } 21 | -------------------------------------------------------------------------------- /cpp/library-with-tests/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/library-with-tests/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/library-with-tests/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/library-with-tests/src/test/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | int main(int argc, char **argv) { 4 | ::testing::InitGoogleTest(&argc, argv); 5 | return RUN_ALL_TESTS(); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /cpp/multiple-target-machines/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "cpp-application" 3 | id "visual-studio" 4 | id "xcode" 5 | } 6 | 7 | application { 8 | targetMachines = [ 9 | machines.windows.x86_64, 10 | machines.macOS.x86_64, 11 | machines.linux.x86_64 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /cpp/multiple-target-machines/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/multiple-target-machines/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/multiple-target-machines/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "app" -------------------------------------------------------------------------------- /cpp/multiple-target-machines/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/multiple-target-machines/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/multiple-target-machines/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/multiple-target-machines/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/multiple-target-machines/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/multiple-target-machines/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/multiple-target-machines/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/multiple-target-machines/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/ansiConsole/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | } 4 | 5 | library { 6 | targetMachines = [ 7 | machines.linux, 8 | machines.macOS 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/ansiConsole/src/main/public/ansi_console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A logger that uses ANSI control sequences to generate color output. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | 8 | class ansi_console { 9 | public: 10 | ansi_console(); 11 | void color(const std::string & message); 12 | }; 13 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-application' 3 | } 4 | 5 | application { 6 | targetMachines = [ 7 | machines.windows, 8 | machines.linux, 9 | machines.macOS 10 | ] 11 | binaries.configureEach { 12 | dependencies { 13 | if (targetMachine.operatingSystemFamily.windows) { 14 | implementation project(':winConsole') 15 | } else { 16 | implementation project(':ansiConsole') 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/app/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/app/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/app/src/main/cpp/logger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A logger that writes messages to a console. 3 | */ 4 | #include 5 | 6 | #ifdef _WIN32 7 | #include "win_console.h" 8 | #else 9 | #include "ansi_console.h" 10 | #endif 11 | #include "logger.h" 12 | 13 | logger::logger() { 14 | } 15 | 16 | void logger::info(const std::string & message) { 17 | #ifdef _WIN32 18 | win_console console; 19 | #else 20 | ansi_console console; 21 | #endif 22 | console.color(message); 23 | } 24 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/app/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "logger.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split("Hello, World!"); 13 | std::string result = join(tokens); 14 | logger logger; 15 | logger.info(result); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/app/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/app/src/main/headers/logger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Writes log messages to some destination. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | 8 | class logger { 9 | public: 10 | logger(); 11 | 12 | // Writes an info message and trailing new-line 13 | void info(const std::string & message); 14 | }; 15 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/app/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | apply plugin: 'xcode' 3 | apply plugin: 'visual-studio' 4 | } 5 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'osDeps' 2 | 3 | include 'app', 'ansiConsole', 'winConsole' 4 | -------------------------------------------------------------------------------- /cpp/operating-system-specific-dependencies/winConsole/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | } 4 | 5 | library { 6 | targetMachines = [ 7 | machines.windows 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /cpp/prebuilt-binaries/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/prebuilt-binaries/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/prebuilt-binaries/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | -------------------------------------------------------------------------------- /cpp/prebuilt-binaries/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/prebuilt-binaries/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/prebuilt-binaries/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/prebuilt-binaries/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/prebuilt-binaries/src/main/headers/string_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library of string utility functions. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include "linked_list.h" 10 | 11 | #define UTILITIES_API 12 | 13 | /* 14 | * Splits the given string into a list of tokens. Tokens are separated by one or more whitespace characters. 15 | */ 16 | UTILITIES_API linked_list split(const std::string & source); 17 | 18 | /* 19 | * Joins the list of tokens into a string, separated by space characters. 20 | */ 21 | UTILITIES_API std::string join(const linked_list & source); 22 | -------------------------------------------------------------------------------- /cpp/prebuilt-repo/org/gradle/cpp-samples/googletest/1.9.0-gr4-SNAPSHOT/googletest-1.9.0-gr4-SNAPSHOT-cpp-api-headers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/native-samples/99f9b825ecb0636d7fef75e1a21c0b0c1caadbcb/cpp/prebuilt-repo/org/gradle/cpp-samples/googletest/1.9.0-gr4-SNAPSHOT/googletest-1.9.0-gr4-SNAPSHOT-cpp-api-headers.zip -------------------------------------------------------------------------------- /cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_debug_linux/1.9.0-gr4-SNAPSHOT/googletest_debug_linux-1.9.0-gr4-SNAPSHOT.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/native-samples/99f9b825ecb0636d7fef75e1a21c0b0c1caadbcb/cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_debug_linux/1.9.0-gr4-SNAPSHOT/googletest_debug_linux-1.9.0-gr4-SNAPSHOT.so -------------------------------------------------------------------------------- /cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_debug_macos/1.9.0-gr4-SNAPSHOT/googletest_debug_macos-1.9.0-gr4-SNAPSHOT.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/native-samples/99f9b825ecb0636d7fef75e1a21c0b0c1caadbcb/cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_debug_macos/1.9.0-gr4-SNAPSHOT/googletest_debug_macos-1.9.0-gr4-SNAPSHOT.dylib -------------------------------------------------------------------------------- /cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_debug_windows/1.9.0-gr4-SNAPSHOT/googletest_debug_windows-1.9.0-gr4-SNAPSHOT.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/native-samples/99f9b825ecb0636d7fef75e1a21c0b0c1caadbcb/cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_debug_windows/1.9.0-gr4-SNAPSHOT/googletest_debug_windows-1.9.0-gr4-SNAPSHOT.dll -------------------------------------------------------------------------------- /cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_debug_windows/1.9.0-gr4-SNAPSHOT/googletest_debug_windows-1.9.0-gr4-SNAPSHOT.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/native-samples/99f9b825ecb0636d7fef75e1a21c0b0c1caadbcb/cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_debug_windows/1.9.0-gr4-SNAPSHOT/googletest_debug_windows-1.9.0-gr4-SNAPSHOT.lib -------------------------------------------------------------------------------- /cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_release_linux/1.9.0-gr4-SNAPSHOT/googletest_release_linux-1.9.0-gr4-SNAPSHOT.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/native-samples/99f9b825ecb0636d7fef75e1a21c0b0c1caadbcb/cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_release_linux/1.9.0-gr4-SNAPSHOT/googletest_release_linux-1.9.0-gr4-SNAPSHOT.so -------------------------------------------------------------------------------- /cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_release_macos/1.9.0-gr4-SNAPSHOT/googletest_release_macos-1.9.0-gr4-SNAPSHOT.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/native-samples/99f9b825ecb0636d7fef75e1a21c0b0c1caadbcb/cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_release_macos/1.9.0-gr4-SNAPSHOT/googletest_release_macos-1.9.0-gr4-SNAPSHOT.dylib -------------------------------------------------------------------------------- /cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_release_windows/1.9.0-gr4-SNAPSHOT/googletest_release_windows-1.9.0-gr4-SNAPSHOT.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/native-samples/99f9b825ecb0636d7fef75e1a21c0b0c1caadbcb/cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_release_windows/1.9.0-gr4-SNAPSHOT/googletest_release_windows-1.9.0-gr4-SNAPSHOT.dll -------------------------------------------------------------------------------- /cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_release_windows/1.9.0-gr4-SNAPSHOT/googletest_release_windows-1.9.0-gr4-SNAPSHOT.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/native-samples/99f9b825ecb0636d7fef75e1a21c0b0c1caadbcb/cpp/prebuilt-repo/org/gradle/cpp-samples/googletest_release_windows/1.9.0-gr4-SNAPSHOT/googletest_release_windows-1.9.0-gr4-SNAPSHOT.lib -------------------------------------------------------------------------------- /cpp/precompiled-headers/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/precompiled-headers/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/precompiled-headers/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | -------------------------------------------------------------------------------- /cpp/precompiled-headers/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/precompiled-headers/src/main/cpp/copy_ctor_assign.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | static void copy(const linked_list & source, linked_list * destination) { 6 | for (int i = 0; i < source.size(); ++i) { 7 | destination->add(source.get(i)); 8 | } 9 | } 10 | 11 | linked_list::linked_list(const linked_list & o) { 12 | head_ = NULL; 13 | copy(o, this); 14 | } 15 | 16 | linked_list & linked_list::operator=(const linked_list & rhs) { 17 | head_ = NULL; 18 | copy(rhs, this); 19 | return *this; 20 | } 21 | -------------------------------------------------------------------------------- /cpp/precompiled-headers/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/precompiled-headers/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/precompiled-headers/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/precompiled-headers/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/precompiled-headers/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/precompiled-headers/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/precompiled-headers/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/precompiled-headers/src/main/headers/pch.h: -------------------------------------------------------------------------------- 1 | #include "linked_list.h" 2 | #include "node.h" 3 | #include "message.h" -------------------------------------------------------------------------------- /cpp/precompiled-headers/src/main/headers/string_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library of string utility functions. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include "linked_list.h" 10 | 11 | #define UTILITIES_API 12 | 13 | /* 14 | * Splits the given string into a list of tokens. Tokens are separated by one or more whitespace characters. 15 | */ 16 | UTILITIES_API linked_list split(const std::string & source); 17 | 18 | /* 19 | * Joins the list of tokens into a string, separated by space characters. 20 | */ 21 | UTILITIES_API std::string join(const linked_list & source); 22 | -------------------------------------------------------------------------------- /cpp/provisionable-tool-chains/build.gradle: -------------------------------------------------------------------------------- 1 | // Currently cannot use the plugins { } block to reference plugins with software model elements 2 | // Use the `apply plugin:` instead 3 | apply plugin: 'cpp-application' 4 | apply plugin: 'xcode' 5 | 6 | model { 7 | toolChains { 8 | provisionedClang(Clang) { 9 | path rootProject.file('buildSrc/build/toolChains/clang-5.0.1/bin') 10 | 11 | // Required to locate dsymutil on macOS and objcopy on Linux 12 | path System.getenv('PATH').split(':') 13 | } 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /cpp/provisionable-tool-chains/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/provisionable-tool-chains/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/provisionable-tool-chains/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' -------------------------------------------------------------------------------- /cpp/provisionable-tool-chains/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/provisionable-tool-chains/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/provisionable-tool-chains/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/provisionable-tool-chains/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/provisionable-tool-chains/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/provisionable-tool-chains/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/provisionable-tool-chains/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/provisionable-tool-chains/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/publish-macros/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "cpp-application" 3 | id "org.gradle.samples.cpp-public-macros" version "1.0" 4 | } 5 | 6 | application { 7 | binaries.configureEach { 8 | dependencies { 9 | implementation project(":utilities") 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /cpp/publish-macros/app/src/main/cpp/check_published_macros.cpp: -------------------------------------------------------------------------------- 1 | #ifndef FOOBAR 2 | # error "Macro not published or consumed correctly" 3 | #endif -------------------------------------------------------------------------------- /cpp/publish-macros/app/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/publish-macros/app/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/publish-macros/app/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/publish-macros/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | apply plugin: "xcode" 3 | apply plugin: "visual-studio" 4 | apply plugin: "maven-publish" 5 | 6 | group = "org.gradle.cpp-samples" 7 | version = "1.6" 8 | 9 | publishing { 10 | repositories { 11 | maven { 12 | url = '../repo' 13 | } 14 | } 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /cpp/publish-macros/cpp-public-macros-plugin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-gradle-plugin` 3 | } 4 | 5 | group = "org.gradle.samples" 6 | version = "1.0" 7 | 8 | gradlePlugin { 9 | (plugins) { 10 | register("cppPublicMacros") { 11 | id = "org.gradle.samples.cpp-public-macros" 12 | implementationClass = "org.gradle.samples.plugins.CppPublicMacrosPlugin" 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /cpp/publish-macros/cpp-public-macros-plugin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "cpp-public-macros-plugin" -------------------------------------------------------------------------------- /cpp/publish-macros/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/publish-macros/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/publish-macros/list/build.gradle: -------------------------------------------------------------------------------- 1 | import org.gradle.samples.tasks.GeneratePublicMacrosManifest 2 | 3 | plugins { 4 | id "cpp-library" 5 | id "org.gradle.samples.cpp-public-macros" version "1.0" 6 | } 7 | 8 | tasks.withType(GeneratePublicMacrosManifest).configureEach { 9 | macros = [macro("FOO", "BAR"), macro("FOOBAR")] 10 | } -------------------------------------------------------------------------------- /cpp/publish-macros/list/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/publish-macros/list/src/main/cpp/copy_ctor_assign.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | static void copy(const linked_list & source, linked_list * destination) { 6 | for (int i = 0; i < source.size(); ++i) { 7 | destination->add(source.get(i)); 8 | } 9 | } 10 | 11 | linked_list::linked_list(const linked_list & o) { 12 | head_ = NULL; 13 | copy(o, this); 14 | } 15 | 16 | linked_list & linked_list::operator=(const linked_list & rhs) { 17 | head_ = NULL; 18 | copy(rhs, this); 19 | return *this; 20 | } 21 | -------------------------------------------------------------------------------- /cpp/publish-macros/list/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/publish-macros/list/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/publish-macros/list/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/publish-macros/list/src/test/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | int main(int argc, char **argv) { 4 | ::testing::InitGoogleTest(&argc, argv); 5 | return RUN_ALL_TESTS(); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /cpp/publish-macros/settings.gradle: -------------------------------------------------------------------------------- 1 | include "app", "list", "utilities" 2 | 3 | // This is included for convenience. Usually this plugin would be published to a plugin repository instead 4 | includeBuild "cpp-public-macros-plugin" 5 | -------------------------------------------------------------------------------- /cpp/publish-macros/utilities/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | id 'org.gradle.samples.cpp-public-macros' version '1.0' 4 | } 5 | 6 | library { 7 | dependencies { 8 | api project(':list') 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /cpp/publish-macros/utilities/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/simple-library/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/simple-library/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/simple-library/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'list' 2 | -------------------------------------------------------------------------------- /cpp/simple-library/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/simple-library/src/main/cpp/copy_ctor_assign.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | static void copy(const linked_list & source, linked_list * destination) { 6 | for (int i = 0; i < source.size(); ++i) { 7 | destination->add(source.get(i)); 8 | } 9 | } 10 | 11 | linked_list::linked_list(const linked_list & o) { 12 | head_ = NULL; 13 | copy(o, this); 14 | } 15 | 16 | linked_list & linked_list::operator=(const linked_list & rhs) { 17 | head_ = NULL; 18 | copy(rhs, this); 19 | return *this; 20 | } 21 | -------------------------------------------------------------------------------- /cpp/simple-library/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/simple-library/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/simple-library/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/simple-library/src/test/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | int main(int argc, char **argv) { 4 | ::testing::InitGoogleTest(&argc, argv); 5 | return RUN_ALL_TESTS(); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /cpp/source-dependencies/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-application' 3 | id 'xcode' 4 | id 'visual-studio' 5 | } 6 | 7 | group = 'org.gradle.cpp-samples' 8 | 9 | application { 10 | dependencies { 11 | implementation 'org.gradle.cpp-samples:utilities:1.0' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cpp/source-dependencies/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/source-dependencies/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/source-dependencies/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | 3 | sourceControl { 4 | gitRepository("https://github.com/gradle/native-samples-cpp-library.git") { 5 | producesModule("org.gradle.cpp-samples:utilities") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /cpp/source-dependencies/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/source-dependencies/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/source-dependencies/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/source-generation/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/source-generation/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/source-generation/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | -------------------------------------------------------------------------------- /cpp/static-library/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-application' 3 | } 4 | 5 | application { 6 | dependencies { 7 | implementation project(':utilities') 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /cpp/static-library/app/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/static-library/app/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/static-library/app/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/static-library/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | apply plugin: 'xcode' 3 | apply plugin: 'visual-studio' 4 | } 5 | -------------------------------------------------------------------------------- /cpp/static-library/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/static-library/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/static-library/list/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | } 4 | 5 | library { 6 | linkage = [Linkage.STATIC, Linkage.SHARED] 7 | } 8 | -------------------------------------------------------------------------------- /cpp/static-library/list/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/static-library/list/src/main/cpp/copy_ctor_assign.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | static void copy(const linked_list & source, linked_list * destination) { 6 | for (int i = 0; i < source.size(); ++i) { 7 | destination->add(source.get(i)); 8 | } 9 | } 10 | 11 | linked_list::linked_list(const linked_list & o) { 12 | head_ = NULL; 13 | copy(o, this); 14 | } 15 | 16 | linked_list & linked_list::operator=(const linked_list & rhs) { 17 | head_ = NULL; 18 | copy(rhs, this); 19 | return *this; 20 | } 21 | -------------------------------------------------------------------------------- /cpp/static-library/list/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/static-library/list/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/static-library/list/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/static-library/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'app', 'utilities', 'list' 2 | -------------------------------------------------------------------------------- /cpp/static-library/utilities/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | } 4 | 5 | library { 6 | linkage = [Linkage.STATIC] 7 | 8 | dependencies { 9 | api project(':list') 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/static-library/utilities/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/swift-package-manager-publish/.gitignore: -------------------------------------------------------------------------------- 1 | list-library/ 2 | release-plugin/ 3 | utilities-library/ 4 | -------------------------------------------------------------------------------- /cpp/swift-package-manager-publish/app/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:4.0 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "App", 7 | dependencies: [ 8 | .package(url: "../utilities-library", from: "1.0.0"), 9 | .package(url: "../list-library", from: "1.0.0") 10 | ], 11 | targets: [ 12 | .target( 13 | name: "App", 14 | dependencies: [ 15 | .product(name: "utilities"), 16 | .product(name: "list") 17 | ] 18 | ), 19 | ] 20 | ) 21 | -------------------------------------------------------------------------------- /cpp/swift-package-manager-publish/app/Sources/App/include/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #ifdef _WIN32 10 | # ifdef MESSAGE_MODULE_EXPORT 11 | # define MESSAGE_API __declspec(dllexport) 12 | # else 13 | # define MESSAGE_API __declspec(dllimport) 14 | # endif 15 | #else 16 | # define MESSAGE_API 17 | #endif 18 | 19 | /* 20 | * Return the message. 21 | */ 22 | MESSAGE_API std::string get_message(); 23 | -------------------------------------------------------------------------------- /cpp/swift-package-manager-publish/app/Sources/App/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/swift-package-manager-publish/app/Sources/App/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/swift-package-manager/Package.swift: -------------------------------------------------------------------------------- 1 | import PackageDescription 2 | 3 | let package = Package( 4 | name: "App", 5 | targets: [ 6 | Target(name: "List"), 7 | Target(name: "Utilities", dependencies: ["List"]), 8 | Target(name: "App", dependencies: ["Utilities"]) 9 | ] 10 | ) 11 | -------------------------------------------------------------------------------- /cpp/swift-package-manager/Sources/App/include/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #ifdef _WIN32 10 | # ifdef MESSAGE_MODULE_EXPORT 11 | # define MESSAGE_API __declspec(dllexport) 12 | # else 13 | # define MESSAGE_API __declspec(dllimport) 14 | # endif 15 | #else 16 | # define MESSAGE_API 17 | #endif 18 | 19 | /* 20 | * Return the message. 21 | */ 22 | MESSAGE_API std::string get_message(); 23 | -------------------------------------------------------------------------------- /cpp/swift-package-manager/Sources/App/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/swift-package-manager/Sources/App/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/swift-package-manager/Sources/List/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/swift-package-manager/Sources/List/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/swift-package-manager/Sources/List/include/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/swift-package-manager/Sources/List/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/swift-package-manager/Sources/Utilities/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/swift-package-manager/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/swift-package-manager/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/swift-package-manager/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'app', 'utilities', 'list' 2 | 3 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-application' 3 | } 4 | 5 | application { 6 | dependencies { 7 | implementation project(':utilities') 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/app/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/app/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /cpp/transitive-dependencies/app/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/list/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | } 4 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/list/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/list/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/list/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/list/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'app', 'utilities', 'list' 2 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/utilities/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | } 4 | 5 | library { 6 | dependencies { 7 | api project(':list') 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /cpp/transitive-dependencies/utilities/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/windows-resources/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /cpp/windows-resources/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /cpp/windows-resources/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "app" -------------------------------------------------------------------------------- /cpp/windows-resources/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpp/windows-resources/src/main/cpp/copy_ctor_assign.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | static void copy(const linked_list & source, linked_list * destination) { 6 | for (int i = 0; i < source.size(); ++i) { 7 | destination->add(source.get(i)); 8 | } 9 | } 10 | 11 | linked_list::linked_list(const linked_list & o) { 12 | head_ = NULL; 13 | copy(o, this); 14 | } 15 | 16 | linked_list & linked_list::operator=(const linked_list & rhs) { 17 | head_ = NULL; 18 | copy(rhs, this); 19 | return *this; 20 | } 21 | -------------------------------------------------------------------------------- /cpp/windows-resources/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpp/windows-resources/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /cpp/windows-resources/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cpp/windows-resources/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/windows-resources/src/main/headers/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /cpp/windows-resources/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp/windows-resources/src/main/headers/resources.h: -------------------------------------------------------------------------------- 1 | #define IDS_MESSAGE 42 2 | -------------------------------------------------------------------------------- /cpp/windows-resources/src/main/headers/string_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library of string utility functions. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include "linked_list.h" 10 | 11 | #define UTILITIES_API 12 | 13 | /* 14 | * Splits the given string into a list of tokens. Tokens are separated by one or more whitespace characters. 15 | */ 16 | UTILITIES_API linked_list split(const std::string & source); 17 | 18 | /* 19 | * Joins the list of tokens into a string, separated by space characters. 20 | */ 21 | UTILITIES_API std::string join(const linked_list & source); 22 | -------------------------------------------------------------------------------- /cpp/windows-resources/src/main/rc/resources.rc: -------------------------------------------------------------------------------- 1 | #include "resources.h" 2 | 3 | STRINGTABLE 4 | { 5 | IDS_MESSAGE, "Hello, World!" 6 | } 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/native-samples/99f9b825ecb0636d7fef75e1a21c0b0c1caadbcb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /samples-dev/.gitignore: -------------------------------------------------------------------------------- 1 | repos -------------------------------------------------------------------------------- /samples-dev/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /samples-dev/plugins/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "plugins" 2 | -------------------------------------------------------------------------------- /samples-dev/plugins/src/main/java/org/gradle/samples/plugins/SampleGeneratorTask.java: -------------------------------------------------------------------------------- 1 | package org.gradle.samples.plugins; 2 | 3 | import org.gradle.api.Task; 4 | import org.gradle.api.file.DirectoryProperty; 5 | 6 | /** 7 | * This is here to help migrate the plugins from Groovy to Kotlin. 8 | */ 9 | public interface SampleGeneratorTask extends Task { 10 | DirectoryProperty getTemplatesDir(); 11 | 12 | DirectoryProperty getSampleDir(); 13 | } 14 | -------------------------------------------------------------------------------- /samples-dev/plugins/src/main/java/org/gradle/samples/plugins/generators/GitRepoTask.java: -------------------------------------------------------------------------------- 1 | package org.gradle.samples.plugins.generators; 2 | 3 | public class GitRepoTask extends UpdateRepoTask { 4 | @Override 5 | boolean isDeleteRepo() { 6 | return true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /samples-dev/plugins/src/main/java/org/gradle/samples/plugins/generators/Template.java: -------------------------------------------------------------------------------- 1 | package org.gradle.samples.plugins.generators; 2 | 3 | public class Template { 4 | private final String templateName; 5 | 6 | public Template(String templateName) { 7 | this.templateName = templateName; 8 | } 9 | 10 | public static Template of(String templateName) { 11 | return new Template(templateName); 12 | } 13 | 14 | public final String getTemplateName() { 15 | return templateName; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples-dev/src/templates/build-root/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/REL_PATH/gradlew" "$@" 4 | -------------------------------------------------------------------------------- /samples-dev/src/templates/build-root/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call REL_PATH\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /samples-dev/src/templates/build-wrapper-plugin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "build-wrapper" 2 | -------------------------------------------------------------------------------- /samples-dev/src/templates/build-wrapper-plugin/src/main/java/org/gradle/samples/plugins/WrappedNativeBasePlugin.java: -------------------------------------------------------------------------------- 1 | package org.gradle.samples.plugins; 2 | 3 | import org.gradle.api.Plugin; 4 | import org.gradle.api.Project; 5 | 6 | public class WrappedNativeBasePlugin implements Plugin { 7 | @Override 8 | public void apply(Project project) { 9 | // Apply the base plugin, to define 'clean' task and other things 10 | project.getPluginManager().apply("lifecycle-base"); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /samples-dev/src/templates/c-app/src/main/c/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | printf("Hello, World!\n"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-ansi-console-lib/src/main/public/ansi_console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A logger that uses ANSI control sequences to generate color output. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | 8 | class ansi_console { 9 | public: 10 | ansi_console(); 11 | void color(const std::string & message); 12 | }; 13 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-app-check-published-macros/src/main/cpp/check_published_macros.cpp: -------------------------------------------------------------------------------- 1 | #ifndef FOOBAR 2 | # error "Macro not published or consumed correctly" 3 | #endif -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-app-cmake-build/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(app) 3 | 4 | add_executable(app 5 | src/app/main.cpp src/app/message.cpp) 6 | 7 | include_directories(${INCLUDE_DIRS}) 8 | 9 | find_library(LIST_LIB list PATHS ${LINK_DIRS}) 10 | find_library(UTILITIES_LIB utilities PATHS ${LINK_DIRS}) 11 | target_link_libraries(app ${LIST_LIB} ${UTILITIES_LIB}) 12 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-app-cmake-build/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | 3 | sourceControl { 4 | gitRepository("../build-wrapper-plugin") { 5 | producesModule("org.gradle.samples:build-wrapper") 6 | } 7 | gitRepository("../utilities") { 8 | producesModule("org.gradle.cpp-samples:utilities") 9 | } 10 | // This should not be required 11 | gitRepository("../list") { 12 | producesModule("org.gradle.cpp-samples:list") 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-app-precompiled-header/src/main/headers/pch.h: -------------------------------------------------------------------------------- 1 | #include "linked_list.h" 2 | #include "node.h" 3 | #include "message.h" -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-app-uses-logger/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "logger.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split("Hello, World!"); 13 | std::string result = join(tokens); 14 | logger logger; 15 | logger.info(result); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-app/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | #include 5 | 6 | #include "string_utils.h" 7 | #include "linked_list.h" 8 | #include "message.h" 9 | 10 | int main() { 11 | linked_list tokens; 12 | tokens = split(get_message()); 13 | std::cout << join(tokens) << std::endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-build-with-list-and-utilities-libraries/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | group = 'org.gradle.cpp-samples' 3 | version = '1.0' 4 | } 5 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-build-with-list-and-utilities-libraries/list/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | } 4 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-build-with-list-and-utilities-libraries/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'list' 2 | include 'utilities' 3 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-build-with-list-and-utilities-libraries/utilities/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | } 4 | 5 | library { 6 | dependencies { 7 | api project(':list') 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-lib-with-api-dep/src/main/cpp/join.cpp: -------------------------------------------------------------------------------- 1 | #define UTILITIES_MODULE_EXPORT 2 | #include "string_utils.h" 3 | 4 | #include "linked_list.h" 5 | 6 | UTILITIES_API std::string join(const linked_list & source) { 7 | std::string result; 8 | for (int i = 0; i < source.size(); ++i) { 9 | if (!result.empty()) { 10 | result.append(" "); 11 | } 12 | result.append(source.get(i)); 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-lib/src/main/cpp/add.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | 4 | #include "node.h" 5 | 6 | static node * tail(node * head) { 7 | node * it; 8 | 9 | for (it = head; it != NULL && it->next() != NULL; it = it->next()) {} 10 | 11 | return it; 12 | } 13 | 14 | void linked_list::add(const std::string & element) { 15 | node * new_node = new node(element); 16 | 17 | node * it = tail(head_); 18 | if (NULL == it) { 19 | head_ = new_node; 20 | } else { 21 | it->set_next(new_node); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-lib/src/main/cpp/destructor.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | linked_list::~linked_list() { 6 | for (node *it = head_; it != NULL;) { 7 | node *next_it = it->next(); 8 | delete it; 9 | it = next_it; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-lib/src/main/cpp/size.cpp: -------------------------------------------------------------------------------- 1 | #define LIST_MODULE_EXPORT 2 | #include "linked_list.h" 3 | #include "node.h" 4 | 5 | std::size_t linked_list::size() const { 6 | std::size_t size = 0; 7 | 8 | for (node * it = head_; it != NULL; ++size, it = it->next()) {} 9 | 10 | return size; 11 | } 12 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-lib/src/main/headers/node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class node { 6 | public: 7 | node(const std::string & data) : next_(NULL), data_(data) {} 8 | 9 | node * next() { return next_; } 10 | void set_next(node * next) { next_ = next; } 11 | 12 | std::string & data() { return data_; } 13 | private: 14 | std::string data_; 15 | node * next_; 16 | }; 17 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-list-lib-build-with-release/build.gradle: -------------------------------------------------------------------------------- 1 | // Currently cannot use the plugins { } block to reference plugins in included builds 2 | // Use the buildscript { } block instead 3 | buildscript { 4 | dependencies { 5 | classpath "org.gradle.samples:release:1.0" 6 | } 7 | } 8 | plugins { 9 | id 'cpp-library' 10 | } 11 | 12 | // Apply the release plugin explicitly as we can't use the plugins { } block 13 | apply plugin: 'org.gradle.samples.release' 14 | 15 | group = 'org.gradle.cpp-samples' 16 | version = '1.0.0' 17 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-list-lib-build-with-release/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'list' 2 | 3 | sourceControl { 4 | gitRepository("../release-plugin") { 5 | producesModule("org.gradle.samples:release") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-list-lib-build/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | } 4 | 5 | group = 'org.gradle.cpp-samples' 6 | version = '1.0' 7 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-list-lib-build/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'list' 2 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-list-lib-cmake-build/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(list) 3 | 4 | add_library(list 5 | src/list/add.cpp 6 | src/list/copy_ctor_assign.cpp 7 | src/list/destructor.cpp 8 | src/list/get.cpp 9 | src/list/remove.cpp 10 | src/list/size.cpp) 11 | 12 | target_include_directories(list PUBLIC src/list/include) 13 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-list-lib-cmake-build/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'list' 2 | 3 | sourceControl { 4 | gitRepository("../build-wrapper-plugin") { 5 | producesModule("org.gradle.samples:build-wrapper") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-logger-uses-console/src/main/cpp/logger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A logger that writes messages to a console. 3 | */ 4 | #include 5 | 6 | #ifdef _WIN32 7 | #include "win_console.h" 8 | #else 9 | #include "ansi_console.h" 10 | #endif 11 | #include "logger.h" 12 | 13 | logger::logger() { 14 | } 15 | 16 | void logger::info(const std::string & message) { 17 | #ifdef _WIN32 18 | win_console console; 19 | #else 20 | ansi_console console; 21 | #endif 22 | console.color(message); 23 | } 24 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-logger-uses-console/src/main/headers/logger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Writes log messages to some destination. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | 8 | class logger { 9 | public: 10 | logger(); 11 | 12 | // Writes an info message and trailing new-line 13 | void info(const std::string & message); 14 | }; 15 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-message-api/src/main/public/message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for the message. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define MESSAGE_API 10 | 11 | /* 12 | * Return the message. 13 | */ 14 | MESSAGE_API std::string get_message(); 15 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-message-resources/src/main/headers/resources.h: -------------------------------------------------------------------------------- 1 | #define IDS_MESSAGE 42 2 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-message-resources/src/main/rc/resources.rc: -------------------------------------------------------------------------------- 1 | #include "resources.h" 2 | 3 | STRINGTABLE 4 | { 5 | IDS_MESSAGE, "Hello, World!" 6 | } 7 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-message-static/src/main/cpp/message.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | 3 | std::string get_message() { 4 | return "Hello, World!"; 5 | } -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-provisionable-tool-chains-build/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-utilities-lib-build-with-release/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'utilities' 2 | 3 | sourceControl { 4 | gitRepository("../release-plugin") { 5 | producesModule("org.gradle.samples:release") 6 | } 7 | gitRepository("../list-library") { 8 | producesModule("org.gradle.cpp-samples:list") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-utilities-lib-build/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'cpp-library' 3 | } 4 | 5 | group = 'org.gradle.cpp-samples' 6 | version = '1.0' 7 | 8 | library { 9 | dependencies { 10 | api 'org.gradle.cpp-samples:list:1.0' 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-utilities-lib-build/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'utilities' 2 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-utilities-lib-cmake-build/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(utilities) 3 | 4 | add_library(utilities 5 | src/utilities/split.cpp 6 | src/utilities/join.cpp) 7 | 8 | target_include_directories(utilities PUBLIC src/utilities/include) 9 | include_directories(${INCLUDE_DIRS}) 10 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-utilities-lib-cmake-build/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'utilities' 2 | 3 | sourceControl { 4 | gitRepository("../build-wrapper-plugin") { 5 | producesModule("org.gradle.samples:build-wrapper") 6 | } 7 | gitRepository("../list") { 8 | producesModule("org.gradle.cpp-samples:list") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples-dev/src/templates/cpp-windows-console-lib/src/main/public/win_console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A logger that uses the Windows console to generate color output. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | 8 | #define WIN_CONSOLE_API 9 | 10 | class WIN_CONSOLE_API win_console { 11 | public: 12 | win_console(); 13 | void color(const std::string & message); 14 | }; 15 | -------------------------------------------------------------------------------- /samples-dev/src/templates/custom-publication-plugin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "custom-publication" 2 | -------------------------------------------------------------------------------- /samples-dev/src/templates/release-plugin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-gradle-plugin` 3 | } 4 | 5 | group = "org.gradle.samples" 6 | version = "1.0" 7 | 8 | gradlePlugin { 9 | (plugins) { 10 | register("release") { 11 | id = "org.gradle.samples.release" 12 | implementationClass = "org.gradle.samples.ReleasePlugin" 13 | } 14 | } 15 | } 16 | 17 | tasks.withType { 18 | // strictly compile the sample plugins 19 | options.compilerArgs.addAll(listOf("-Werror", "-Xlint:deprecation")) 20 | } 21 | -------------------------------------------------------------------------------- /samples-dev/src/templates/release-plugin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "release" 2 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-app-uses-logger/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | 5 | class App { 6 | class func normalize(_ s: String) -> String { 7 | let tokens = Util.split(s) 8 | return Util.join(tokens) 9 | } 10 | } 11 | 12 | let logger = Logger() 13 | let result = App.normalize(" Hello, World! ") 14 | logger.info(result) 15 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-app/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | import Utilities 5 | 6 | class App { 7 | class func normalize(_ s: String) -> String { 8 | let tokens = Util.split(s) 9 | return Util.join(tokens) 10 | } 11 | } 12 | 13 | let result = App.normalize(" Hello, World! ") 14 | print(result) 15 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-app/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-build-with-list-and-utilities-libraries/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | group = 'org.gradle.swift-samples' 3 | version = '1.0' 4 | } 5 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-build-with-list-and-utilities-libraries/list/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | id 'xcode' 4 | id 'xctest' 5 | } 6 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-build-with-list-and-utilities-libraries/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'list' 2 | include 'utilities' 3 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-build-with-list-and-utilities-libraries/utilities/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | id 'xcode' 4 | id 'xctest' 5 | } 6 | 7 | library { 8 | dependencies { 9 | api project(':list') 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-lib-unusable/src/main/swift/DoNotCompile.swift: -------------------------------------------------------------------------------- 1 | This doesn't compile. -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-lib/src/main/swift/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-linux-console-lib/src/main/swift/Console.swift: -------------------------------------------------------------------------------- 1 | #if os(Linux) 2 | import Glibc 3 | #endif 4 | 5 | public class Console { 6 | public init() { 7 | } 8 | 9 | // Writes the given string using color text, if connected to a console 10 | public func color(_ s: String) { 11 | #if os(Linux) 12 | if (isatty(1) != 0) { 13 | // green text 14 | print("\u{001B}[0;32m" + s + "\u{001B}[0m") 15 | return 16 | } 17 | #endif 18 | print(s) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-list-lib-build-with-release/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'list' 2 | 3 | sourceControl { 4 | gitRepository("../release-plugin") { 5 | producesModule("org.gradle.samples:release") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-list-lib-build/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | id 'xcode' 4 | id 'xctest' 5 | } 6 | 7 | group = 'org.gradle.swift-samples' 8 | version = '1.0' 9 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-list-lib-build/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'list' 2 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-logger-reports-swift-version/src/test/swift/LoggerTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import Logger 3 | 4 | class LoggerTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testLogsMessage", testLogsMessage), 7 | ] 8 | 9 | func testLogsMessage() { 10 | let logger = Logger() 11 | logger.info("some message") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-logger-uses-console/src/main/swift/Logger.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A logger that writes to the console. 3 | */ 4 | #if os(Linux) 5 | import LinuxConsole 6 | #else 7 | import MacOsConsole 8 | #endif 9 | 10 | class Logger { 11 | let console = Console() 12 | 13 | // Writes an info message and trailing new-line 14 | func info(_ s: String) { 15 | console.color(s) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-macos-console-lib/src/main/swift/Console.swift: -------------------------------------------------------------------------------- 1 | #if os(macOS) 2 | import Darwin 3 | #endif 4 | 5 | public class Console { 6 | public init() { 7 | } 8 | 9 | // Writes the given string using color text, if connected to a console 10 | public func color(_ s: String) { 11 | #if os(macOS) 12 | if (isatty(1) != 0) { 13 | // blue text 14 | print("\u{001B}[0;34m" + s + "\u{001B}[0m") 15 | return 16 | } 17 | #endif 18 | print(s) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-provisionable-tool-chains-build/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-utilities-lib-build-with-release/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'utilities' 2 | 3 | sourceControl { 4 | gitRepository("../release-plugin") { 5 | producesModule("org.gradle.samples:release") 6 | } 7 | gitRepository("../list-library") { 8 | producesModule("org.gradle.swift-samples:list") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-utilities-lib-build/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | id 'xcode' 4 | id 'xctest' 5 | } 6 | 7 | group = 'org.gradle.swift-samples' 8 | version = '1.0' 9 | 10 | library { 11 | dependencies { 12 | api 'org.gradle.swift-samples:list:1.0' 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples-dev/src/templates/swift-utilities-lib-build/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'utilities' 2 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | include("samples-dev") 2 | 3 | includeBuild("samples-dev/plugins") 4 | includeBuild("samples-dev/src/templates/custom-publication-plugin") 5 | includeBuild("samples-dev/src/templates/build-wrapper-plugin") 6 | includeBuild("samples-dev/src/templates/release-plugin") 7 | 8 | pluginManagement { 9 | resolutionStrategy { 10 | eachPlugin { 11 | if (requested.id.id.startsWith("org.gradle.samples.")) { 12 | useModule("org.gradle.samples.plugins:plugins:1.0") 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /swift/application/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-application' 3 | id 'xcode' 4 | id 'xctest' 5 | } 6 | -------------------------------------------------------------------------------- /swift/application/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/application/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/application/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | -------------------------------------------------------------------------------- /swift/application/src/main/swift/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /swift/application/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | 5 | class App { 6 | class func normalize(_ s: String) -> String { 7 | let tokens = Util.split(s) 8 | return Util.join(tokens) 9 | } 10 | } 11 | 12 | let result = App.normalize(" Hello, World! ") 13 | print(result) 14 | -------------------------------------------------------------------------------- /swift/application/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/application/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests), testCase(LinkedListTests.allTests), testCase(UtilTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/composite-build/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-application' 3 | id 'xctest' 4 | id 'xcode' 5 | } 6 | 7 | application { 8 | dependencies { 9 | implementation 'org.gradle.swift-samples:utilities:1.2' 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /swift/composite-build/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/composite-build/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/composite-build/list-library/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | id 'xctest' 4 | id 'xcode' 5 | } 6 | 7 | group = 'org.gradle.swift-samples' 8 | version = '1.5' 9 | -------------------------------------------------------------------------------- /swift/composite-build/list-library/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'list' 2 | -------------------------------------------------------------------------------- /swift/composite-build/list-library/src/main/swift/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /swift/composite-build/list-library/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(LinkedListTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/composite-build/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | 3 | includeBuild 'utilities-library' 4 | includeBuild 'list-library' 5 | -------------------------------------------------------------------------------- /swift/composite-build/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | import Utilities 5 | 6 | class App { 7 | class func normalize(_ s: String) -> String { 8 | let tokens = Util.split(s) 9 | return Util.join(tokens) 10 | } 11 | } 12 | 13 | let result = App.normalize(" Hello, World! ") 14 | print(result) 15 | -------------------------------------------------------------------------------- /swift/composite-build/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/composite-build/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/composite-build/utilities-library/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | id 'xctest' 4 | id 'xcode' 5 | } 6 | 7 | group = 'org.gradle.swift-samples' 8 | version = '1.2' 9 | 10 | library { 11 | dependencies { 12 | api 'org.gradle.swift-samples:list:1.5' 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /swift/composite-build/utilities-library/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'utilities' 2 | -------------------------------------------------------------------------------- /swift/composite-build/utilities-library/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(UtilTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/cpp-dependencies/app/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | plugins { 3 | id 'swift-application' 4 | id 'xctest' 5 | } 6 | 7 | application { 8 | dependencies { 9 | implementation project(':list') 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /swift/cpp-dependencies/app/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | 5 | class App { 6 | class func normalize(_ s: String) -> String { 7 | let tokens = Util.split(s) 8 | return Util.join(tokens) 9 | } 10 | } 11 | 12 | let result = App.normalize(" Hello, World! ") 13 | print(result) 14 | -------------------------------------------------------------------------------- /swift/cpp-dependencies/app/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/cpp-dependencies/app/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests), testCase(LinkedListTests.allTests), testCase(UtilTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/cpp-dependencies/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | apply plugin: 'xcode' 3 | 4 | group = 'org.gradle.swift-samples' 5 | } 6 | -------------------------------------------------------------------------------- /swift/cpp-dependencies/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/cpp-dependencies/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/cpp-dependencies/list/build.gradle: -------------------------------------------------------------------------------- 1 | apply from: 'common.gradle' 2 | -------------------------------------------------------------------------------- /swift/cpp-dependencies/list/common.gradle: -------------------------------------------------------------------------------- 1 | // Any configuration common to both the shared and static variants of this library 2 | 3 | apply plugin: 'cpp-library' 4 | -------------------------------------------------------------------------------- /swift/cpp-dependencies/listStatic/build.gradle: -------------------------------------------------------------------------------- 1 | apply from: project(':list').file('common.gradle') 2 | 3 | library { 4 | linkage = [ Linkage.STATIC ] 5 | source.from project(':list').file('src/main/cpp') 6 | publicHeaders.from project(':list').file('src/main/public') 7 | } 8 | -------------------------------------------------------------------------------- /swift/cpp-dependencies/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'app', 'list', 'listStatic' 2 | -------------------------------------------------------------------------------- /swift/dependency-on-upstream-branch/.gitignore: -------------------------------------------------------------------------------- 1 | list-library/ 2 | utilities-library/ 3 | -------------------------------------------------------------------------------- /swift/dependency-on-upstream-branch/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-application' 3 | id 'xcode' 4 | id 'xctest' 5 | } 6 | 7 | group = 'org.gradle.swift-samples' 8 | 9 | application { 10 | dependencies { 11 | implementation('org.gradle.swift-samples:utilities') { 12 | version { 13 | branch = 'release' 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/dependency-on-upstream-branch/app/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/dependency-on-upstream-branch/app/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/dependency-on-upstream-branch/app/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | 3 | sourceControl { 4 | gitRepository("../utilities-library") { 5 | producesModule("org.gradle.swift-samples:utilities") 6 | } 7 | gitRepository("../list-library") { 8 | producesModule("org.gradle.swift-samples:list") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /swift/dependency-on-upstream-branch/app/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | import Utilities 5 | 6 | class App { 7 | class func normalize(_ s: String) -> String { 8 | let tokens = Util.split(s) 9 | return Util.join(tokens) 10 | } 11 | } 12 | 13 | let result = App.normalize(" Hello, World! ") 14 | print(result) 15 | -------------------------------------------------------------------------------- /swift/dependency-on-upstream-branch/app/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/dependency-on-upstream-branch/app/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/injected-plugins/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-application' 3 | id 'xcode' 4 | id 'xctest' 5 | } 6 | 7 | group = 'org.gradle.swift-samples' 8 | 9 | application { 10 | dependencies { 11 | implementation 'org.gradle.swift-samples:utilities:latest.integration' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /swift/injected-plugins/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/injected-plugins/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/injected-plugins/plugins/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'groovy' 3 | id 'java-gradle-plugin' 4 | } 5 | 6 | gradlePlugin { 7 | plugins { 8 | "utilities-build" { 9 | id = "utilities-build" 10 | implementationClass = "org.gradle.swift.samples.UtilitiesBuildPlugin" 11 | } 12 | "list-build" { 13 | id = "list-build" 14 | implementationClass = "org.gradle.swift.samples.ListBuildPlugin" 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/injected-plugins/plugins/settings.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/native-samples/99f9b825ecb0636d7fef75e1a21c0b0c1caadbcb/swift/injected-plugins/plugins/settings.gradle -------------------------------------------------------------------------------- /swift/injected-plugins/plugins/src/main/groovy/org/gradle/swift/samples/CommonPlugin.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.swift.samples 2 | 3 | import org.gradle.api.* 4 | 5 | class CommonPlugin implements Plugin { 6 | void apply(Project project) { 7 | project.allprojects { 8 | apply plugin: 'swift-library' 9 | apply plugin: 'xcode' 10 | apply plugin: 'xctest' 11 | 12 | group = 'org.gradle.swift-samples' 13 | version = '1.0-SNAPSHOT' 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /swift/injected-plugins/plugins/src/main/groovy/org/gradle/swift/samples/GenerateSource.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.swift.samples 2 | 3 | import org.gradle.api.* 4 | import org.gradle.api.tasks.* 5 | 6 | class GenerateSource extends DefaultTask { 7 | @Input 8 | String sourceFile 9 | 10 | @OutputFile 11 | File outputFile = new File(temporaryDir, "Generated.swift") 12 | 13 | @TaskAction 14 | void generate() { 15 | // Simple source code generator 16 | outputFile.text = sourceFile 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /swift/injected-plugins/repos/.gitignore: -------------------------------------------------------------------------------- 1 | list-library/ 2 | utilities-library/ 3 | -------------------------------------------------------------------------------- /swift/injected-plugins/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | 3 | includeBuild("plugins") 4 | 5 | sourceControl { 6 | gitRepository("repos/utilities-library") { 7 | producesModule("org.gradle.swift-samples:utilities") 8 | plugins { 9 | id "utilities-build" 10 | } 11 | } 12 | gitRepository("repos/list-library") { 13 | producesModule("org.gradle.swift-samples:list") 14 | plugins { 15 | id "list-build" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /swift/injected-plugins/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | import Utilities 5 | 6 | class App { 7 | class func normalize(_ s: String) -> String { 8 | let tokens = Util.split(s) 9 | return Util.join(tokens) 10 | } 11 | } 12 | 13 | let result = App.normalize(" Hello, World! ") 14 | print(result) 15 | -------------------------------------------------------------------------------- /swift/injected-plugins/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/injected-plugins/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/ios-application/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-application' 3 | id 'org.gradle.samples.ios-application' version '1.0' 4 | id 'xcode' 5 | } 6 | 7 | group = "org.gradle.samples" 8 | -------------------------------------------------------------------------------- /swift/ios-application/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/ios-application/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/ios-application/ios-plugin/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/ios-application/ios-plugin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/ios-application/ios-plugin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "ios-plugin" -------------------------------------------------------------------------------- /swift/ios-application/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | 3 | includeBuild 'ios-plugin' -------------------------------------------------------------------------------- /swift/multiple-target-machines/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "swift-application" 3 | id "xcode" 4 | } 5 | 6 | application { 7 | targetMachines = [ 8 | machines.macOS.x86_64, 9 | machines.linux.x86_64 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /swift/multiple-target-machines/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/multiple-target-machines/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/multiple-target-machines/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "app" -------------------------------------------------------------------------------- /swift/multiple-target-machines/src/main/swift/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /swift/multiple-target-machines/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | 5 | class App { 6 | class func normalize(_ s: String) -> String { 7 | let tokens = Util.split(s) 8 | return Util.join(tokens) 9 | } 10 | } 11 | 12 | let result = App.normalize(" Hello, World! ") 13 | print(result) 14 | -------------------------------------------------------------------------------- /swift/multiple-target-machines/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/multiple-target-machines/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests), testCase(LinkedListTests.allTests), testCase(UtilTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-application' 3 | } 4 | 5 | application { 6 | targetMachines = [ 7 | machines.linux, 8 | machines.macOS 9 | ] 10 | binaries.configureEach { 11 | dependencies { 12 | if (targetMachine.operatingSystemFamily.macOs) { 13 | implementation project(':macos-console') 14 | } else { 15 | implementation project(':linux-console') 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/app/src/main/swift/Logger.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A logger that writes to the console. 3 | */ 4 | #if os(Linux) 5 | import LinuxConsole 6 | #else 7 | import MacOsConsole 8 | #endif 9 | 10 | class Logger { 11 | let console = Console() 12 | 13 | // Writes an info message and trailing new-line 14 | func info(_ s: String) { 15 | console.color(s) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/app/src/main/swift/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/app/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | 5 | class App { 6 | class func normalize(_ s: String) -> String { 7 | let tokens = Util.split(s) 8 | return Util.join(tokens) 9 | } 10 | } 11 | 12 | let logger = Logger() 13 | let result = App.normalize(" Hello, World! ") 14 | logger.info(result) 15 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/app/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/app/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests), testCase(LinkedListTests.allTests), testCase(UtilTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | apply plugin: 'xcode' 3 | } 4 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/linux-console/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | } 4 | 5 | library { 6 | module = "LinuxConsole" 7 | targetMachines = [ 8 | machines.linux 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/linux-console/src/main/swift/Console.swift: -------------------------------------------------------------------------------- 1 | #if os(Linux) 2 | import Glibc 3 | #endif 4 | 5 | public class Console { 6 | public init() { 7 | } 8 | 9 | // Writes the given string using color text, if connected to a console 10 | public func color(_ s: String) { 11 | #if os(Linux) 12 | if (isatty(1) != 0) { 13 | // green text 14 | print("\u{001B}[0;32m" + s + "\u{001B}[0m") 15 | return 16 | } 17 | #endif 18 | print(s) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/macos-console/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | } 4 | 5 | library { 6 | module = "MacOsConsole" 7 | targetMachines = [ 8 | machines.macOS 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/macos-console/src/main/swift/Console.swift: -------------------------------------------------------------------------------- 1 | #if os(macOS) 2 | import Darwin 3 | #endif 4 | 5 | public class Console { 6 | public init() { 7 | } 8 | 9 | // Writes the given string using color text, if connected to a console 10 | public func color(_ s: String) { 11 | #if os(macOS) 12 | if (isatty(1) != 0) { 13 | // blue text 14 | print("\u{001B}[0;34m" + s + "\u{001B}[0m") 15 | return 16 | } 17 | #endif 18 | print(s) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /swift/operating-system-specific-dependencies/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'osDeps' 2 | 3 | include 'app', 'linux-console', 'macos-console' 4 | -------------------------------------------------------------------------------- /swift/prebuilt-binaries/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/prebuilt-binaries/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/prebuilt-binaries/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | -------------------------------------------------------------------------------- /swift/prebuilt-binaries/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | 5 | class App { 6 | class func normalize(_ s: String) -> String { 7 | let tokens = Util.split(s) 8 | return Util.join(tokens) 9 | } 10 | } 11 | 12 | let result = App.normalize(" Hello, World! ") 13 | print(result) 14 | -------------------------------------------------------------------------------- /swift/prebuilt-binaries/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/prebuilt-binaries/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests), testCase(UtilTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/provisionable-tool-chains/build.gradle: -------------------------------------------------------------------------------- 1 | // Currently cannot use the plugins { } block to reference plugins with software model elements 2 | // Use the `apply plugin:` instead 3 | apply plugin: 'swift-application' 4 | apply plugin: 'xcode' 5 | 6 | model { 7 | toolChains { 8 | provisionedSwift(Swiftc) { 9 | path rootProject.file('buildSrc/build/toolChains/swift-4.0.3/usr/bin') 10 | 11 | // Required to locate dsymutil on macOS and objcopy on Linux 12 | path System.getenv('PATH').split(':') 13 | } 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /swift/provisionable-tool-chains/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/provisionable-tool-chains/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/provisionable-tool-chains/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' -------------------------------------------------------------------------------- /swift/provisionable-tool-chains/src/main/swift/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /swift/provisionable-tool-chains/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | 5 | class App { 6 | class func normalize(_ s: String) -> String { 7 | let tokens = Util.split(s) 8 | return Util.join(tokens) 9 | } 10 | } 11 | 12 | let result = App.normalize(" Hello, World! ") 13 | print(result) 14 | -------------------------------------------------------------------------------- /swift/provisionable-tool-chains/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/provisionable-tool-chains/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests), testCase(LinkedListTests.allTests), testCase(UtilTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/simple-library/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | id 'xcode' 4 | id 'xctest' 5 | } 6 | 7 | group = 'org.gradle.swift-samples' 8 | -------------------------------------------------------------------------------- /swift/simple-library/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/simple-library/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/simple-library/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'list' 2 | -------------------------------------------------------------------------------- /swift/simple-library/src/main/swift/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /swift/simple-library/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(LinkedListTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/source-dependencies/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-application' 3 | id 'xcode' 4 | id 'xctest' 5 | } 6 | 7 | group = 'org.gradle.swift-samples' 8 | 9 | application { 10 | dependencies { 11 | implementation 'org.gradle.swift-samples:utilities:1.0' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /swift/source-dependencies/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/source-dependencies/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/source-dependencies/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | 3 | sourceControl { 4 | gitRepository("https://github.com/gradle/native-samples-swift-library.git") { 5 | producesModule("org.gradle.swift-samples:utilities") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /swift/source-dependencies/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | import Utilities 5 | 6 | class App { 7 | class func normalize(_ s: String) -> String { 8 | let tokens = Util.split(s) 9 | return Util.join(tokens) 10 | } 11 | } 12 | 13 | let result = App.normalize(" Hello, World! ") 14 | print(result) 15 | -------------------------------------------------------------------------------- /swift/source-dependencies/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/source-dependencies/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/source-generation/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/source-generation/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/source-generation/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | -------------------------------------------------------------------------------- /swift/static-library/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-application' 3 | id 'xctest' 4 | } 5 | 6 | application { 7 | dependencies { 8 | implementation project(':utilities') 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /swift/static-library/app/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | import Utilities 5 | 6 | class App { 7 | class func normalize(_ s: String) -> String { 8 | let tokens = Util.split(s) 9 | return Util.join(tokens) 10 | } 11 | } 12 | 13 | let result = App.normalize(" Hello, World! ") 14 | print(result) 15 | -------------------------------------------------------------------------------- /swift/static-library/app/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/static-library/app/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/static-library/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | apply plugin: "xcode" 3 | 4 | group = 'org.gradle.swift-samples' 5 | } 6 | -------------------------------------------------------------------------------- /swift/static-library/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/static-library/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/static-library/list/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | id 'xctest' 4 | } 5 | 6 | library { 7 | linkage = [Linkage.SHARED] 8 | } 9 | -------------------------------------------------------------------------------- /swift/static-library/list/src/main/swift/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /swift/static-library/list/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(LinkedListTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/static-library/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'app', 'utilities', 'list' 2 | -------------------------------------------------------------------------------- /swift/static-library/utilities/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | id 'xctest' 4 | } 5 | 6 | library { 7 | linkage = [Linkage.STATIC] 8 | 9 | dependencies { 10 | api project(':list') 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /swift/static-library/utilities/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(UtilTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/swift-package-manager-publish/.gitignore: -------------------------------------------------------------------------------- 1 | list-library/ 2 | release-plugin/ 3 | utilities-library/ 4 | -------------------------------------------------------------------------------- /swift/swift-package-manager-publish/app/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:4.0 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "App", 7 | dependencies: [ 8 | .package(url: "../utilities-library", from: "1.0.0") 9 | ], 10 | targets: [ 11 | .target( 12 | name: "App", 13 | dependencies: [ 14 | .product(name: "utilities") 15 | ] 16 | ), 17 | .testTarget(name: "AppTests") 18 | ] 19 | ) 20 | -------------------------------------------------------------------------------- /swift/swift-package-manager-publish/app/Sources/App/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | import Utilities 5 | 6 | class App { 7 | class func normalize(_ s: String) -> String { 8 | let tokens = Util.split(s) 9 | return Util.join(tokens) 10 | } 11 | } 12 | 13 | let result = App.normalize(" Hello, World! ") 14 | print(result) 15 | -------------------------------------------------------------------------------- /swift/swift-package-manager-publish/app/Tests/AppTests/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/swift-package-manager-publish/app/Tests/AppTests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/swift-package-manager-publish/app/Tests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import AppTests 3 | 4 | XCTMain([testCase(AppTests.allTests)]) 5 | -------------------------------------------------------------------------------- /swift/swift-package-manager/Package.swift: -------------------------------------------------------------------------------- 1 | import PackageDescription 2 | 3 | let package = Package( 4 | name: "App", 5 | targets: [ 6 | Target(name: "List"), 7 | Target(name: "Utilities", dependencies: ["List"]), 8 | Target(name: "App", dependencies: ["Utilities"]), 9 | Target(name: "ListTests"), 10 | Target(name: "UtilitiesTests") 11 | ] 12 | ) -------------------------------------------------------------------------------- /swift/swift-package-manager/Sources/App/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | import Utilities 5 | 6 | class App { 7 | class func normalize(_ s: String) -> String { 8 | let tokens = Util.split(s) 9 | return Util.join(tokens) 10 | } 11 | } 12 | 13 | let result = App.normalize(" Hello, World! ") 14 | print(result) 15 | -------------------------------------------------------------------------------- /swift/swift-package-manager/Sources/List/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /swift/swift-package-manager/Tests/AppTests/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/swift-package-manager/Tests/AppTests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/swift-package-manager/Tests/ListTests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(LinkedListTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/swift-package-manager/Tests/UtilitiesTests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(UtilTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/swift-package-manager/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/swift-package-manager/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/swift-package-manager/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'app', 'utilities', 'list' 2 | -------------------------------------------------------------------------------- /swift/swift-versions/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | apply plugin: 'xcode' 3 | } 4 | 5 | subprojects { 6 | apply plugin: 'swift-application' 7 | apply plugin: 'xctest' 8 | 9 | application { 10 | module = 'App' 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /swift/swift-versions/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/swift-versions/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/swift-versions/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':swift3-app', ':swift4-app', ':swift5-app' 2 | -------------------------------------------------------------------------------- /swift/swift-versions/swift3-app/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | application { 3 | sourceCompatibility = SwiftVersion.SWIFT3 4 | } 5 | -------------------------------------------------------------------------------- /swift/swift-versions/swift3-app/src/main/swift/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /swift/swift-versions/swift3-app/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | 5 | class App { 6 | class func normalize(_ s: String) -> String { 7 | let tokens = Util.split(s) 8 | return Util.join(tokens) 9 | } 10 | } 11 | 12 | let logger = Logger() 13 | let result = App.normalize(" Hello, World! ") 14 | logger.info(result) 15 | -------------------------------------------------------------------------------- /swift/swift-versions/swift3-app/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/swift-versions/swift3-app/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests), testCase(LinkedListTests.allTests), testCase(LoggerTests.allTests), testCase(UtilTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/swift-versions/swift3-app/src/test/swift/LoggerTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class LoggerTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testLogsMessage", testLogsMessage), 7 | ] 8 | 9 | func testLogsMessage() { 10 | let logger = Logger() 11 | logger.info("some message") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /swift/swift-versions/swift4-app/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | application { 3 | sourceCompatibility = SwiftVersion.SWIFT4 4 | } 5 | -------------------------------------------------------------------------------- /swift/swift-versions/swift4-app/src/main/swift/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /swift/swift-versions/swift4-app/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | 5 | class App { 6 | class func normalize(_ s: String) -> String { 7 | let tokens = Util.split(s) 8 | return Util.join(tokens) 9 | } 10 | } 11 | 12 | let logger = Logger() 13 | let result = App.normalize(" Hello, World! ") 14 | logger.info(result) 15 | -------------------------------------------------------------------------------- /swift/swift-versions/swift4-app/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/swift-versions/swift4-app/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests), testCase(LinkedListTests.allTests), testCase(LoggerTests.allTests), testCase(UtilTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/swift-versions/swift4-app/src/test/swift/LoggerTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class LoggerTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testLogsMessage", testLogsMessage), 7 | ] 8 | 9 | func testLogsMessage() { 10 | let logger = Logger() 11 | logger.info("some message") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /swift/swift-versions/swift5-app/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | application { 3 | sourceCompatibility = SwiftVersion.SWIFT5 4 | } 5 | -------------------------------------------------------------------------------- /swift/swift-versions/swift5-app/src/main/swift/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /swift/swift-versions/swift5-app/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | 5 | class App { 6 | class func normalize(_ s: String) -> String { 7 | let tokens = Util.split(s) 8 | return Util.join(tokens) 9 | } 10 | } 11 | 12 | let logger = Logger() 13 | let result = App.normalize(" Hello, World! ") 14 | logger.info(result) 15 | -------------------------------------------------------------------------------- /swift/swift-versions/swift5-app/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/swift-versions/swift5-app/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests), testCase(LinkedListTests.allTests), testCase(LoggerTests.allTests), testCase(UtilTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/swift-versions/swift5-app/src/test/swift/LoggerTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class LoggerTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testLogsMessage", testLogsMessage), 7 | ] 8 | 9 | func testLogsMessage() { 10 | let logger = Logger() 11 | logger.info("some message") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /swift/system-library-as-module/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | plugins { 3 | id 'swift-application' 4 | id 'xcode' 5 | } 6 | 7 | components.withType(SwiftBinary) { binary -> 8 | project.dependencies { 9 | add(binary.importPathConfiguration.name, files("curl")) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /swift/system-library-as-module/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/system-library-as-module/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/system-library-as-module/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'app' 2 | 3 | -------------------------------------------------------------------------------- /swift/system-library-as-module/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | import CCurl 2 | 3 | let handle = curl_easy_init() 4 | 5 | curlHelperSetOptString(handle, CURLOPT_URL, "http://www.example.com") 6 | curlHelperSetOptBool(handle, CURLOPT_VERBOSE, CURL_TRUE) 7 | 8 | let ret = curl_easy_perform(handle) 9 | let error = curl_easy_strerror(ret) 10 | 11 | print("error = \(error)") 12 | print("ret = \(ret)") 13 | -------------------------------------------------------------------------------- /swift/transitive-dependencies/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-application' 3 | id 'xctest' 4 | } 5 | 6 | application { 7 | dependencies { 8 | implementation project(':utilities') 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /swift/transitive-dependencies/app/src/main/swift/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * A simple hello world application. Uses a library to tokenize and join a string and prints the result. 3 | */ 4 | import Utilities 5 | 6 | class App { 7 | class func normalize(_ s: String) -> String { 8 | let tokens = Util.split(s) 9 | return Util.join(tokens) 10 | } 11 | } 12 | 13 | let result = App.normalize(" Hello, World! ") 14 | print(result) 15 | -------------------------------------------------------------------------------- /swift/transitive-dependencies/app/src/test/swift/AppTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import App 3 | 4 | class AppTests: XCTestCase { 5 | public static var allTests = [ 6 | ("testNormalizeEmpty", testNormalizeEmpty), 7 | ("testNormalize", testNormalize), 8 | ] 9 | 10 | func testNormalizeEmpty() { 11 | XCTAssertEqual("", App.normalize("")) 12 | } 13 | 14 | func testNormalize() { 15 | XCTAssertEqual("abc def", App.normalize(" abc def ")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /swift/transitive-dependencies/app/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(AppTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/transitive-dependencies/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | exec "$(dirname "$0")/../../gradlew" "$@" 4 | -------------------------------------------------------------------------------- /swift/transitive-dependencies/gradlew.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call ..\..\gradlew.bat %* 3 | -------------------------------------------------------------------------------- /swift/transitive-dependencies/list/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | id 'xctest' 4 | } 5 | -------------------------------------------------------------------------------- /swift/transitive-dependencies/list/src/main/swift/Node.swift: -------------------------------------------------------------------------------- 1 | // A linked list node 2 | class Node { 3 | let data: String 4 | var next: Node? 5 | 6 | init(data: String) { 7 | self.data = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /swift/transitive-dependencies/list/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(LinkedListTests.allTests)]) 4 | -------------------------------------------------------------------------------- /swift/transitive-dependencies/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'app', 'utilities', 'list' 2 | -------------------------------------------------------------------------------- /swift/transitive-dependencies/utilities/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'swift-library' 3 | id 'xctest' 4 | } 5 | 6 | library { 7 | dependencies { 8 | api project(':list') 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /swift/transitive-dependencies/utilities/src/test/swift/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | XCTMain([testCase(UtilTests.allTests)]) 4 | --------------------------------------------------------------------------------