├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE.txt ├── README.md ├── build.gradle ├── gradle.properties ├── gradle ├── common.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lightsaber ├── build.gradle ├── core-kotlin │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── joom │ │ └── lightsaber │ │ └── InjectorExtensions.kt ├── core-test │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ ├── AnnotationBuilder.java │ │ │ ├── AnnotationInvocationHandler.java │ │ │ └── ProviderInterceptorBuilder.java │ │ └── test │ │ └── java │ │ └── com │ │ └── joom │ │ └── lightsaber │ │ ├── AnnotationBuilderTest.java │ │ └── ProviderInterceptorBuilderTest.java ├── core │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ ├── Component.java │ │ │ ├── ConfigurationException.java │ │ │ ├── Contract.java │ │ │ ├── ContractConfiguration.java │ │ │ ├── Eager.java │ │ │ ├── Factory.java │ │ │ ├── Import.java │ │ │ ├── ImportedBy.java │ │ │ ├── Injector.java │ │ │ ├── Key.java │ │ │ ├── Lazy.java │ │ │ ├── LazyAdapter.java │ │ │ ├── Lightsaber.java │ │ │ ├── Module.java │ │ │ ├── Provide.java │ │ │ ├── ProvidedAs.java │ │ │ ├── ProvidedBy.java │ │ │ ├── ProviderInterceptor.java │ │ │ └── internal │ │ │ ├── ContractCreator.java │ │ │ ├── GenericArrayTypeImpl.java │ │ │ ├── InjectorConfigurator.java │ │ │ ├── IterableMap.java │ │ │ ├── LightsaberInjector.java │ │ │ ├── LightweightHashMap.java │ │ │ ├── MapIterator.java │ │ │ ├── MembersInjector.java │ │ │ ├── ParameterizedTypeImpl.java │ │ │ ├── PolymorphicKeyHashMap.java │ │ │ ├── SingletonProvider.java │ │ │ ├── TypeUtils.java │ │ │ └── WildcardTypeImpl.java │ │ └── test │ │ └── java │ │ └── com │ │ └── joom │ │ └── lightsaber │ │ ├── LightsaberGenericTest.java │ │ ├── LightsaberTest.java │ │ ├── TypeReference.java │ │ └── internal │ │ ├── GenericArrayTypeImplTest.java │ │ ├── NamedType.java │ │ └── ParameterizedTypeImplTest.java ├── gradle-plugin │ ├── .gitignore │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ └── plugin │ │ │ ├── AllClassesTransformRegistrar.kt │ │ │ ├── AndroidLightsaberPlugin.kt │ │ │ ├── AndroidLightsaberPluginExtension.kt │ │ │ ├── BackupClassesTask.kt │ │ │ ├── BaseLightsaberPlugin.kt │ │ │ ├── CollectionExtensions.kt │ │ │ ├── Flags.kt │ │ │ ├── GradleExtensions.kt │ │ │ ├── JavaLightsaberPlugin.kt │ │ │ ├── JavaLightsaberPluginExtension.kt │ │ │ ├── LightsaberSharedBuildCacheService.kt │ │ │ ├── LightsaberTask.kt │ │ │ ├── LightsaberTransform.kt │ │ │ ├── LightsaberTransformTask.kt │ │ │ ├── PluginVersion.kt │ │ │ ├── ScopedArtifactsRegistrar.kt │ │ │ └── TransformTaskRegistrar.kt │ │ └── resources │ │ └── META-INF │ │ └── gradle-plugins │ │ ├── com.joom.lightsaber.android.properties │ │ └── com.joom.lightsaber.properties ├── gradle.properties ├── pablo.gradle ├── processor │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ ├── LightsaberTypes.kt │ │ │ └── processor │ │ │ ├── CachedGripFactory.kt │ │ │ ├── ClassProcessor.kt │ │ │ ├── DebugReport.kt │ │ │ ├── ErrorReporter.kt │ │ │ ├── FileSinkFactory.kt │ │ │ ├── JvmRuntimeUtil.kt │ │ │ ├── LightsaberOutput.kt │ │ │ ├── LightsaberOutputFactory.kt │ │ │ ├── LightsaberParameters.kt │ │ │ ├── LightsaberProcessor.kt │ │ │ ├── LightsaberSharedBuildCache.kt │ │ │ ├── ProcessingException.kt │ │ │ ├── analysis │ │ │ ├── Analyzer.kt │ │ │ ├── AnalyzerHelper.kt │ │ │ ├── BindingRegistry.kt │ │ │ ├── BindingsAnalyzer.kt │ │ │ ├── BridgeRegistry.kt │ │ │ ├── ComponentsAnalyzer.kt │ │ │ ├── ContractAnalyzer.kt │ │ │ ├── ContractConfigurationAnalyzer.kt │ │ │ ├── ContractParser.kt │ │ │ ├── ExternalSetupAnalyzer.kt │ │ │ ├── FactoriesAnalyzer.kt │ │ │ ├── FactoryParser.kt │ │ │ ├── ImportParser.kt │ │ │ ├── InjectionTargetsAnalyzer.kt │ │ │ ├── ModuleAnalyzer.kt │ │ │ ├── ModuleParser.kt │ │ │ ├── ProvisionPointFactory.kt │ │ │ ├── ScopeRegistry.kt │ │ │ └── SourceResolver.kt │ │ │ ├── annotations │ │ │ └── proxy │ │ │ │ ├── AnnotationCreator.kt │ │ │ │ └── AnnotationProxyGenerator.kt │ │ │ ├── commons │ │ │ ├── AccessFlagStringifier.kt │ │ │ ├── AnyExtensions.kt │ │ │ ├── Arrays.kt │ │ │ ├── ClassVisitorExtensions.kt │ │ │ ├── CloseableExtensions.kt │ │ │ ├── CollectionsExtensions.kt │ │ │ ├── CompositeAnnotationVisitor.kt │ │ │ ├── CompositeClassVisitor.kt │ │ │ ├── CompositeFieldVisitor.kt │ │ │ ├── CompositeMethodVisitor.kt │ │ │ ├── CompositeVisitor.kt │ │ │ ├── DependencyExtensions.kt │ │ │ ├── Descriptions.kt │ │ │ ├── GeneratorAdapter.kt │ │ │ ├── GeneratorAdapterExtensions.kt │ │ │ ├── GenericTypeExtensions.kt │ │ │ ├── GripExtensions.kt │ │ │ ├── InjecteeExtensions.kt │ │ │ ├── InjectionPointExtensions.kt │ │ │ ├── IntExtensions.kt │ │ │ ├── IterableExtensions.kt │ │ │ ├── MapExtensions.kt │ │ │ ├── Methods.kt │ │ │ ├── MirrorsExtensions.kt │ │ │ ├── ProvisionPointExtensions.kt │ │ │ ├── StandaloneClassWriter.kt │ │ │ └── Types.kt │ │ │ ├── descriptors │ │ │ ├── FieldDescriptor.kt │ │ │ └── MethodDescriptor.kt │ │ │ ├── generation │ │ │ ├── ClassProducer.kt │ │ │ ├── ContractClassGenerator.kt │ │ │ ├── ContractsGenerator.kt │ │ │ ├── FactoriesGenerator.kt │ │ │ ├── FactoryClassGenerator.kt │ │ │ ├── GenerationContextFactory.kt │ │ │ ├── Generator.kt │ │ │ ├── GeneratorAdapterExtensions.kt │ │ │ ├── KeyRegistryClassGenerator.kt │ │ │ ├── PackageInvaderClassGenerator.kt │ │ │ ├── PackageInvadersGenerator.kt │ │ │ ├── ProcessorClassProducer.kt │ │ │ ├── ProviderClassGenerator.kt │ │ │ ├── ProvidersGenerator.kt │ │ │ └── model │ │ │ │ ├── GenerationContext.kt │ │ │ │ ├── Key.kt │ │ │ │ ├── KeyRegistry.kt │ │ │ │ ├── PackageInvader.kt │ │ │ │ ├── Provider.kt │ │ │ │ ├── ProviderFactory.kt │ │ │ │ └── ProviderMedium.kt │ │ │ ├── graph │ │ │ ├── CycleSearcher.kt │ │ │ ├── DirectedGraph.kt │ │ │ ├── GraphExtensions.kt │ │ │ ├── HashDirectedGraph.kt │ │ │ └── Traversals.kt │ │ │ ├── injection │ │ │ ├── BaseInjectionClassVisitor.kt │ │ │ ├── ContractConfigurationPatcher.kt │ │ │ ├── FactoryInjectionPointPatcher.kt │ │ │ ├── InjectableTargetPatcher.kt │ │ │ ├── ModulePatcher.kt │ │ │ ├── Patcher.kt │ │ │ └── ProvidableTargetPatcher.kt │ │ │ ├── logging │ │ │ └── LoggerExtensions.kt │ │ │ ├── model │ │ │ ├── Binding.kt │ │ │ ├── Component.kt │ │ │ ├── Contract.kt │ │ │ ├── ContractConfiguration.kt │ │ │ ├── ContractProvisionPoint.kt │ │ │ ├── Converter.kt │ │ │ ├── Dependency.kt │ │ │ ├── ExternalSetup.kt │ │ │ ├── Factory.kt │ │ │ ├── FactoryInjectee.kt │ │ │ ├── FactoryInjectionPoint.kt │ │ │ ├── FactoryProvisionPoint.kt │ │ │ ├── Import.kt │ │ │ ├── ImportPoint.kt │ │ │ ├── Injectee.kt │ │ │ ├── InjectionContext.kt │ │ │ ├── InjectionPoint.kt │ │ │ ├── InjectionTarget.kt │ │ │ ├── Module.kt │ │ │ ├── ProvisionPoint.kt │ │ │ └── Scope.kt │ │ │ ├── validation │ │ │ ├── ComponentGraph.kt │ │ │ ├── DependencyResolver.kt │ │ │ ├── DependencyResolverFactory.kt │ │ │ ├── DependencyResolverPath.kt │ │ │ ├── DependencyResolverPathSegment.kt │ │ │ ├── HintsBuilder.kt │ │ │ ├── SanityChecker.kt │ │ │ ├── UnusedImportsCalculator.kt │ │ │ ├── UsageValidator.kt │ │ │ └── Validator.kt │ │ │ └── watermark │ │ │ ├── LightsaberAttribute.kt │ │ │ ├── WatermarkChecker.kt │ │ │ └── WatermarkClassVisitor.kt │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ └── processor │ │ │ ├── LightsaberSharedBuildCacheImplTest.kt │ │ │ ├── MultipleSinkOutputTest.kt │ │ │ ├── SingleSinkOutputTest.kt │ │ │ ├── analysis │ │ │ ├── AnalyzerHelperImplTest.kt │ │ │ ├── BindingsAnalyzerImplTest.kt │ │ │ ├── ExternalSetupAnalyzerImplTest.kt │ │ │ └── InjectionTargetsAnalyzerImplTest.kt │ │ │ ├── annotations │ │ │ └── proxy │ │ │ │ ├── AnnotationProxyGeneratorTest.kt │ │ │ │ ├── Annotations.java │ │ │ │ └── ArrayClassLoader.kt │ │ │ ├── commons │ │ │ ├── CompositeAnnotationVisitorTest.kt │ │ │ ├── CompositeClassVisitorTest.kt │ │ │ ├── CompositeFieldVisitorTest.kt │ │ │ ├── CompositeMethodVisitorTest.kt │ │ │ └── CompositeVisitorVerifier.kt │ │ │ ├── generation │ │ │ └── GeneratorTest.kt │ │ │ ├── graph │ │ │ └── CycleSearcherTest.kt │ │ │ ├── integration │ │ │ ├── IntegrationTestRule.kt │ │ │ └── TestErrorReporter.kt │ │ │ └── validation │ │ │ ├── ContractParserTest.kt │ │ │ ├── FactoryParserTest.kt │ │ │ ├── ImportParserTest.kt │ │ │ ├── ModuleParserTest.kt │ │ │ ├── SanityCheckerTest.kt │ │ │ ├── UnusedImportsTest.kt │ │ │ ├── UsageValidatorTest.kt │ │ │ └── ValidatorTest.kt │ │ └── resources │ │ └── test_case_projects │ │ ├── analyzer_helper │ │ ├── contract_configuration_with_generic_type │ │ │ └── Configuration.kt │ │ ├── eager_without_scope │ │ │ └── Configuration.kt │ │ └── multiple_qualifiers │ │ │ └── Configuration.kt │ │ ├── bindings_analyzer │ │ └── provide_as_with_non_class_argument │ │ │ └── Configuration.kt │ │ ├── contract_parser │ │ ├── contract_with_generic_parameters │ │ │ └── Configuration.kt │ │ ├── contract_with_methods_with_parameters │ │ │ └── Configuration.kt │ │ └── non_interface_contract │ │ │ └── Configuration.kt │ │ ├── external_setup_analyzer │ │ ├── dependency_project │ │ │ └── Configuration.kt │ │ ├── imported_by_dependency_project │ │ │ └── Configuration.kt │ │ ├── imported_by_with_empty_list_of_arguments │ │ │ └── Configuration.kt │ │ ├── imported_by_with_non_class_argument │ │ │ └── Configuration.kt │ │ ├── imported_by_with_non_container_argument │ │ │ └── Configuration.kt │ │ ├── imported_by_without_arguments │ │ │ └── Configuration.kt │ │ ├── provided_by_dependency_project │ │ │ └── Configuration.kt │ │ └── provided_by_with_non_container_argument │ │ │ └── Configuration.kt │ │ ├── factory_parser │ │ ├── factory_creating_instance_with_multiple_factory_inject │ │ │ └── Configuration.kt │ │ ├── factory_creating_instance_with_without_factory_parameter │ │ │ └── Configuration.kt │ │ ├── factory_creating_instance_without_factory_inject │ │ │ └── Configuration.kt │ │ ├── factory_return_with_non_class_argument │ │ │ └── Configuration.kt │ │ ├── factory_with_inheritance │ │ │ └── Configuration.kt │ │ ├── factory_with_misconfigured_inheritance │ │ │ └── Configuration.kt │ │ ├── factory_with_multiple_inheritance │ │ │ └── Configuration.kt │ │ └── factory_with_void_methods │ │ │ └── Configuration.kt │ │ ├── generator │ │ ├── bounded_generics │ │ │ └── Configuration.kt │ │ ├── first_project │ │ │ └── Configuration.kt │ │ ├── parameterized_type │ │ │ └── Configuration.kt │ │ └── second_project │ │ │ └── Configuration.kt │ │ ├── import_parser │ │ ├── import_kotlin_lazy_contract │ │ │ └── Configuration.kt │ │ ├── import_lazy_contract │ │ │ └── Configuration.kt │ │ ├── import_lazy_module │ │ │ └── Configuration.kt │ │ └── import_method_with_parameters │ │ │ └── Configuration.kt │ │ ├── injection_target_analyzer │ │ └── class_with_multiple_injectable_constructors │ │ │ └── Configuration.kt │ │ ├── module_parser │ │ ├── module_with_type_parameters │ │ │ └── Configuration.kt │ │ └── module_without_annotation │ │ │ └── Configuration.kt │ │ ├── sanity │ │ ├── abstract_contract_configuration │ │ │ └── Configuration.kt │ │ ├── factory_contains_generic_parameters │ │ │ └── Configuration.kt │ │ ├── factory_creating_instance_type_differ_from_return_annotation │ │ │ └── Configuration.kt │ │ ├── factory_is_not_an_interface │ │ │ └── Configuration.kt │ │ ├── factory_without_methods │ │ │ └── Configuration.kt │ │ ├── invalid_access_level │ │ │ └── Configuration.kt │ │ ├── invalid_provided_as │ │ │ └── Configuration.kt │ │ ├── module_inherits_contract_configuration_class │ │ │ └── Configuration.kt │ │ ├── module_with_invalid_parent │ │ │ └── Configuration.kt │ │ ├── non_constructable_module_with_imported_by │ │ │ └── Configuration.kt │ │ ├── provide_as_with_argument_class_containing_injectable_constructor │ │ │ └── Configuration.kt │ │ ├── provide_as_with_generic_argument_class │ │ │ └── Configuration.kt │ │ ├── provide_as_with_generic_host_class │ │ │ └── Configuration.kt │ │ ├── provide_as_with_host_class_as_argument │ │ │ └── Configuration.kt │ │ ├── provide_as_with_not_inherited_argument │ │ │ └── Configuration.kt │ │ ├── static_field_injection │ │ │ └── Configuration.kt │ │ └── static_method_injection │ │ │ └── Configuration.kt │ │ ├── unused_imports │ │ ├── factory_usages │ │ │ └── Configuration.kt │ │ ├── injector_usages │ │ │ └── Configuration.kt │ │ ├── provider_usages │ │ │ └── Configuration.kt │ │ ├── transitive_module_usages │ │ │ └── Configuration.kt │ │ ├── unused_contract │ │ │ └── Configuration.kt │ │ └── unused_module │ │ │ └── Configuration.kt │ │ ├── usage_validator │ │ ├── dependency_project │ │ │ └── Configuration.kt │ │ └── referencing_dependency_project │ │ │ └── Configuration.kt │ │ └── validator │ │ ├── contract_duplicates │ │ └── Configuration.kt │ │ ├── dependency_cycle │ │ └── Configuration.kt │ │ ├── dependency_duplicates │ │ └── Configuration.kt │ │ ├── dependency_missed │ │ └── Configuration.kt │ │ ├── module_duplicates │ │ └── Configuration.kt │ │ ├── provided_as_without_provided_by │ │ └── Configuration.kt │ │ ├── provided_by_separate_module │ │ └── Configuration.kt │ │ ├── provided_by_without_inject │ │ └── Configuration.kt │ │ ├── separate_module_dependency_missing │ │ └── Configuration.kt │ │ ├── valid_configuration │ │ ├── AppContract.kt │ │ ├── AppMain.kt │ │ ├── AppModule.kt │ │ ├── DependencyImplementation.kt │ │ └── DependencyInterface.kt │ │ └── valid_configuration_with_lazy_imports │ │ ├── AnotherDependencyImplementation.kt │ │ ├── AnotherDependencyInterface.kt │ │ ├── AppContract.kt │ │ ├── AppMain.kt │ │ ├── AppModule.kt │ │ ├── DependencyImplementation.kt │ │ ├── DependencyInterface.kt │ │ ├── YetAnotherDependencyImplementation.kt │ │ ├── YetAnotherDependencyImplementation2.kt │ │ ├── YetAnotherDependencyInterface.kt │ │ └── YetAnotherDependencyInterface2.kt ├── settings.gradle └── src │ └── functionalTest │ └── java │ └── com │ └── joom │ └── lightsaber │ └── plugin │ ├── AndroidLightsaberPluginTest.kt │ └── GradleDistribution.kt ├── samples ├── injection-test │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── Main.kt │ │ └── test │ │ └── java │ │ └── com │ │ └── joom │ │ └── lightsaber │ │ ├── BoundedGenericTest.kt │ │ ├── ChildInjectionTest.kt │ │ ├── ComponentModuleTest.kt │ │ ├── ContractConfigurationTest.kt │ │ ├── ContractImportTest.kt │ │ ├── ContractInjectionTest.kt │ │ ├── CycleInjectionTest.kt │ │ ├── EagerInjectionTest.kt │ │ ├── FactoryBridgesInjectionTest.kt │ │ ├── FactoryInheritanceInjectionTest.kt │ │ ├── FactoryInjectionTest.kt │ │ ├── GenericInjectionTest.kt │ │ ├── ImportedByInjectionTest.kt │ │ ├── InjectionTargetHierarchyInjectionTest.kt │ │ ├── InjectorInjectionTest.kt │ │ ├── LambdaInjectionTest.kt │ │ ├── LazyContractConfigurationTest.kt │ │ ├── LazyContractImportTest.kt │ │ ├── LazyInjectionTest.kt │ │ ├── NestedModuleTest.kt │ │ ├── PrimitiveInjectionTest.kt │ │ ├── ProvidedAsInjectionTest.kt │ │ ├── ProvidedByInjectionTest.kt │ │ ├── ProviderInterceptorInjectionTest.kt │ │ ├── QualifiedInjectionTest.kt │ │ ├── StaticModuleTest.kt │ │ ├── TestExtensions.kt │ │ └── access │ │ ├── AccessComponent.java │ │ ├── AccessModule.java │ │ ├── AccessTest.java │ │ ├── InternalDependency.java │ │ ├── InternalDependencyImpl.java │ │ ├── InternalGenericDependency.java │ │ ├── InternalGenericDependencyImpl.java │ │ ├── InternalQualifier.java │ │ └── SingletonQualifier.java ├── sample-android-kotlin │ ├── build.gradle │ ├── proguard.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ └── sample │ │ │ └── MainActivityTest.kt │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ └── sample │ │ │ ├── Chewbacca.kt │ │ │ ├── DarthVader.kt │ │ │ ├── DroidFactory.kt │ │ │ ├── LightsaberComponent.kt │ │ │ ├── LightsaberModule.kt │ │ │ ├── MainActivity.kt │ │ │ ├── R2D2.kt │ │ │ └── Wookiee.kt │ │ └── res │ │ ├── layout │ │ └── main.xml │ │ └── values │ │ └── strings.xml ├── sample-android-library │ ├── build.gradle │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ └── sample │ │ │ └── library │ │ │ └── LibraryTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ └── sample │ │ │ └── library │ │ │ ├── Droid.java │ │ │ ├── Kashyyyk.java │ │ │ ├── LibraryModule.java │ │ │ └── Planet.java │ │ └── test │ │ └── java │ │ └── com │ │ └── joom │ │ └── lightsaber │ │ └── sample │ │ └── library │ │ └── UnitTest.java ├── sample-java │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── joom │ │ └── lightsaber │ │ └── sample │ │ ├── Chewbacca.java │ │ ├── DarthVader.java │ │ ├── Droid.java │ │ ├── DroidFactory.java │ │ ├── Kashyyyk.java │ │ ├── LightsaberComponent.java │ │ ├── LightsaberModule.java │ │ ├── LightsaberSample.java │ │ ├── Planet.java │ │ ├── R2D2.java │ │ └── Wookiee.java ├── sample-kotlin-modular │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── joom │ │ │ │ └── lightsaber │ │ │ │ └── modular │ │ │ │ └── ModularSample.kt │ │ │ └── test │ │ │ └── kotlin │ │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ └── modular │ │ │ └── ModularSampleTest.kt │ ├── library-component │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ └── modular │ │ │ ├── ComponentDependency.kt │ │ │ └── LibraryComponent.kt │ ├── library-contract │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ └── modular │ │ │ └── ModularContract.kt │ ├── library-factory │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── joom │ │ │ └── lightsaber │ │ │ └── modular │ │ │ ├── FactoryDependency.kt │ │ │ ├── LibraryFactory.kt │ │ │ └── LibraryFactoryModule.kt │ └── library-module │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── joom │ │ └── lightsaber │ │ └── modular │ │ ├── LibraryContract.kt │ │ ├── LibraryModule.kt │ │ └── ModuleDependency.kt └── sample-kotlin │ ├── build.gradle │ └── src │ └── main │ └── java │ └── com │ └── joom │ └── lightsaber │ └── sample │ ├── Chewbacca.kt │ ├── DarthVader.kt │ ├── Droid.kt │ ├── DroidFactory.kt │ ├── Kashyyyk.kt │ ├── LightsaberComponent.kt │ ├── LightsaberModule.kt │ ├── LightsaberSample.kt │ ├── Planet.kt │ ├── R2D2.kt │ └── Wookiee.kt └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.jar 3 | *.zip 4 | *.tar 5 | *.apk 6 | *.ap_ 7 | 8 | # Files for the Dalvik VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | 14 | # Generated files 15 | bin/ 16 | gen/ 17 | 18 | # Gradle files 19 | .gradle/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | 28 | # IntelliJ IDEA and Android Studio files 29 | .idea/ 30 | *.iml 31 | 32 | # Gradle Wrapper 33 | !gradle/wrapper/gradle-wrapper.jar 34 | 35 | !processor/src/test/resources/ 36 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | buildscript { 3 | apply from: "$rootDir/gradle/common.gradle" 4 | 5 | repositories { 6 | mavenLocal() 7 | google() 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 13 | classpath "com.android.tools.build:gradle:$androidToolsVersion" 14 | classpath "com.joom.lightsaber:lightsaber-gradle-plugin:$version" 15 | } 16 | } 17 | 18 | repositories { 19 | mavenLocal() 20 | google() 21 | mavenCentral() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4g -XX:+UseParallelGC -Dfile.encoding=UTF-8 2 | kotlin.incremental=true 3 | android.useAndroidX=true 4 | pablo.shadow.enabled=false 5 | development=true 6 | 7 | lightsaber.validate.unused.imports=false 8 | lightsaber.validate.unused.imports.verbose=false 9 | lightsaber.dump.debug.report=true 10 | -------------------------------------------------------------------------------- /gradle/common.gradle: -------------------------------------------------------------------------------- 1 | version = '1.0.0-alpha23' 2 | group = 'com.joom.lightsaber' 3 | 4 | ext.javaVersion = JavaVersion.VERSION_11 5 | ext.kotlinVersion = '1.7.21' 6 | ext.kotlinLanguageVersion = '1.7' 7 | ext.kotlinRuntimeVariant = '-jdk8' 8 | ext.pabloVersion = '1.3.1' 9 | 10 | ext.javaxInjectVersion = '1' 11 | ext.jsr305Version = '3.0.2' 12 | ext.asmVersion = '9.2' 13 | ext.gripVersion = '0.9.1' 14 | ext.bimapVersion = '1.1.0' 15 | ext.logbackVersion = '1.2.11' 16 | 17 | ext.junitVersion = '4.13.2' 18 | ext.mockitoVersion = '3.11.2' 19 | ext.mockitoKotlinVersion = '3.2.0' 20 | 21 | ext.androidCompileSdkVersion = 30 22 | ext.androidTargetSdkVersion = 30 23 | ext.androidMinSdkVersion = 16 24 | ext.androidBuildToolsVersion = '30.0.3' 25 | ext.androidToolsVersion = '7.4.2' 26 | ext.androidxAnnotationVersion = '1.2.0' 27 | ext.androidxEspressoVersion = '3.4.0' 28 | ext.androidxTestRunnerVersion = '1.4.0' 29 | ext.androidxTestExtJunitVersion = '1.1.3' 30 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joomcode/lightsaber/61f4821f2b807c7b0f4163414b843194f526971e/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-7.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /lightsaber/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | allprojects { 3 | apply from: "$rootDir/../gradle/common.gradle" 4 | 5 | buildscript { 6 | repositories { 7 | google() 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 13 | classpath "com.android.tools.build:gradle:$androidToolsVersion" 14 | classpath "io.michaelrocks.pablo:pablo:$pabloVersion" 15 | } 16 | } 17 | 18 | repositories { 19 | google() 20 | mavenCentral() 21 | } 22 | } 23 | } 24 | 25 | apply plugin: 'kotlin' 26 | 27 | sourceSets { 28 | functionalTest { 29 | java { 30 | compileClasspath += main.output 31 | runtimeClasspath += main.output 32 | } 33 | } 34 | } 35 | 36 | dependencies { 37 | functionalTestImplementation gradleTestKit() 38 | functionalTestImplementation "junit:junit:$junitVersion" 39 | } 40 | 41 | tasks.register("functionalTest", Test.class) { 42 | description = "Runs functional tests." 43 | group = "verification" 44 | 45 | testClassesDirs = project.sourceSets.functionalTest.output.classesDirs 46 | classpath = project.sourceSets.functionalTest.runtimeClasspath 47 | } 48 | 49 | afterEvaluate { 50 | tasks.named("functionalTest") { 51 | subprojects.each { 52 | dependsOn(it.tasks.named("publishToMavenLocal")) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lightsaber/core-kotlin/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-library' 2 | apply plugin: 'kotlin' 3 | apply from: "$rootDir/pablo.gradle" 4 | 5 | sourceCompatibility = javaVersion 6 | targetCompatibility = javaVersion 7 | 8 | dependencies { 9 | api project(':core') 10 | 11 | implementation "org.jetbrains.kotlin:kotlin-stdlib$kotlinRuntimeVariant:$kotlinVersion" 12 | 13 | testImplementation "junit:junit:$junitVersion" 14 | } 15 | 16 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { 17 | kotlinOptions { 18 | jvmTarget = javaVersion 19 | apiVersion = kotlinLanguageVersion 20 | languageVersion = kotlinLanguageVersion 21 | } 22 | } 23 | 24 | jar { 25 | destinationDirectory.set(file('build/jar')) 26 | } 27 | -------------------------------------------------------------------------------- /lightsaber/core-test/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-library' 2 | apply from: "$rootDir/pablo.gradle" 3 | 4 | sourceCompatibility = javaVersion 5 | targetCompatibility = javaVersion 6 | 7 | dependencies { 8 | implementation project(":core") 9 | 10 | implementation "com.google.code.findbugs:jsr305:$jsr305Version" 11 | 12 | testImplementation "junit:junit:$junitVersion" 13 | testImplementation "org.mockito:mockito-core:$mockitoVersion" 14 | testImplementation "com.google.code.findbugs:jsr305:$jsr305Version" 15 | } 16 | 17 | jar { 18 | destinationDirectory.set(file('build/jar')) 19 | } 20 | 21 | pablo { 22 | artifactName = 'lightsaber-test' 23 | } 24 | -------------------------------------------------------------------------------- /lightsaber/core/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-library' 2 | apply from: "$rootDir/pablo.gradle" 3 | 4 | sourceCompatibility = javaVersion 5 | targetCompatibility = javaVersion 6 | 7 | dependencies { 8 | api "javax.inject:javax.inject:$javaxInjectVersion" 9 | 10 | implementation "com.google.code.findbugs:jsr305:$jsr305Version" 11 | 12 | testImplementation project(':core-test') 13 | testImplementation "junit:junit:$junitVersion" 14 | testImplementation "org.mockito:mockito-core:$mockitoVersion" 15 | testImplementation "com.google.code.findbugs:jsr305:$jsr305Version" 16 | } 17 | 18 | jar { 19 | destinationDirectory.set(file('build/jar')) 20 | } 21 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/Component.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import static java.lang.annotation.ElementType.TYPE; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Documented; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | @Target(TYPE) 27 | @Retention(RUNTIME) 28 | @Documented 29 | @Deprecated 30 | public @interface Component { 31 | Class parent() default None.class; 32 | 33 | class None { 34 | private None() { 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/ConfigurationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import javax.annotation.Nullable; 20 | 21 | public class ConfigurationException extends RuntimeException { 22 | public ConfigurationException() { 23 | } 24 | 25 | public ConfigurationException(@Nullable final String message) { 26 | super(message); 27 | } 28 | 29 | public ConfigurationException(@Nullable final String message, @Nullable final Throwable cause) { 30 | super(message, cause); 31 | } 32 | 33 | public ConfigurationException(@Nullable final Throwable cause) { 34 | super(cause); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/Contract.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import static java.lang.annotation.ElementType.FIELD; 20 | import static java.lang.annotation.ElementType.METHOD; 21 | import static java.lang.annotation.ElementType.TYPE; 22 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 23 | 24 | import java.lang.annotation.Documented; 25 | import java.lang.annotation.Retention; 26 | import java.lang.annotation.Target; 27 | 28 | @Target({ TYPE, FIELD, METHOD }) 29 | @Retention(RUNTIME) 30 | @Documented 31 | public @interface Contract { 32 | } 33 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/ContractConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | public abstract class ContractConfiguration { 20 | } 21 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/Eager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import static java.lang.annotation.ElementType.FIELD; 20 | import static java.lang.annotation.ElementType.METHOD; 21 | import static java.lang.annotation.ElementType.TYPE; 22 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 23 | 24 | import java.lang.annotation.Documented; 25 | import java.lang.annotation.Retention; 26 | import java.lang.annotation.Target; 27 | 28 | @Target({ TYPE, FIELD, METHOD }) 29 | @Retention(RUNTIME) 30 | @Documented 31 | public @interface Eager { 32 | } 33 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/Import.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import static java.lang.annotation.ElementType.FIELD; 20 | import static java.lang.annotation.ElementType.METHOD; 21 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 22 | 23 | import java.lang.annotation.Documented; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.Target; 26 | 27 | @Target({ METHOD, FIELD }) 28 | @Retention(RUNTIME) 29 | @Documented 30 | public @interface Import { 31 | } 32 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/ImportedBy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import static java.lang.annotation.ElementType.TYPE; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Documented; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | @Target({ TYPE }) 27 | @Retention(RUNTIME) 28 | @Documented 29 | public @interface ImportedBy { 30 | Class[] value(); 31 | } 32 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/Lazy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import javax.annotation.Nonnull; 20 | 21 | public interface Lazy { 22 | @Nonnull 23 | T get(); 24 | } 25 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/LazyAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import javax.annotation.Nonnull; 20 | import javax.inject.Provider; 21 | 22 | public class LazyAdapter implements Lazy { 23 | private final Provider provider; 24 | private volatile T instance; 25 | private final Object instanceLock = new Object(); 26 | 27 | public LazyAdapter(@Nonnull final Provider provider) { 28 | this.provider = provider; 29 | } 30 | 31 | @Nonnull 32 | @Override 33 | public T get() { 34 | if (instance == null) { 35 | synchronized (instanceLock) { 36 | if (instance == null) { 37 | instance = provider.get(); 38 | } 39 | } 40 | } 41 | return instance; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/Module.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import static java.lang.annotation.ElementType.TYPE; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Documented; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | @Target(TYPE) 27 | @Retention(RUNTIME) 28 | @Documented 29 | public @interface Module { 30 | } 31 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/Provide.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import static java.lang.annotation.ElementType.FIELD; 20 | import static java.lang.annotation.ElementType.METHOD; 21 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 22 | 23 | import java.lang.annotation.Documented; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.Target; 26 | 27 | @Target({ METHOD, FIELD }) 28 | @Retention(RUNTIME) 29 | @Documented 30 | public @interface Provide { 31 | } 32 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/ProvidedAs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import static java.lang.annotation.ElementType.TYPE; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Documented; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | @Target({ TYPE }) 27 | @Retention(RUNTIME) 28 | @Documented 29 | public @interface ProvidedAs { 30 | Class[] value(); 31 | } 32 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/ProvidedBy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import static java.lang.annotation.ElementType.TYPE; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Documented; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | @Target({ TYPE }) 27 | @Retention(RUNTIME) 28 | @Documented 29 | public @interface ProvidedBy { 30 | Class[] value(); 31 | } 32 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/internal/ContractCreator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.internal; 18 | 19 | import com.joom.lightsaber.Injector; 20 | 21 | public interface ContractCreator { 22 | T createContract(Injector injector); 23 | } 24 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/internal/GenericArrayTypeImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.internal; 18 | 19 | import java.lang.reflect.GenericArrayType; 20 | import java.lang.reflect.Type; 21 | 22 | public final class GenericArrayTypeImpl implements GenericArrayType { 23 | private final Type genericComponentType; 24 | 25 | public GenericArrayTypeImpl(final Type genericComponentType) { 26 | this.genericComponentType = genericComponentType; 27 | } 28 | 29 | @Override 30 | public Type getGenericComponentType() { 31 | return genericComponentType; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return TypeUtils.getTypeName(genericComponentType) + "[]"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/internal/InjectorConfigurator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.internal; 18 | 19 | public interface InjectorConfigurator { 20 | void configureInjector(LightsaberInjector injector); 21 | } 22 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/internal/IterableMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.internal; 18 | 19 | import java.util.Map; 20 | 21 | import javax.annotation.Nonnull; 22 | 23 | public interface IterableMap extends Map, Iterable { 24 | @Nonnull 25 | @Override 26 | MapIterator iterator(); 27 | } 28 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/internal/MapIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.internal; 18 | 19 | import java.util.Iterator; 20 | 21 | public interface MapIterator extends Iterator { 22 | V getValue(); 23 | 24 | V setValue(V value); 25 | } 26 | -------------------------------------------------------------------------------- /lightsaber/core/src/main/java/com/joom/lightsaber/internal/MembersInjector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.internal; 18 | 19 | import com.joom.lightsaber.Injector; 20 | 21 | import javax.annotation.Nonnull; 22 | 23 | public interface MembersInjector { 24 | void injectFields(@Nonnull Injector injector); 25 | 26 | void injectMethods(@Nonnull Injector injector); 27 | } 28 | -------------------------------------------------------------------------------- /lightsaber/core/src/test/java/com/joom/lightsaber/TypeReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber; 18 | 19 | import java.lang.reflect.ParameterizedType; 20 | import java.lang.reflect.Type; 21 | 22 | import javax.annotation.Nonnull; 23 | 24 | abstract class TypeReference { 25 | protected TypeReference() { 26 | } 27 | 28 | @Nonnull 29 | public Type getType() { 30 | final ParameterizedType referenceType = (ParameterizedType) getClass().getGenericSuperclass(); 31 | return referenceType.getActualTypeArguments()[0]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lightsaber/core/src/test/java/com/joom/lightsaber/internal/GenericArrayTypeImplTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.internal; 18 | 19 | import static org.junit.Assert.assertEquals; 20 | 21 | import org.junit.Test; 22 | 23 | public class GenericArrayTypeImplTest { 24 | @Test 25 | public void testToString() { 26 | final GenericArrayTypeImpl genericArrayType = new GenericArrayTypeImpl(NamedType.create("Type")); 27 | assertEquals("Type[]", genericArrayType.toString()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lightsaber/core/src/test/java/com/joom/lightsaber/internal/NamedType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.internal; 18 | 19 | import java.lang.reflect.Type; 20 | 21 | class NamedType implements Type { 22 | private final String name; 23 | 24 | private NamedType(final String name) { 25 | this.name = name; 26 | } 27 | 28 | public static NamedType create(final String name) { 29 | return new NamedType(name); 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return name; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lightsaber/gradle-plugin/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated code 2 | generated/ -------------------------------------------------------------------------------- /lightsaber/gradle-plugin/src/main/java/com/joom/lightsaber/plugin/AllClassesTransformRegistrar.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.plugin 18 | 19 | import com.android.build.api.artifact.MultipleArtifact 20 | import com.android.build.api.variant.Component 21 | import org.gradle.api.tasks.TaskProvider 22 | 23 | internal object AllClassesTransformRegistrar : TransformTaskRegistrar { 24 | override fun register(component: Component, taskProvider: TaskProvider) { 25 | @Suppress("DEPRECATION") 26 | component.artifacts.use(taskProvider) 27 | .wiredWith(LightsaberTransformTask::inputDirectories, LightsaberTransformTask::outputDirectory) 28 | .toTransform(MultipleArtifact.ALL_CLASSES_DIRS) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lightsaber/gradle-plugin/src/main/java/com/joom/lightsaber/plugin/AndroidLightsaberPluginExtension.kt: -------------------------------------------------------------------------------- 1 | package com.joom.lightsaber.plugin 2 | 3 | import java.io.File 4 | 5 | open class AndroidLightsaberPluginExtension { 6 | var validateUsage: Boolean? = null 7 | var validateUnusedImports: Boolean? = null 8 | var validateUnusedImportsVerbose: Boolean? = null 9 | var dumpDebugReport: Boolean? = null 10 | 11 | var cacheable: Boolean = false 12 | var bootClasspath: List = emptyList() 13 | } 14 | -------------------------------------------------------------------------------- /lightsaber/gradle-plugin/src/main/java/com/joom/lightsaber/plugin/CollectionExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.plugin 18 | 19 | inline fun forEach(iterable1: Iterable, iterable2: Iterable, action: (T, R) -> Unit) { 20 | val iterator1 = iterable1.iterator() 21 | val iterator2 = iterable2.iterator() 22 | while (iterator1.hasNext()) { 23 | action(iterator1.next(), iterator2.next()) 24 | } 25 | check(!iterator2.hasNext()) 26 | } 27 | -------------------------------------------------------------------------------- /lightsaber/gradle-plugin/src/main/java/com/joom/lightsaber/plugin/JavaLightsaberPluginExtension.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.plugin 18 | 19 | open class JavaLightsaberPluginExtension { 20 | var processTest: Boolean? = null 21 | var validateUsage: Boolean? = null 22 | var validateUnusedImports: Boolean? = null 23 | var validateUnusedImportsVerbose: Boolean? = null 24 | var dumpDebugReport: Boolean? = null 25 | } 26 | -------------------------------------------------------------------------------- /lightsaber/gradle-plugin/src/main/java/com/joom/lightsaber/plugin/TransformTaskRegistrar.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.plugin 18 | 19 | import com.android.build.api.variant.Component 20 | import org.gradle.api.tasks.TaskProvider 21 | 22 | internal interface TransformTaskRegistrar { 23 | fun register(component: Component, taskProvider: TaskProvider) 24 | } 25 | -------------------------------------------------------------------------------- /lightsaber/gradle-plugin/src/main/resources/META-INF/gradle-plugins/com.joom.lightsaber.android.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.joom.lightsaber.plugin.AndroidLightsaberPlugin 2 | -------------------------------------------------------------------------------- /lightsaber/gradle-plugin/src/main/resources/META-INF/gradle-plugins/com.joom.lightsaber.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.joom.lightsaber.plugin.JavaLightsaberPlugin 2 | -------------------------------------------------------------------------------- /lightsaber/gradle.properties: -------------------------------------------------------------------------------- 1 | ../gradle.properties -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/CachedGripFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor 18 | 19 | import com.joom.grip.Grip 20 | import com.joom.grip.GripFactory 21 | import java.nio.file.Path 22 | 23 | internal object CachedGripFactory { 24 | fun create(cache: LightsaberSharedBuildCache, paths: Iterable): Iterable { 25 | val visited = HashSet() 26 | 27 | return paths 28 | .asSequence() 29 | .filter { visited.add(it) } 30 | .map { 31 | cache.getOrPut(GripKey(it)) { key -> 32 | GripFactory.INSTANCE.create(key.path) 33 | } 34 | } 35 | .asIterable() 36 | } 37 | 38 | private data class GripKey(val path: Path) 39 | } 40 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/LightsaberParameters.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor 18 | 19 | import java.nio.file.Path 20 | 21 | data class LightsaberParameters( 22 | val inputs: List, 23 | val classpath: List, 24 | val modulesClasspath: List, 25 | val bootClasspath: List, 26 | val outputFactory: LightsaberOutputFactory, 27 | val projectName: String, 28 | val validateUsage: Boolean, 29 | val validateUnusedImports: Boolean, 30 | val validateUnusedImportsVerbose: Boolean, 31 | val dumpDebugReport: Boolean, 32 | val reportDirectory: Path, 33 | val sharedBuildCache: LightsaberSharedBuildCache, 34 | val errorReporter: ErrorReporter = ErrorReporterImpl(), 35 | ) 36 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/LightsaberProcessor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor 18 | 19 | import com.joom.lightsaber.processor.logging.getLogger 20 | 21 | class LightsaberProcessor( 22 | private val parameters: LightsaberParameters 23 | ) { 24 | private val logger = getLogger() 25 | 26 | @Throws(Exception::class) 27 | fun process() { 28 | ClassProcessor(parameters).use { processor -> 29 | processor.processClasses() 30 | } 31 | 32 | logger.info("DONE") 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/ProcessingException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.joom.lightsaber.processor 17 | 18 | class ProcessingException(message: String, cause: Throwable? = null) : Exception(message, cause) 19 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/analysis/ScopeRegistry.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.analysis 18 | 19 | import com.joom.grip.mirrors.Type 20 | import com.joom.lightsaber.LightsaberTypes 21 | import com.joom.lightsaber.processor.commons.Types 22 | 23 | class ScopeRegistry { 24 | fun findScopeProviderByAnnotationType(annotationType: Type.Object): Type.Object? { 25 | return when (annotationType) { 26 | Types.SINGLETON_TYPE -> LightsaberTypes.SINGLETON_PROVIDER_TYPE 27 | else -> null 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/commons/AnyExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.commons 18 | 19 | import java.io.Closeable 20 | 21 | inline fun using(closeable: T, block: (T) -> R): R { 22 | try { 23 | return block(closeable) 24 | } finally { 25 | try { 26 | closeable.close() 27 | } catch (exception: Exception) { 28 | // Ignore the exception. 29 | } 30 | } 31 | } 32 | 33 | inline fun Any.cast(): T = 34 | this as T 35 | 36 | inline fun given(condition: Boolean, body: () -> T): T? = 37 | if (condition) body() else null 38 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/commons/Arrays.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.commons 18 | 19 | inline fun Array.mapToArray(transform: (T) -> R): Array { 20 | return Array(size, { index -> transform(this[index]) }) 21 | } 22 | 23 | inline fun List.mapToArray(transform: (T) -> R): Array { 24 | return Array(size, { index -> transform(this[index]) }) 25 | } 26 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/commons/CloseableExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.commons 18 | 19 | import java.io.Closeable 20 | import java.io.IOException 21 | 22 | fun Closeable.closeQuietly() { 23 | try { 24 | close() 25 | } catch (exception: IOException) { 26 | // Ignore the exception. 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/commons/CollectionsExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.commons 18 | 19 | import java.util.Collections 20 | import java.util.SortedMap 21 | import java.util.SortedSet 22 | 23 | fun Collection.immutable(): Collection = Collections.unmodifiableCollection(this) 24 | fun List.immutable(): List = Collections.unmodifiableList(this) 25 | fun Map.immutable(): Map = Collections.unmodifiableMap(this) 26 | fun Set.immutable(): Set = Collections.unmodifiableSet(this) 27 | fun SortedMap.immutable(): SortedMap = Collections.unmodifiableSortedMap(this) 28 | fun SortedSet.immutable(): SortedSet = Collections.unmodifiableSortedSet(this) 29 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/commons/DependencyExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.commons 18 | 19 | import com.joom.lightsaber.processor.model.Dependency 20 | 21 | fun Dependency.boxed(): Dependency { 22 | val boxedType = type.boxed() 23 | return if (boxedType === type) this else copy(type = boxedType) 24 | } 25 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/commons/GeneratorAdapterExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.commons 18 | 19 | import com.joom.grip.mirrors.MethodMirror 20 | import com.joom.grip.mirrors.Type 21 | import com.joom.grip.mirrors.isPrivate 22 | 23 | inline fun GeneratorAdapter.newLocal(type: Type, valueProvider: () -> Unit): Int { 24 | val local = newLocal(type) 25 | valueProvider() 26 | storeLocal(local) 27 | return local 28 | } 29 | 30 | fun GeneratorAdapter.invokeMethod(owner: Type, method: MethodMirror) { 31 | if (method.isPrivate) { 32 | invokePrivate(owner, method.toMethodDescriptor()) 33 | } else { 34 | invokeVirtual(owner, method.toMethodDescriptor()) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/commons/GenericTypeExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.commons 18 | 19 | import com.joom.grip.mirrors.signature.GenericType 20 | 21 | fun GenericType.boxed(): GenericType { 22 | if (this !is GenericType.Raw) { 23 | return this 24 | } 25 | 26 | val boxedType = type.boxed() 27 | if (boxedType === type) { 28 | return this 29 | } 30 | 31 | return GenericType.Raw(boxedType) 32 | } 33 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/commons/InjecteeExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.commons 18 | 19 | import com.joom.lightsaber.processor.model.Injectee 20 | 21 | fun Injectee.boxed(): Injectee { 22 | val boxedDependency = dependency.boxed() 23 | return if (boxedDependency === dependency) this else copy(dependency = boxedDependency) 24 | } 25 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/commons/InjectionPointExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.commons 18 | 19 | import com.joom.lightsaber.processor.model.Injectee 20 | import com.joom.lightsaber.processor.model.InjectionPoint 21 | 22 | fun InjectionPoint.getInjectees(): Collection { 23 | return when (this) { 24 | is InjectionPoint.Method -> injectees 25 | is InjectionPoint.Field -> listOf(injectee) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/commons/IntExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.commons 18 | 19 | operator fun Int.contains(flags: Int): Boolean { 20 | return this and flags == flags 21 | } 22 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/commons/Methods.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.commons 18 | 19 | import com.joom.grip.mirrors.Type 20 | import com.joom.lightsaber.processor.descriptors.MethodDescriptor 21 | 22 | object Methods { 23 | val HASH_CODE_METHOD = MethodDescriptor.forMethod("hashCode", Type.Primitive.Int) 24 | val EQUALS_METHOD = MethodDescriptor.forMethod("equals", Type.Primitive.Boolean, Types.OBJECT_TYPE) 25 | val TO_STRING_METHOD = MethodDescriptor.forMethod("toString", Types.STRING_TYPE) 26 | 27 | val GET_VALUE_METHOD = MethodDescriptor.forMethod("getValue", Types.OBJECT_TYPE) 28 | val GET_METHOD = MethodDescriptor.forMethod("get", Types.OBJECT_TYPE) 29 | } 30 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/commons/ProvisionPointExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.commons 18 | 19 | import com.joom.lightsaber.processor.model.Injectee 20 | import com.joom.lightsaber.processor.model.ProvisionPoint 21 | 22 | fun ProvisionPoint.getInjectees(): Collection { 23 | return when (this) { 24 | is ProvisionPoint.Constructor -> injectionPoint.injectees 25 | is ProvisionPoint.Method -> injectionPoint.injectees 26 | is ProvisionPoint.Field -> emptyList() 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/descriptors/FieldDescriptor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.descriptors 18 | 19 | import com.joom.grip.mirrors.Type 20 | import com.joom.grip.mirrors.getType 21 | 22 | fun FieldDescriptor(name: String, desc: String): FieldDescriptor = FieldDescriptor(name, getType(desc)) 23 | 24 | data class FieldDescriptor( 25 | val name: String, 26 | val type: Type 27 | ) 28 | 29 | val FieldDescriptor.descriptor: String 30 | get() = type.descriptor 31 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/generation/ClassProducer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.generation 18 | 19 | interface ClassProducer { 20 | fun produceClass(internalName: String, classData: ByteArray) 21 | } 22 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/generation/model/Key.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.generation.model 18 | 19 | import com.joom.lightsaber.processor.descriptors.FieldDescriptor 20 | 21 | sealed class Key { 22 | abstract val field: FieldDescriptor 23 | 24 | data class Type(override val field: FieldDescriptor) : Key() 25 | data class QualifiedType(override val field: FieldDescriptor) : Key() 26 | } 27 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/generation/model/KeyRegistry.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.generation.model 18 | 19 | import com.joom.grip.mirrors.Type 20 | import com.joom.lightsaber.processor.model.Dependency 21 | 22 | data class KeyRegistry( 23 | val type: Type.Object, 24 | val keys: Map 25 | ) 26 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/generation/model/PackageInvader.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.generation.model 18 | 19 | import com.joom.grip.mirrors.Type 20 | import com.joom.lightsaber.processor.descriptors.FieldDescriptor 21 | 22 | data class PackageInvader( 23 | val type: Type.Object, 24 | val packageName: String, 25 | val fields: Map 26 | ) 27 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/graph/GraphExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.graph 18 | 19 | fun DirectedGraph.reversed(): DirectedGraph { 20 | val reversed = HashDirectedGraph() 21 | for (vertex in vertices) { 22 | for (adjacentVertex in getAdjacentVertices(vertex)!!) { 23 | reversed.put(adjacentVertex, vertex) 24 | } 25 | } 26 | return reversed 27 | } 28 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/injection/BaseInjectionClassVisitor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.injection 18 | 19 | import com.joom.lightsaber.processor.watermark.WatermarkClassVisitor 20 | import org.objectweb.asm.ClassVisitor 21 | 22 | open class BaseInjectionClassVisitor( 23 | classVisitor: ClassVisitor 24 | ) : WatermarkClassVisitor(classVisitor, false) 25 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/logging/LoggerExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.logging 18 | 19 | import org.slf4j.LoggerFactory 20 | 21 | fun T.getLogger() = getLogger(javaClass) 22 | fun getLogger(name: String) = LoggerFactory.getLogger(name) 23 | fun getLogger(type: Class<*>) = LoggerFactory.getLogger(type) 24 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/Binding.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | data class Binding( 20 | val dependency: Dependency, 21 | val ancestor: Dependency 22 | ) 23 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/Component.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | import com.joom.grip.mirrors.Type 20 | 21 | data class Component( 22 | val type: Type.Object, 23 | val parent: Type.Object?, 24 | val defaultModule: Module, 25 | val subcomponents: Collection 26 | ) { 27 | 28 | fun getModulesWithDescendants(): Sequence = defaultModule.getModulesWithDescendants() 29 | fun getImportsWithDescendants(): Sequence = defaultModule.getImportsWithDescendants() 30 | } 31 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/Contract.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | import com.joom.grip.mirrors.Type 20 | 21 | data class Contract( 22 | val type: Type.Object, 23 | val implementationType: Type.Object, 24 | val dependency: Dependency, 25 | val provisionPoints: Collection 26 | ) 27 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/ContractConfiguration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | import com.joom.grip.mirrors.Type 20 | 21 | data class ContractConfiguration( 22 | val type: Type.Object, 23 | val contract: Contract, 24 | val defaultModule: Module 25 | ) { 26 | 27 | fun getModulesWithDescendants(): Sequence = defaultModule.getModulesWithDescendants() 28 | fun getImportsWithDescendants(): Sequence = defaultModule.getImportsWithDescendants() 29 | } 30 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/ContractProvisionPoint.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | import com.joom.grip.mirrors.MethodMirror 20 | import com.joom.grip.mirrors.Type 21 | 22 | class ContractProvisionPoint( 23 | val container: Type.Object, 24 | val method: MethodMirror, 25 | val injectee: Injectee 26 | ) 27 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/Converter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | import com.joom.grip.mirrors.Type 20 | 21 | sealed class Converter { 22 | object Identity : Converter() 23 | object Instance : Converter() 24 | data class Adapter(val adapterType: Type.Object) : Converter() 25 | } 26 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/Dependency.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | import com.joom.grip.mirrors.AnnotationMirror 20 | import com.joom.grip.mirrors.signature.GenericType 21 | 22 | data class Dependency( 23 | val type: GenericType, 24 | val qualifier: AnnotationMirror? = null 25 | ) 26 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/ExternalSetup.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | import com.joom.grip.mirrors.Type 20 | 21 | class ExternalSetup( 22 | val annotationModuleImportPointsByImporterModules: Map>, 23 | val providableTargetsByModules: Map>, 24 | val factoriesByModules: Map>, 25 | val contractsByModules: Map> 26 | ) 27 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/Factory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | import com.joom.grip.mirrors.Type 20 | import com.joom.grip.mirrors.getObjectTypeByInternalName 21 | 22 | data class Factory( 23 | val type: Type.Object, 24 | val implementationType: Type.Object, 25 | val dependency: Dependency, 26 | val provisionPoints: List 27 | ) { 28 | 29 | companion object { 30 | fun computeImplementationType(type: Type.Object): Type.Object { 31 | return getObjectTypeByInternalName("${type.internalName}\$Lightsaber\$Factory") 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/FactoryInjectee.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | sealed class FactoryInjectee { 20 | abstract val injectee: Injectee 21 | 22 | val dependency: Dependency get() = injectee.dependency 23 | 24 | data class FromInjector( 25 | override val injectee: Injectee 26 | ) : FactoryInjectee() 27 | 28 | data class FromMethod( 29 | override val injectee: Injectee, 30 | val argumentIndex: Int 31 | ) : FactoryInjectee() 32 | } 33 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/FactoryInjectionPoint.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | import com.joom.grip.mirrors.MethodMirror 20 | import com.joom.grip.mirrors.Type 21 | 22 | data class FactoryInjectionPoint( 23 | val containerType: Type.Object, 24 | val method: MethodMirror, 25 | val injectees: List 26 | ) 27 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/FactoryProvisionPoint.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | import com.joom.grip.mirrors.MethodMirror 20 | import com.joom.grip.mirrors.Type 21 | 22 | data class FactoryProvisionPoint( 23 | val containerType: Type.Object, 24 | val method: MethodMirror, 25 | val injectionPoint: FactoryInjectionPoint 26 | ) 27 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/Import.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | sealed class Import { 20 | abstract val importPoint: ImportPoint 21 | 22 | data class Module( 23 | val module: com.joom.lightsaber.processor.model.Module, 24 | override val importPoint: ImportPoint 25 | ) : Import() 26 | 27 | data class Contract( 28 | val contract: com.joom.lightsaber.processor.model.Contract, 29 | override val importPoint: ImportPoint 30 | ) : Import() 31 | } 32 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/InjectionPoint.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | import com.joom.grip.mirrors.FieldMirror 20 | import com.joom.grip.mirrors.MethodMirror 21 | import com.joom.grip.mirrors.Type 22 | 23 | sealed class InjectionPoint { 24 | abstract val containerType: Type.Object 25 | 26 | data class Method( 27 | override val containerType: Type.Object, 28 | val method: MethodMirror, 29 | val injectees: List 30 | ) : InjectionPoint() 31 | 32 | data class Field( 33 | override val containerType: Type.Object, 34 | val field: FieldMirror, 35 | val injectee: Injectee 36 | ) : InjectionPoint() 37 | } 38 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/model/Scope.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.model 18 | 19 | import com.joom.grip.mirrors.Type 20 | 21 | sealed class Scope { 22 | abstract val isEager: Boolean 23 | 24 | object None : Scope() { 25 | override val isEager: Boolean get() = false 26 | } 27 | 28 | class Class( 29 | val scopeType: Type.Object, 30 | override val isEager: Boolean 31 | ) : Scope() 32 | } 33 | -------------------------------------------------------------------------------- /lightsaber/processor/src/main/java/com/joom/lightsaber/processor/validation/ComponentGraph.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.processor.validation 18 | 19 | import com.joom.grip.mirrors.Type 20 | import com.joom.lightsaber.processor.graph.DirectedGraph 21 | import com.joom.lightsaber.processor.graph.HashDirectedGraph 22 | import com.joom.lightsaber.processor.model.Component 23 | 24 | fun buildComponentGraph(components: Collection): DirectedGraph { 25 | return HashDirectedGraph().apply { 26 | components.forEach { put(it.type, it.subcomponents) } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/analyzer_helper/contract_configuration_with_generic_type/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.analyzer_helper.contract_configuration_with_generic_type 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | 22 | @Contract 23 | interface AppContract 24 | 25 | class AppContractConfiguration : ContractConfiguration>() 26 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/analyzer_helper/eager_without_scope/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.analyzer_helper.eager_without_scope 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.Eager 22 | import com.joom.lightsaber.ProvidedBy 23 | import javax.inject.Inject 24 | 25 | @Eager 26 | @ProvidedBy(AppContractConfiguration::class) 27 | class Instance @Inject constructor() 28 | 29 | @Contract 30 | interface AppContract 31 | 32 | class AppContractConfiguration : ContractConfiguration() 33 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/bindings_analyzer/provide_as_with_non_class_argument/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.bindings_analyzer.provide_as_with_non_class_argument 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.ProvidedAs 22 | import com.joom.lightsaber.ProvidedBy 23 | import javax.inject.Inject 24 | 25 | @Contract 26 | interface AppContract 27 | 28 | class AppContractConfiguration : ContractConfiguration() 29 | 30 | @ProvidedAs(Int::class) 31 | @ProvidedBy(AppContractConfiguration::class) 32 | class Dependency @Inject constructor() 33 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/contract_parser/contract_with_generic_parameters/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.contract_parser.contract_with_generic_parameters 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | 22 | @Contract 23 | interface ClassContract 24 | 25 | class AppContractConfiguration : ContractConfiguration>() 26 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/contract_parser/contract_with_methods_with_parameters/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.contract_parser.contract_with_methods_with_parameters 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | 22 | @Contract 23 | interface AppContract { 24 | fun method(parameter: String) 25 | } 26 | 27 | class AppContractConfiguration : ContractConfiguration() 28 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/contract_parser/non_interface_contract/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.contract_parser.non_interface_contract 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | 22 | @Contract 23 | class ClassContract 24 | 25 | class AppContractConfiguration : ContractConfiguration() 26 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/external_setup_analyzer/imported_by_with_empty_list_of_arguments/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.external_setup_analyzer.imported_by_with_empty_list_of_arguments 18 | 19 | import com.joom.lightsaber.ImportedBy 20 | import com.joom.lightsaber.Module 21 | 22 | @ImportedBy() 23 | @Module 24 | class AppModule 25 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/external_setup_analyzer/imported_by_with_non_class_argument/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.external_setup_analyzer.imported_by_with_non_class_argument 18 | 19 | import com.joom.lightsaber.ImportedBy 20 | import com.joom.lightsaber.Module 21 | 22 | @ImportedBy(Int::class) 23 | @Module 24 | class AppModule 25 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/external_setup_analyzer/imported_by_with_non_container_argument/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.external_setup_analyzer.imported_by_with_non_container_argument 18 | 19 | import com.joom.lightsaber.ImportedBy 20 | import com.joom.lightsaber.Module 21 | 22 | @ImportedBy(Any::class) 23 | @Module 24 | class AppModule 25 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/external_setup_analyzer/imported_by_without_arguments/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.external_setup_analyzer.imported_by_without_arguments 18 | 19 | import com.joom.lightsaber.ImportedBy 20 | import com.joom.lightsaber.Module 21 | 22 | @ImportedBy 23 | @Module 24 | class AppModule 25 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/external_setup_analyzer/provided_by_dependency_project/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.external_setup_analyzer.provided_by_dependency_project 18 | 19 | import com.joom.lightsaber.ProvidedBy 20 | import test_case_projects.external_setup_analyzer.dependency_project.DependencyProjectModule 21 | import javax.inject.Inject 22 | 23 | @ProvidedBy(DependencyProjectModule::class) 24 | class ProvidedDependency @Inject constructor() 25 | 26 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/external_setup_analyzer/provided_by_with_non_container_argument/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.external_setup_analyzer.provided_by_with_non_container_argument 18 | 19 | import com.joom.lightsaber.ProvidedBy 20 | import javax.inject.Inject 21 | 22 | @ProvidedBy(Any::class) 23 | class AppDependency @Inject constructor() 24 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/factory_parser/factory_creating_instance_with_multiple_factory_inject/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.factory_parser.factory_creating_instance_with_multiple_factory_inject 18 | 19 | import com.joom.lightsaber.Factory 20 | 21 | class Instance @Factory.Inject constructor() { 22 | @Factory.Inject 23 | constructor(param: String) : this() 24 | } 25 | 26 | @Factory 27 | interface FactoryInterface { 28 | fun buildInstance(): Instance 29 | } 30 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/factory_parser/factory_creating_instance_with_without_factory_parameter/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.factory_parser.factory_creating_instance_with_without_factory_parameter 18 | 19 | import com.joom.lightsaber.Factory 20 | 21 | class Instance @Factory.Inject constructor(@Factory.Parameter val param: String) 22 | 23 | @Factory 24 | interface FactoryInterface { 25 | fun buildInstance(): Instance 26 | } 27 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/factory_parser/factory_creating_instance_without_factory_inject/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.factory_parser.factory_creating_instance_without_factory_inject 18 | 19 | import com.joom.lightsaber.Factory 20 | 21 | class Instance 22 | 23 | @Factory 24 | interface FactoryInterface { 25 | fun buildInstance(): Instance 26 | } 27 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/factory_parser/factory_return_with_non_class_argument/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.factory_parser.factory_return_with_non_class_argument 18 | 19 | import com.joom.lightsaber.Factory 20 | 21 | @Factory 22 | interface FactoryInterface { 23 | 24 | @Factory.Return(Int::class) 25 | fun buildInstance(): Int 26 | } 27 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/factory_parser/factory_with_void_methods/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.factory_parser.factory_with_void_methods 18 | 19 | import com.joom.lightsaber.Factory 20 | 21 | @Factory 22 | interface FactoryInterface { 23 | fun buildInstance() 24 | } 25 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/generator/bounded_generics/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.generator.bounded_generics 18 | 19 | import com.joom.lightsaber.ContractConfiguration 20 | import com.joom.lightsaber.Provide 21 | 22 | interface Key 23 | 24 | interface Value { 25 | val value: T 26 | } 27 | 28 | interface GenericContainerValue 29 | 30 | interface GenericContract { 31 | val value: GenericContainerValue> 32 | } 33 | 34 | class GenericContractConfiguration : ContractConfiguration() { 35 | 36 | @Provide 37 | fun provideValue(): GenericContainerValue> { 38 | return object : GenericContainerValue> {} 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/generator/parameterized_type/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.generator.parameterized_type 18 | 19 | import com.joom.lightsaber.Module 20 | import com.joom.lightsaber.ProvidedBy 21 | import javax.inject.Inject 22 | 23 | @Module 24 | class DependencyModule 25 | 26 | interface TypedDependency 27 | 28 | @ProvidedBy(DependencyModule::class) 29 | class Dependency @Inject constructor( 30 | val dependency: TypedDependency 31 | ) 32 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/import_parser/import_kotlin_lazy_contract/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.import_parser.import_kotlin_lazy_contract 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.Import 22 | import com.joom.lightsaber.Module 23 | 24 | @Contract 25 | interface AppContract 26 | 27 | interface LazyContract 28 | 29 | @Module 30 | class AppContractConfiguration( 31 | @Import @Contract val lazyContract: Lazy = lazy { object : LazyContract {} } 32 | ) : ContractConfiguration() 33 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/import_parser/import_lazy_contract/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.import_parser.import_lazy_contract 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.Import 22 | import com.joom.lightsaber.Lazy 23 | import com.joom.lightsaber.Module 24 | 25 | @Contract 26 | interface AppContract 27 | 28 | interface LazyContract 29 | 30 | @Module 31 | class AppContractConfiguration( 32 | @Import @Contract val lazyContract: Lazy = Lazy { object : LazyContract {} } 33 | ) : ContractConfiguration() 34 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/import_parser/import_lazy_module/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.import_parser.import_lazy_module 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.Import 22 | import com.joom.lightsaber.Lazy 23 | import com.joom.lightsaber.Module 24 | 25 | @Contract 26 | interface AppContract 27 | 28 | class AppContractConfiguration : ContractConfiguration() { 29 | 30 | @Import 31 | private fun importAppModule(): Lazy { 32 | return Lazy { AppModule() } 33 | } 34 | } 35 | 36 | @Module 37 | class AppModule 38 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/import_parser/import_method_with_parameters/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.import_parser.import_method_with_parameters 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.Import 22 | import com.joom.lightsaber.Module 23 | 24 | @Contract 25 | interface AppContract 26 | 27 | class AppContractConfiguration : ContractConfiguration() { 28 | @Import 29 | fun importAppModule(parameter: String): AppModule { 30 | return AppModule() 31 | } 32 | } 33 | 34 | @Module 35 | class AppModule 36 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/injection_target_analyzer/class_with_multiple_injectable_constructors/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.injection_target_analyzer.class_with_multiple_injectable_constructors 18 | 19 | import javax.inject.Inject 20 | 21 | class Instance @Inject constructor() { 22 | 23 | @Inject 24 | constructor(parameter: String) : this() 25 | } 26 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/module_parser/module_with_type_parameters/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.module_parser.module_with_type_parameters 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | 22 | @Contract 23 | interface AppContract 24 | 25 | class AppContractConfiguration : ContractConfiguration() 26 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/module_parser/module_without_annotation/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.module_parser.module_without_annotation 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.Import 22 | 23 | @Contract 24 | interface AppContract 25 | 26 | class AppContractConfiguration : ContractConfiguration() { 27 | 28 | @Import 29 | private fun importAppModule(): NonAnnotatedModule { 30 | return NonAnnotatedModule() 31 | } 32 | } 33 | 34 | class NonAnnotatedModule 35 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/abstract_contract_configuration/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.abstract_contract_configuration 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | 22 | @Contract 23 | interface AppContract 24 | 25 | abstract class AppContractConfiguration : ContractConfiguration() 26 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/factory_contains_generic_parameters/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.factory_contains_generic_parameters 18 | 19 | import com.joom.lightsaber.Factory 20 | 21 | @Factory 22 | interface FactoryInterface 23 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/factory_creating_instance_type_differ_from_return_annotation/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.factory_creating_instance_type_differ_from_return_annotation 18 | 19 | import com.joom.lightsaber.Factory 20 | 21 | class Instance @Factory.Inject constructor() 22 | class ActualInstance @Factory.Inject constructor() 23 | 24 | @Factory 25 | interface FactoryInterface { 26 | 27 | @Factory.Return(ActualInstance::class) 28 | fun buildInstance(): Instance 29 | } 30 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/factory_is_not_an_interface/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.factory_is_not_an_interface 18 | 19 | import com.joom.lightsaber.Factory 20 | import javax.inject.Inject 21 | 22 | @Factory 23 | class FactoryClass @Inject constructor() 24 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/factory_without_methods/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.factory_without_methods 18 | 19 | import com.joom.lightsaber.Factory 20 | 21 | @Factory 22 | interface FactoryInterface 23 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/invalid_access_level/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.invalid_access_level 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.ProvidedBy 22 | import javax.inject.Inject 23 | 24 | @Contract 25 | interface AppContract 26 | 27 | class AppContractConfiguration : ContractConfiguration() 28 | 29 | @ProvidedBy(AppContractConfiguration::class) 30 | abstract class AbstractClassDependency @Inject constructor() 31 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/invalid_provided_as/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.invalid_provided_as 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.ProvidedAs 22 | import com.joom.lightsaber.ProvidedBy 23 | import javax.inject.Inject 24 | 25 | @Contract 26 | interface AppContract 27 | 28 | class AppContractConfiguration : ContractConfiguration() 29 | 30 | @ProvidedBy(AppContractConfiguration::class) 31 | @ProvidedAs(String::class) 32 | class Dependency @Inject constructor() 33 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/module_inherits_contract_configuration_class/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.module_inherits_contract_configuration_class 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.Module 22 | 23 | @Contract 24 | interface AppContract 25 | 26 | @Module 27 | class AppContractConfiguration : ContractConfiguration() 28 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/module_with_invalid_parent/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.module_with_invalid_parent 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.Import 22 | import com.joom.lightsaber.Module 23 | 24 | @Contract 25 | interface AppContract 26 | 27 | class AppContractConfiguration : ContractConfiguration() { 28 | 29 | @Import 30 | private fun importAppModule(): AppModule { 31 | return AppModule() 32 | } 33 | } 34 | 35 | abstract class AppModuleSuper 36 | 37 | @Module 38 | class AppModule : AppModuleSuper() 39 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/non_constructable_module_with_imported_by/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.non_constructable_module_with_imported_by 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.ImportedBy 22 | import com.joom.lightsaber.Module 23 | 24 | @Contract 25 | interface AppContract 26 | 27 | class AppContractConfiguration : ContractConfiguration() 28 | 29 | @Module 30 | @ImportedBy(AppContractConfiguration::class) 31 | class AppModule(param: String) 32 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/provide_as_with_generic_argument_class/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.provide_as_with_generic_argument_class 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.ProvidedAs 22 | import com.joom.lightsaber.ProvidedBy 23 | import javax.inject.Inject 24 | 25 | @Contract 26 | interface AppContract 27 | 28 | class AppContractConfiguration : ContractConfiguration() 29 | 30 | @ProvidedAs(List::class) 31 | @ProvidedBy(AppContractConfiguration::class) 32 | class Dependency @Inject constructor() 33 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/provide_as_with_generic_host_class/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.provide_as_with_generic_host_class 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.ProvidedAs 22 | import com.joom.lightsaber.ProvidedBy 23 | import javax.inject.Inject 24 | 25 | @Contract 26 | interface AppContract 27 | 28 | class AppContractConfiguration : ContractConfiguration() 29 | 30 | @ProvidedAs(List::class) 31 | @ProvidedBy(AppContractConfiguration::class) 32 | class Dependency @Inject constructor() 33 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/provide_as_with_host_class_as_argument/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.provide_as_with_host_class_as_argument 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.ProvidedAs 22 | import com.joom.lightsaber.ProvidedBy 23 | import javax.inject.Inject 24 | 25 | @Contract 26 | interface AppContract 27 | 28 | class AppContractConfiguration : ContractConfiguration() 29 | 30 | @ProvidedAs(Dependency::class) 31 | @ProvidedBy(AppContractConfiguration::class) 32 | class Dependency @Inject constructor() 33 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/sanity/provide_as_with_not_inherited_argument/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.sanity.provide_as_with_not_inherited_argument 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.ProvidedAs 22 | import com.joom.lightsaber.ProvidedBy 23 | import javax.inject.Inject 24 | 25 | @Contract 26 | interface AppContract 27 | 28 | class AppContractConfiguration : ContractConfiguration() 29 | 30 | @ProvidedAs(InterfaceThatHostClassDoesNotInherit::class) 31 | @ProvidedBy(AppContractConfiguration::class) 32 | class Dependency @Inject constructor() 33 | 34 | interface InterfaceThatHostClassDoesNotInherit 35 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/contract_duplicates/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.contract_duplicates 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.Import 22 | import com.joom.lightsaber.Lazy 23 | import com.joom.lightsaber.Module 24 | 25 | @Contract 26 | interface AppContract 27 | 28 | interface LazyContract 29 | 30 | @Module 31 | class AppContractConfiguration( 32 | @Import @Contract val lazyContract1: LazyContract = object : LazyContract {}, 33 | @Import @Contract val lazyContract2: Lazy = Lazy { object : LazyContract {} } 34 | ) : ContractConfiguration() 35 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/dependency_missed/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.dependency_missed 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | 22 | @Contract 23 | interface AppContract { 24 | val dependency: MissedDependencyInterface 25 | } 26 | 27 | class AppContractConfiguration : ContractConfiguration() 28 | 29 | interface MissedDependencyInterface 30 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/module_duplicates/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.module_duplicates 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.Import 22 | import com.joom.lightsaber.Module 23 | 24 | @Contract 25 | interface AppContract 26 | 27 | class AppContractConfiguration : ContractConfiguration() { 28 | 29 | @Import 30 | private fun importAppModule1(): AppModule { 31 | return AppModule() 32 | } 33 | 34 | @Import 35 | private fun importAppModule2(): AppModule { 36 | return AppModule() 37 | } 38 | } 39 | 40 | @Module 41 | class AppModule 42 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/provided_as_without_provided_by/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.provided_as_without_provided_by 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.ProvidedAs 22 | 23 | @Contract 24 | interface AppContract { 25 | val dependency: DependencyInterface 26 | } 27 | 28 | class AppContractConfiguration : ContractConfiguration() 29 | 30 | interface DependencyInterface 31 | 32 | @ProvidedAs(DependencyInterface::class) 33 | internal class DependencyImplementation : DependencyInterface 34 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/provided_by_separate_module/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.provided_by_separate_module 18 | 19 | import com.joom.lightsaber.Module 20 | import com.joom.lightsaber.ProvidedBy 21 | import javax.inject.Inject 22 | 23 | @ProvidedBy(DependencyModule::class) 24 | class Dependency @Inject constructor() 25 | 26 | @Module 27 | class DependencyModule 28 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/provided_by_without_inject/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.provided_by_without_inject 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.ProvidedAs 22 | import com.joom.lightsaber.ProvidedBy 23 | 24 | @Contract 25 | interface AppContract 26 | 27 | class AppContractConfiguration : ContractConfiguration() 28 | 29 | @ProvidedBy(AppContractConfiguration::class) 30 | @ProvidedAs(DependencyInterface::class) 31 | internal class DependencyImplementation : DependencyInterface 32 | 33 | interface DependencyInterface 34 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/separate_module_dependency_missing/Configuration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.separate_module_dependency_missing 18 | 19 | import com.joom.lightsaber.Module 20 | import com.joom.lightsaber.Provide 21 | 22 | class FirstDependency 23 | 24 | class SecondDependency(private val firstDependency: FirstDependency) 25 | 26 | @Module 27 | class MyModule { 28 | 29 | @Provide 30 | fun provideDependency(firstDependency: FirstDependency): SecondDependency { 31 | return SecondDependency(firstDependency) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration/AppContract.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration 18 | 19 | import com.joom.lightsaber.Contract 20 | import com.joom.lightsaber.ContractConfiguration 21 | import com.joom.lightsaber.Import 22 | 23 | @Contract 24 | interface AppContract { 25 | val dependency: DependencyInterface 26 | } 27 | 28 | class AppContractConfiguration : ContractConfiguration() { 29 | 30 | @Import 31 | private fun importAppModule(): AppModule { 32 | return AppModule() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration/AppMain.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration 18 | 19 | import com.joom.lightsaber.Lightsaber 20 | 21 | class AppMain { 22 | companion object { 23 | @JvmStatic 24 | fun main(args: Array) { 25 | AppMain().run() 26 | } 27 | } 28 | 29 | fun run() { 30 | val injector = Lightsaber.Builder().build() 31 | val contract = injector.createContract(AppContractConfiguration()) 32 | 33 | contract.dependency.foo() 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration/AppModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration 18 | 19 | import com.joom.lightsaber.Module 20 | 21 | @Module 22 | class AppModule 23 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration/DependencyImplementation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration 18 | 19 | import com.joom.lightsaber.ProvidedAs 20 | import com.joom.lightsaber.ProvidedBy 21 | import javax.inject.Inject 22 | 23 | @ProvidedBy(AppContractConfiguration::class) 24 | @ProvidedAs(DependencyInterface::class) 25 | internal class DependencyImplementation @Inject constructor() : DependencyInterface { 26 | override fun foo() { 27 | print("bar") 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration/DependencyInterface.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration 18 | 19 | interface DependencyInterface { 20 | fun foo() 21 | } 22 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration_with_lazy_imports/AnotherDependencyImplementation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration_with_lazy_imports 18 | 19 | import com.joom.lightsaber.ProvidedAs 20 | import com.joom.lightsaber.ProvidedBy 21 | import javax.inject.Inject 22 | 23 | @ProvidedBy(LazyContractConfiguration::class) 24 | @ProvidedAs(AnotherDependencyInterface::class) 25 | internal class AnotherDependencyImplementation @Inject constructor() : AnotherDependencyInterface { 26 | override fun bar() { 27 | print("foo") 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration_with_lazy_imports/AnotherDependencyInterface.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration_with_lazy_imports 18 | 19 | interface AnotherDependencyInterface { 20 | fun bar() 21 | } 22 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration_with_lazy_imports/AppModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration_with_lazy_imports 18 | 19 | import com.joom.lightsaber.Module 20 | 21 | @Module 22 | class AppModule 23 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration_with_lazy_imports/DependencyInterface.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration_with_lazy_imports 18 | 19 | interface DependencyInterface { 20 | fun foo() 21 | } 22 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration_with_lazy_imports/YetAnotherDependencyImplementation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration_with_lazy_imports 18 | 19 | import com.joom.lightsaber.ProvidedAs 20 | import com.joom.lightsaber.ProvidedBy 21 | import javax.inject.Inject 22 | 23 | @ProvidedBy(AppModule::class) 24 | @ProvidedAs(YetAnotherDependencyInterface::class) 25 | internal class YetAnotherDependencyImplementation @Inject constructor() : YetAnotherDependencyInterface { 26 | override fun foobar() { 27 | print("foobar") 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration_with_lazy_imports/YetAnotherDependencyImplementation2.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration_with_lazy_imports 18 | 19 | import com.joom.lightsaber.ProvidedAs 20 | import com.joom.lightsaber.ProvidedBy 21 | import javax.inject.Inject 22 | 23 | @ProvidedBy(KotlinLazyContractConfiguration::class) 24 | @ProvidedAs(YetAnotherDependencyInterface2::class) 25 | internal class YetAnotherDependencyImplementation2 @Inject constructor() : YetAnotherDependencyInterface2 { 26 | override fun foobar2() { 27 | print("foobar2") 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration_with_lazy_imports/YetAnotherDependencyInterface.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration_with_lazy_imports 18 | 19 | interface YetAnotherDependencyInterface { 20 | fun foobar() 21 | } 22 | -------------------------------------------------------------------------------- /lightsaber/processor/src/test/resources/test_case_projects/validator/valid_configuration_with_lazy_imports/YetAnotherDependencyInterface2.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package test_case_projects.validator.valid_configuration_with_lazy_imports 18 | 19 | interface YetAnotherDependencyInterface2 { 20 | fun foobar2() 21 | } 22 | -------------------------------------------------------------------------------- /lightsaber/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'lightsaber' 2 | 3 | include ':core' 4 | include ':core-kotlin' 5 | include ':core-test' 6 | include ':gradle-plugin' 7 | include ':processor' 8 | -------------------------------------------------------------------------------- /lightsaber/src/functionalTest/java/com/joom/lightsaber/plugin/GradleDistribution.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | package com.joom.lightsaber.plugin 19 | 20 | enum class GradleDistribution(val url: String) { 21 | GRADLE_7_5("https://services.gradle.org/distributions/gradle-7.5-all.zip"), 22 | GRADLE_8_0("https://services.gradle.org/distributions/gradle-8.0-all.zip"), 23 | } 24 | -------------------------------------------------------------------------------- /samples/injection-test/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'java' 18 | apply plugin: 'kotlin' 19 | apply plugin: 'com.joom.lightsaber' 20 | 21 | sourceCompatibility = javaVersion 22 | targetCompatibility = javaVersion 23 | 24 | dependencies { 25 | implementation "org.jetbrains.kotlin:kotlin-stdlib$kotlinRuntimeVariant:$kotlinVersion" 26 | 27 | testImplementation "com.joom.lightsaber:lightsaber-core-kotlin:$version" 28 | testImplementation "com.joom.lightsaber:lightsaber-test:$version" 29 | testImplementation "junit:junit:$junitVersion" 30 | } 31 | 32 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { 33 | kotlinOptions { 34 | jvmTarget = javaVersion 35 | apiVersion = kotlinLanguageVersion 36 | languageVersion = kotlinLanguageVersion 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /samples/injection-test/src/main/java/Main.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Just add main to make the compiler happy. 18 | fun main() { 19 | } 20 | -------------------------------------------------------------------------------- /samples/injection-test/src/test/java/com/joom/lightsaber/access/AccessComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.access; 18 | 19 | import com.joom.lightsaber.Component; 20 | import com.joom.lightsaber.Import; 21 | 22 | @Component 23 | class AccessComponent { 24 | @Import 25 | private AccessModule importAccessModule() { 26 | return new AccessModule(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /samples/injection-test/src/test/java/com/joom/lightsaber/access/InternalDependency.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.access; 18 | 19 | interface InternalDependency { 20 | void action(); 21 | } 22 | -------------------------------------------------------------------------------- /samples/injection-test/src/test/java/com/joom/lightsaber/access/InternalDependencyImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.access; 18 | 19 | import com.joom.lightsaber.ProvidedBy; 20 | 21 | import javax.inject.Inject; 22 | 23 | @ProvidedBy(AccessModule.class) 24 | class InternalDependencyImpl implements InternalDependency { 25 | @Inject 26 | public InternalDependencyImpl() { 27 | } 28 | 29 | @Override 30 | public void action() { 31 | } 32 | 33 | @Inject 34 | private void privateMethod() { 35 | } 36 | 37 | @Inject 38 | void internalMethod() { 39 | } 40 | 41 | @Inject 42 | protected void protectedMethod() { 43 | } 44 | 45 | @Inject 46 | public void publicMethod() { 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /samples/injection-test/src/test/java/com/joom/lightsaber/access/InternalGenericDependency.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.access; 18 | 19 | @SuppressWarnings("unused") 20 | interface InternalGenericDependency { 21 | void action(); 22 | } 23 | -------------------------------------------------------------------------------- /samples/injection-test/src/test/java/com/joom/lightsaber/access/InternalGenericDependencyImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.access; 18 | 19 | import com.joom.lightsaber.ProvidedBy; 20 | 21 | import javax.inject.Inject; 22 | 23 | @ProvidedBy(AccessModule.class) 24 | class InternalGenericDependencyImpl implements InternalGenericDependency { 25 | @Inject 26 | public InternalGenericDependencyImpl() { 27 | } 28 | 29 | @Override 30 | public void action() { 31 | } 32 | 33 | @Inject 34 | private void privateMethod() { 35 | } 36 | 37 | @Inject 38 | void internalMethod() { 39 | } 40 | 41 | @Inject 42 | protected void protectedMethod() { 43 | } 44 | 45 | @Inject 46 | public void publicMethod() { 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /samples/injection-test/src/test/java/com/joom/lightsaber/access/InternalQualifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.access; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import javax.inject.Qualifier; 25 | 26 | @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD }) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Qualifier 29 | @interface InternalQualifier { 30 | } 31 | -------------------------------------------------------------------------------- /samples/injection-test/src/test/java/com/joom/lightsaber/access/SingletonQualifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.access; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import javax.inject.Qualifier; 25 | 26 | @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD }) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Qualifier 29 | @interface SingletonQualifier { 30 | } 31 | -------------------------------------------------------------------------------- /samples/sample-android-kotlin/proguard.pro: -------------------------------------------------------------------------------- 1 | -dontwarn kotlin.** 2 | -------------------------------------------------------------------------------- /samples/sample-android-kotlin/src/androidTest/java/com/joom/lightsaber/sample/MainActivityTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | import androidx.test.ext.junit.rules.ActivityScenarioRule 20 | import androidx.test.ext.junit.runners.AndroidJUnit4 21 | import androidx.test.filters.LargeTest 22 | import org.junit.Rule 23 | import org.junit.Test 24 | import org.junit.runner.RunWith 25 | 26 | @LargeTest 27 | @RunWith(AndroidJUnit4::class) 28 | class MainActivityTest { 29 | 30 | @get:Rule 31 | val activityScenarioRule = ActivityScenarioRule(MainActivity::class.java) 32 | 33 | @Test 34 | fun mainActivityTest() = Unit 35 | } 36 | -------------------------------------------------------------------------------- /samples/sample-android-kotlin/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 21 | 22 | 23 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /samples/sample-android-kotlin/src/main/java/com/joom/lightsaber/sample/Chewbacca.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | import com.joom.lightsaber.ProvidedAs 20 | import com.joom.lightsaber.ProvidedBy 21 | import com.joom.lightsaber.sample.library.Planet 22 | import javax.inject.Inject 23 | import javax.inject.Provider 24 | import javax.inject.Singleton 25 | 26 | @Singleton 27 | @ProvidedAs(Wookiee::class) 28 | @ProvidedBy(LightsaberModule::class) 29 | internal class Chewbacca @Inject private constructor( 30 | planetProvider: Provider 31 | ) : Wookiee { 32 | 33 | override val planet: Planet = planetProvider.get() 34 | 35 | override fun roar() { 36 | System.out.println("AULRGHHHGR") 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /samples/sample-android-kotlin/src/main/java/com/joom/lightsaber/sample/DarthVader.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | object DarthVader 20 | -------------------------------------------------------------------------------- /samples/sample-android-kotlin/src/main/java/com/joom/lightsaber/sample/DroidFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | import com.joom.lightsaber.Factory 20 | import com.joom.lightsaber.ProvidedBy 21 | import com.joom.lightsaber.sample.library.Droid 22 | 23 | @Factory 24 | @ProvidedBy(LightsaberModule::class) 25 | internal interface DroidFactory { 26 | 27 | @Factory.Return(R2D2::class) 28 | fun produceR2D2(color: String): Droid 29 | } 30 | -------------------------------------------------------------------------------- /samples/sample-android-kotlin/src/main/java/com/joom/lightsaber/sample/LightsaberComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | import com.joom.lightsaber.Component 20 | import com.joom.lightsaber.Import 21 | import com.joom.lightsaber.Provide 22 | import com.joom.lightsaber.sample.library.LibraryModule 23 | 24 | @Component 25 | internal class LightsaberComponent { 26 | 27 | @Provide 28 | private val darthVader = DarthVader 29 | 30 | @Import 31 | private fun importLibraryModule(): LibraryModule { 32 | return LibraryModule() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /samples/sample-android-kotlin/src/main/java/com/joom/lightsaber/sample/LightsaberModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | import com.joom.lightsaber.ImportedBy 20 | import com.joom.lightsaber.Module 21 | import com.joom.lightsaber.Provide 22 | import com.joom.lightsaber.sample.library.Droid 23 | 24 | @Module 25 | @ImportedBy(LightsaberComponent::class) 26 | internal class LightsaberModule { 27 | 28 | @Provide 29 | private fun provideDroid(factory: DroidFactory): Droid = factory.produceR2D2("Silver") 30 | } 31 | -------------------------------------------------------------------------------- /samples/sample-android-kotlin/src/main/java/com/joom/lightsaber/sample/Wookiee.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | import com.joom.lightsaber.sample.library.Planet 20 | 21 | interface Wookiee { 22 | val planet: Planet 23 | fun roar() 24 | } 25 | -------------------------------------------------------------------------------- /samples/sample-android-kotlin/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Lightsaber Kotlin 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/sample-android-library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.joom.lightsaber.android' 3 | 4 | android { 5 | compileSdk androidCompileSdkVersion 6 | buildToolsVersion androidBuildToolsVersion 7 | 8 | defaultConfig { 9 | minSdkVersion androidMinSdkVersion 10 | targetSdkVersion androidTargetSdkVersion 11 | versionCode 1 12 | versionName version 13 | 14 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 15 | } 16 | 17 | compileOptions { 18 | sourceCompatibility javaVersion 19 | targetCompatibility javaVersion 20 | } 21 | 22 | lintOptions { 23 | checkReleaseBuilds false 24 | } 25 | } 26 | 27 | dependencies { 28 | implementation "com.joom.lightsaber:lightsaber-core:$version" 29 | implementation "androidx.annotation:annotation:$androidxAnnotationVersion" 30 | 31 | androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoVersion" 32 | androidTestImplementation "androidx.test:runner:$androidxTestRunnerVersion" 33 | androidTestImplementation "androidx.test:rules:$androidxTestRunnerVersion" 34 | androidTestImplementation "androidx.test.ext:junit:$androidxTestExtJunitVersion" 35 | androidTestImplementation "androidx.annotation:annotation:$androidxAnnotationVersion" 36 | 37 | testImplementation "junit:junit:$junitVersion" 38 | } 39 | -------------------------------------------------------------------------------- /samples/sample-android-library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /samples/sample-android-library/src/main/java/com/joom/lightsaber/sample/library/Droid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample.library; 18 | 19 | public interface Droid { 20 | void repair(); 21 | } 22 | -------------------------------------------------------------------------------- /samples/sample-android-library/src/main/java/com/joom/lightsaber/sample/library/LibraryModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample.library; 18 | 19 | import javax.inject.Provider; 20 | import javax.inject.Singleton; 21 | 22 | import com.joom.lightsaber.Module; 23 | import com.joom.lightsaber.Provide; 24 | 25 | @Module 26 | public class LibraryModule { 27 | @Provide 28 | @Singleton 29 | private Planet providePlanet(final Provider kashyyykProvider) { 30 | return kashyyykProvider.get(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /samples/sample-android-library/src/main/java/com/joom/lightsaber/sample/library/Planet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample.library; 18 | 19 | public interface Planet { 20 | String getName(); 21 | 22 | String getSector(); 23 | } 24 | -------------------------------------------------------------------------------- /samples/sample-android-library/src/test/java/com/joom/lightsaber/sample/library/UnitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample.library; 18 | 19 | import org.junit.Test; 20 | 21 | public class UnitTest { 22 | @Test 23 | public void emptyTest() throws Exception { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /samples/sample-java/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'application' 3 | apply plugin: 'com.joom.lightsaber' 4 | 5 | sourceCompatibility = javaVersion 6 | targetCompatibility = javaVersion 7 | 8 | mainClassName = 'com.joom.lightsaber.sample.LightsaberSample' 9 | 10 | dependencies { 11 | testImplementation "junit:junit:$junitVersion" 12 | } 13 | 14 | jar { 15 | destinationDirectory.set(file('build/jar')) 16 | 17 | from { 18 | configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } 19 | } 20 | } 21 | 22 | lightsaber { 23 | processTest false 24 | } 25 | -------------------------------------------------------------------------------- /samples/sample-java/src/main/java/com/joom/lightsaber/sample/DarthVader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample; 18 | 19 | public class DarthVader { 20 | public static final DarthVader INSTANCE = new DarthVader(); 21 | 22 | private DarthVader() { 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /samples/sample-java/src/main/java/com/joom/lightsaber/sample/Droid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample; 18 | 19 | public interface Droid { 20 | void repair(); 21 | } 22 | -------------------------------------------------------------------------------- /samples/sample-java/src/main/java/com/joom/lightsaber/sample/DroidFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample; 18 | 19 | import com.joom.lightsaber.Factory; 20 | import com.joom.lightsaber.ProvidedBy; 21 | 22 | @Factory 23 | @ProvidedBy(LightsaberModule.class) 24 | public interface DroidFactory { 25 | @Factory.Return(R2D2.class) 26 | Droid produceR2D2(final String color); 27 | } 28 | -------------------------------------------------------------------------------- /samples/sample-java/src/main/java/com/joom/lightsaber/sample/LightsaberComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample; 18 | 19 | import com.joom.lightsaber.Component; 20 | import com.joom.lightsaber.Provide; 21 | 22 | @Component 23 | class LightsaberComponent { 24 | @Provide 25 | private final DarthVader darthVader = DarthVader.INSTANCE; 26 | } 27 | -------------------------------------------------------------------------------- /samples/sample-java/src/main/java/com/joom/lightsaber/sample/LightsaberModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample; 18 | 19 | import com.joom.lightsaber.ImportedBy; 20 | import com.joom.lightsaber.Module; 21 | import com.joom.lightsaber.Provide; 22 | 23 | import javax.inject.Provider; 24 | import javax.inject.Singleton; 25 | 26 | @Module 27 | @ImportedBy(LightsaberComponent.class) 28 | class LightsaberModule { 29 | @Provide 30 | private Droid provideDroid(final DroidFactory factory) { 31 | return factory.produceR2D2("Silver"); 32 | } 33 | 34 | @Provide 35 | @Singleton 36 | private Planet providePlanet(final Provider kashyyykProvider) { 37 | return kashyyykProvider.get(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /samples/sample-java/src/main/java/com/joom/lightsaber/sample/Planet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample; 18 | 19 | interface Planet { 20 | String getName(); 21 | 22 | String getSector(); 23 | } 24 | -------------------------------------------------------------------------------- /samples/sample-java/src/main/java/com/joom/lightsaber/sample/Wookiee.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample; 18 | 19 | public interface Wookiee { 20 | void roar(); 21 | 22 | Planet getPlanet(); 23 | } 24 | -------------------------------------------------------------------------------- /samples/sample-kotlin-modular/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'application' 4 | apply plugin: 'com.joom.lightsaber' 5 | 6 | sourceCompatibility = javaVersion 7 | targetCompatibility = javaVersion 8 | 9 | mainClassName = 'com.joom.lightsaber.modular.ModularSample' 10 | 11 | dependencies { 12 | implementation "com.joom.lightsaber:lightsaber-core:$version" 13 | implementation "org.jetbrains.kotlin:kotlin-stdlib$kotlinRuntimeVariant:$kotlinVersion" 14 | implementation project(":samples:sample-kotlin-modular:library-contract") 15 | implementation project(":samples:sample-kotlin-modular:library-component") 16 | 17 | testImplementation "junit:junit:$junitVersion" 18 | } 19 | 20 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { 21 | kotlinOptions { 22 | jvmTarget = javaVersion 23 | apiVersion = kotlinLanguageVersion 24 | languageVersion = kotlinLanguageVersion 25 | } 26 | } 27 | 28 | jar { 29 | destinationDirectory.set(file('build/jar')) 30 | duplicatesStrategy DuplicatesStrategy.FAIL 31 | 32 | exclude 'META-INF', 'META-INF/**' 33 | 34 | from { 35 | configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /samples/sample-kotlin-modular/library-component/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'com.joom.lightsaber' 4 | 5 | sourceCompatibility = javaVersion 6 | targetCompatibility = javaVersion 7 | 8 | dependencies { 9 | implementation "org.jetbrains.kotlin:kotlin-stdlib$kotlinRuntimeVariant:$kotlinVersion" 10 | } 11 | 12 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { 13 | kotlinOptions { 14 | jvmTarget = javaVersion 15 | apiVersion = kotlinLanguageVersion 16 | languageVersion = kotlinLanguageVersion 17 | } 18 | } 19 | 20 | lightsaber { 21 | processTest false 22 | } 23 | -------------------------------------------------------------------------------- /samples/sample-kotlin-modular/library-component/src/main/java/com/joom/lightsaber/modular/ComponentDependency.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.modular 18 | 19 | import com.joom.lightsaber.ProvidedAs 20 | import com.joom.lightsaber.ProvidedBy 21 | import javax.inject.Inject 22 | 23 | interface ComponentDependency { 24 | fun printInfo() 25 | } 26 | 27 | @ProvidedBy(LibraryComponent::class) 28 | @ProvidedAs(ComponentDependency::class) 29 | internal class ComponentDependencyImpl @Inject constructor() : ComponentDependency { 30 | override fun printInfo() { 31 | println("ComponentDependencyImpl") 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /samples/sample-kotlin-modular/library-component/src/main/java/com/joom/lightsaber/modular/LibraryComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.modular 18 | 19 | import com.joom.lightsaber.Component 20 | 21 | @Suppress("DEPRECATION") 22 | @Component 23 | class LibraryComponent 24 | -------------------------------------------------------------------------------- /samples/sample-kotlin-modular/library-contract/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'com.joom.lightsaber' 4 | 5 | sourceCompatibility = javaVersion 6 | targetCompatibility = javaVersion 7 | 8 | dependencies { 9 | implementation "org.jetbrains.kotlin:kotlin-stdlib$kotlinRuntimeVariant:$kotlinVersion" 10 | 11 | api project(":samples:sample-kotlin-modular:library-module") 12 | api project(":samples:sample-kotlin-modular:library-factory") 13 | } 14 | 15 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { 16 | kotlinOptions { 17 | jvmTarget = javaVersion 18 | apiVersion = kotlinLanguageVersion 19 | languageVersion = kotlinLanguageVersion 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /samples/sample-kotlin-modular/library-factory/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'com.joom.lightsaber' 4 | 5 | sourceCompatibility = javaVersion 6 | targetCompatibility = javaVersion 7 | 8 | dependencies { 9 | implementation "org.jetbrains.kotlin:kotlin-stdlib$kotlinRuntimeVariant:$kotlinVersion" 10 | } 11 | 12 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { 13 | kotlinOptions { 14 | jvmTarget = javaVersion 15 | apiVersion = kotlinLanguageVersion 16 | languageVersion = kotlinLanguageVersion 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /samples/sample-kotlin-modular/library-factory/src/main/java/com/joom/lightsaber/modular/FactoryDependency.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.modular 18 | 19 | import com.joom.lightsaber.Factory 20 | 21 | interface FactoryDependency { 22 | fun printInfo() 23 | } 24 | 25 | internal class FactoryDependencyImpl @Factory.Inject constructor() : FactoryDependency { 26 | override fun printInfo() { 27 | println("FactoryDependencyImpl") 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /samples/sample-kotlin-modular/library-factory/src/main/java/com/joom/lightsaber/modular/LibraryFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.modular 18 | 19 | import com.joom.lightsaber.Factory 20 | import com.joom.lightsaber.ProvidedBy 21 | 22 | @Factory 23 | @ProvidedBy(LibraryFactoryModule::class) 24 | interface LibraryFactory { 25 | @Factory.Return(FactoryDependencyImpl::class) 26 | fun create(): FactoryDependency 27 | } 28 | -------------------------------------------------------------------------------- /samples/sample-kotlin-modular/library-factory/src/main/java/com/joom/lightsaber/modular/LibraryFactoryModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.modular 18 | 19 | import com.joom.lightsaber.Module 20 | 21 | @Module 22 | class LibraryFactoryModule 23 | -------------------------------------------------------------------------------- /samples/sample-kotlin-modular/library-module/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'com.joom.lightsaber' 4 | 5 | sourceCompatibility = javaVersion 6 | targetCompatibility = javaVersion 7 | 8 | dependencies { 9 | implementation "org.jetbrains.kotlin:kotlin-stdlib$kotlinRuntimeVariant:$kotlinVersion" 10 | } 11 | 12 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { 13 | kotlinOptions { 14 | jvmTarget = javaVersion 15 | apiVersion = kotlinLanguageVersion 16 | languageVersion = kotlinLanguageVersion 17 | } 18 | } 19 | 20 | lightsaber { 21 | processTest false 22 | } 23 | -------------------------------------------------------------------------------- /samples/sample-kotlin-modular/library-module/src/main/java/com/joom/lightsaber/modular/LibraryContract.kt: -------------------------------------------------------------------------------- 1 | package com.joom.lightsaber.modular 2 | 3 | import com.joom.lightsaber.ContractConfiguration 4 | import com.joom.lightsaber.Provide 5 | import javax.inject.Qualifier 6 | 7 | @Qualifier 8 | @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.FIELD, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.VALUE_PARAMETER) 9 | @Retention(AnnotationRetention.RUNTIME) 10 | annotation class ContractQualifier 11 | 12 | interface LibraryContract { 13 | @get:ContractQualifier 14 | val qualifiedContractDependency: ModuleDependency 15 | } 16 | 17 | class LibraryContractConfiguration : ContractConfiguration() { 18 | @Provide 19 | @ContractQualifier 20 | fun provideQualifiedDependency(): ModuleDependency { 21 | return object : ModuleDependency { 22 | override fun printInfo() { 23 | println("QualifiedContractDependencyImpl") 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /samples/sample-kotlin/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'application' 4 | apply plugin: 'com.joom.lightsaber' 5 | 6 | sourceCompatibility = javaVersion 7 | targetCompatibility = javaVersion 8 | 9 | mainClassName = 'com.joom.lightsaber.sample.LightsaberSample' 10 | 11 | dependencies { 12 | implementation "org.jetbrains.kotlin:kotlin-stdlib$kotlinRuntimeVariant:$kotlinVersion" 13 | 14 | testImplementation "junit:junit:$junitVersion" 15 | } 16 | 17 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { 18 | kotlinOptions { 19 | jvmTarget = javaVersion 20 | apiVersion = kotlinLanguageVersion 21 | languageVersion = kotlinLanguageVersion 22 | } 23 | } 24 | 25 | jar { 26 | destinationDirectory.set(file('build/jar')) 27 | duplicatesStrategy DuplicatesStrategy.FAIL 28 | 29 | exclude 'META-INF', 'META-INF/**' 30 | 31 | from { 32 | configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } 33 | } 34 | } 35 | 36 | lightsaber { 37 | processTest false 38 | } 39 | -------------------------------------------------------------------------------- /samples/sample-kotlin/src/main/java/com/joom/lightsaber/sample/Chewbacca.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | import com.joom.lightsaber.ProvidedAs 20 | import com.joom.lightsaber.ProvidedBy 21 | import javax.inject.Inject 22 | import javax.inject.Provider 23 | import javax.inject.Singleton 24 | 25 | @Singleton 26 | @ProvidedAs(Wookiee::class) 27 | @ProvidedBy(LightsaberModule::class) 28 | internal class Chewbacca @Inject private constructor( 29 | planetProvider: Provider 30 | ) : Wookiee { 31 | 32 | override val planet: Planet = planetProvider.get() 33 | 34 | override fun roar() { 35 | System.out.println("AULRGHHHGR") 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /samples/sample-kotlin/src/main/java/com/joom/lightsaber/sample/DarthVader.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | object DarthVader 20 | -------------------------------------------------------------------------------- /samples/sample-kotlin/src/main/java/com/joom/lightsaber/sample/Droid.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | interface Droid { 20 | fun repair() 21 | } 22 | -------------------------------------------------------------------------------- /samples/sample-kotlin/src/main/java/com/joom/lightsaber/sample/DroidFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | import com.joom.lightsaber.Factory 20 | import com.joom.lightsaber.ProvidedBy 21 | 22 | @Factory 23 | @ProvidedBy(LightsaberModule::class) 24 | internal interface DroidFactory { 25 | 26 | @Factory.Return(R2D2::class) 27 | fun produceR2D2(color: String): Droid 28 | } 29 | -------------------------------------------------------------------------------- /samples/sample-kotlin/src/main/java/com/joom/lightsaber/sample/Kashyyyk.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | import com.joom.lightsaber.ProvidedBy 20 | import javax.inject.Inject 21 | import javax.inject.Singleton 22 | 23 | @Singleton 24 | @ProvidedBy(LightsaberModule::class) 25 | internal class Kashyyyk @Inject private constructor() : Planet { 26 | 27 | override val name = "Kashyyyk" 28 | override val sector = "Mytaranor" 29 | 30 | private var isSettled = false 31 | 32 | @Inject 33 | fun settle(droid1: Droid, droid2: Droid) { 34 | if (isSettled) { 35 | throw IllegalStateException("Already settled") 36 | } 37 | System.out.println("Settling Kashyyyk with $droid1 and $droid2") 38 | isSettled = true 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /samples/sample-kotlin/src/main/java/com/joom/lightsaber/sample/LightsaberComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | import com.joom.lightsaber.Component 20 | import com.joom.lightsaber.Provide 21 | 22 | @Component 23 | internal class LightsaberComponent { 24 | 25 | @Provide 26 | private val darthVader = DarthVader 27 | } 28 | -------------------------------------------------------------------------------- /samples/sample-kotlin/src/main/java/com/joom/lightsaber/sample/LightsaberModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | import com.joom.lightsaber.ImportedBy 20 | import com.joom.lightsaber.Module 21 | import com.joom.lightsaber.Provide 22 | import javax.inject.Provider 23 | import javax.inject.Singleton 24 | 25 | @Module 26 | @ImportedBy(LightsaberComponent::class) 27 | internal class LightsaberModule { 28 | 29 | @Provide 30 | private fun provideDroid(factory: DroidFactory): Droid = factory.produceR2D2("Silver") 31 | 32 | @Provide 33 | @Singleton 34 | private fun providePlanet(kashyyykProvider: Provider): Planet = kashyyykProvider.get() 35 | } 36 | -------------------------------------------------------------------------------- /samples/sample-kotlin/src/main/java/com/joom/lightsaber/sample/Planet.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | interface Planet { 20 | val name: String 21 | val sector: String 22 | } 23 | -------------------------------------------------------------------------------- /samples/sample-kotlin/src/main/java/com/joom/lightsaber/sample/Wookiee.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 SIA Joom 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.joom.lightsaber.sample 18 | 19 | interface Wookiee { 20 | val planet: Planet 21 | fun roar() 22 | } 23 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | def isDevelopment = properties['development'].toBoolean() 2 | 3 | if (isDevelopment) { 4 | includeBuild('lightsaber') { 5 | dependencySubstitution { 6 | substitute module('com.joom.lightsaber:lightsaber-core') using project(':core') 7 | substitute module('com.joom.lightsaber:lightsaber-core-kotlin') using project(':core-kotlin') 8 | substitute module('com.joom.lightsaber:lightsaber-test') using project(':core-test') 9 | substitute module('com.joom.lightsaber:lightsaber-processor') using project(':processor') 10 | substitute module('com.joom.lightsaber:lightsaber-gradle-plugin') using project(':gradle-plugin') 11 | } 12 | } 13 | } 14 | 15 | 16 | include ':samples:injection-test' 17 | include ':samples:sample-java' 18 | include ':samples:sample-kotlin' 19 | include ':samples:sample-android-kotlin' 20 | include ':samples:sample-android-library' 21 | include ':samples:sample-kotlin-modular:app' 22 | include ':samples:sample-kotlin-modular:library-contract' 23 | include ':samples:sample-kotlin-modular:library-module' 24 | include ':samples:sample-kotlin-modular:library-component' 25 | include ':samples:sample-kotlin-modular:library-factory' 26 | --------------------------------------------------------------------------------