From 753a6c60f47f3ac4f270005b65e9d6481de8eb68 Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Fri, 23 Oct 2015 10:00:02 -0700 Subject: Adding maven and ant source trees Change-Id: I0a39b9add833a31b9c3f98d193983ae2f3a5a445 Signed-off-by: Ashlee Young --- .../apache-maven-3.3.3/maven-model-builder/pom.xml | 86 ++ .../building/AbstractModelBuildingListener.java | 37 + .../maven/model/building/DefaultModelBuilder.java | 1309 ++++++++++++++++++++ .../model/building/DefaultModelBuilderFactory.java | 243 ++++ .../model/building/DefaultModelBuildingEvent.java | 64 + .../building/DefaultModelBuildingRequest.java | 408 ++++++ .../model/building/DefaultModelBuildingResult.java | 180 +++ .../maven/model/building/DefaultModelProblem.java | 175 +++ .../building/DefaultModelProblemCollector.java | 200 +++ .../model/building/DefaultModelProcessor.java | 84 ++ .../maven/model/building/FileModelSource.java | 83 ++ .../model/building/FilterModelBuildingRequest.java | 285 +++++ .../apache/maven/model/building/ModelBuilder.java | 67 + .../maven/model/building/ModelBuildingEvent.java | 53 + .../model/building/ModelBuildingEventCatapult.java | 48 + .../model/building/ModelBuildingException.java | 180 +++ .../model/building/ModelBuildingListener.java | 40 + .../maven/model/building/ModelBuildingRequest.java | 338 +++++ .../maven/model/building/ModelBuildingResult.java | 99 ++ .../apache/maven/model/building/ModelCache.java | 56 + .../apache/maven/model/building/ModelCacheTag.java | 132 ++ .../org/apache/maven/model/building/ModelData.java | 222 ++++ .../apache/maven/model/building/ModelProblem.java | 117 ++ .../model/building/ModelProblemCollector.java | 41 + .../model/building/ModelProblemCollectorExt.java | 37 + .../building/ModelProblemCollectorRequest.java | 101 ++ .../maven/model/building/ModelProblemUtils.java | 171 +++ .../maven/model/building/ModelProcessor.java | 32 + .../apache/maven/model/building/ModelSource.java | 38 + .../apache/maven/model/building/ModelSource2.java | 56 + .../org/apache/maven/model/building/Result.java | 255 ++++ .../maven/model/building/StringModelSource.java | 56 + .../maven/model/building/UrlModelSource.java | 46 + .../DefaultDependencyManagementImporter.java | 83 ++ .../composition/DependencyManagementImporter.java | 48 + .../inheritance/DefaultInheritanceAssembler.java | 255 ++++ .../model/inheritance/InheritanceAssembler.java | 48 + .../AbstractStringBasedModelInterpolator.java | 271 ++++ .../interpolation/BuildTimestampValueSource.java | 47 + .../model/interpolation/MavenBuildTimestamp.java | 70 ++ .../model/interpolation/ModelInterpolator.java | 54 + .../PathTranslatingPostProcessor.java | 67 + .../interpolation/ProblemDetectingValueSource.java | 87 ++ .../StringSearchModelInterpolator.java | 504 ++++++++ .../interpolation/UrlNormalizingPostProcessor.java | 69 ++ .../apache/maven/model/io/DefaultModelReader.java | 134 ++ .../apache/maven/model/io/DefaultModelWriter.java | 118 ++ .../apache/maven/model/io/ModelParseException.java | 93 ++ .../org/apache/maven/model/io/ModelReader.java | 89 ++ .../org/apache/maven/model/io/ModelWriter.java | 74 ++ .../maven/model/locator/DefaultModelLocator.java | 42 + .../apache/maven/model/locator/ModelLocator.java | 44 + .../DefaultDependencyManagementInjector.java | 110 ++ .../DefaultPluginManagementInjector.java | 137 ++ .../management/DependencyManagementInjector.java | 44 + .../model/management/PluginManagementInjector.java | 44 + .../apache/maven/model/merge/MavenModelMerger.java | 729 +++++++++++ .../normalization/DefaultModelNormalizer.java | 135 ++ .../maven/model/normalization/ModelNormalizer.java | 54 + .../model/path/DefaultModelPathTranslator.java | 111 ++ .../model/path/DefaultModelUrlNormalizer.java | 84 ++ .../maven/model/path/DefaultPathTranslator.java | 66 + .../maven/model/path/DefaultUrlNormalizer.java | 65 + .../maven/model/path/ModelPathTranslator.java | 45 + .../maven/model/path/ModelUrlNormalizer.java | 42 + .../apache/maven/model/path/PathTranslator.java | 43 + .../org/apache/maven/model/path/UrlNormalizer.java | 39 + .../plugin/DefaultPluginConfigurationExpander.java | 83 ++ .../plugin/DefaultReportConfigurationExpander.java | 65 + .../model/plugin/DefaultReportingConverter.java | 240 ++++ .../model/plugin/LifecycleBindingsInjector.java | 46 + .../model/plugin/PluginConfigurationExpander.java | 43 + .../model/plugin/ReportConfigurationExpander.java | 43 + .../maven/model/plugin/ReportingConverter.java | 43 + .../profile/DefaultProfileActivationContext.java | 259 ++++ .../model/profile/DefaultProfileInjector.java | 249 ++++ .../model/profile/DefaultProfileSelector.java | 143 +++ .../model/profile/ProfileActivationContext.java | 79 ++ .../maven/model/profile/ProfileInjector.java | 46 + .../maven/model/profile/ProfileSelector.java | 49 + .../profile/activation/FileProfileActivator.java | 192 +++ .../activation/JdkVersionProfileActivator.java | 224 ++++ .../OperatingSystemProfileActivator.java | 168 +++ .../model/profile/activation/ProfileActivator.java | 59 + .../activation/PropertyProfileActivator.java | 126 ++ .../resolution/InvalidRepositoryException.java | 73 ++ .../maven/model/resolution/ModelResolver.java | 93 ++ .../resolution/UnresolvableModelException.java | 126 ++ .../model/resolution/WorkspaceModelResolver.java | 33 + .../model/superpom/DefaultSuperPomProvider.java | 87 ++ .../maven/model/superpom/SuperPomProvider.java | 42 + .../model/validation/DefaultModelValidator.java | 1076 ++++++++++++++++ .../maven/model/validation/ModelValidator.java | 54 + .../maven-model-builder/src/main/mdo/profiles.mdo | 399 ++++++ .../resources/org/apache/maven/model/pom-4.0.0.xml | 150 +++ .../maven-model-builder/src/site/apt/index.apt | 187 +++ .../src/site/apt/super-pom.apt.vm | 30 + .../maven-model-builder/src/site/site.xml | 40 + .../model/building/ComplexActivationTest.java | 60 + .../building/DefaultModelBuilderFactoryTest.java | 59 + .../model/building/SimpleProblemCollector.java | 89 ++ .../DefaultInheritanceAssemblerTest.java | 108 ++ .../AbstractModelInterpolatorTest.java | 494 ++++++++ .../interpolation/MavenBuildTimestampTest.java | 38 + .../StringSearchModelInterpolatorTest.java | 505 ++++++++ .../maven/model/path/DefaultUrlNormalizerTest.java | 85 ++ .../activation/AbstractProfileActivatorTest.java | 92 ++ .../activation/JdkVersionProfileActivatorTest.java | 185 +++ .../activation/PropertyProfileActivatorTest.java | 185 +++ .../validation/DefaultModelValidatorTest.java | 630 ++++++++++ .../src/test/resources/poms/factory/complex.xml | 49 + .../src/test/resources/poms/factory/simple.xml | 81 ++ .../inheritance/plugin-configuration-child.xml | 61 + .../inheritance/plugin-configuration-expected.xml | 87 ++ .../inheritance/plugin-configuration-parent.xml | 89 ++ .../validation/bad-dependency-exclusion-id.xml | 40 + .../poms/validation/bad-dependency-scope.xml | 69 ++ .../poms/validation/bad-dependency-version.xml | 43 + .../validation/bad-import-scope-classifier.xml | 38 + .../poms/validation/bad-import-scope-type.xml | 37 + .../resources/poms/validation/bad-modelVersion.xml | 25 + .../validation/bad-plugin-dependency-scope.xml | 70 ++ .../validation/bad-plugin-dependency-version.xml | 46 + .../poms/validation/bad-plugin-version.xml | 55 + .../poms/validation/bad-repository-id.xml | 50 + .../poms/validation/bad-snapshot-version.xml | 25 + .../test/resources/poms/validation/bad-version.xml | 25 + .../poms/validation/basedir-system-path.xml | 42 + .../validation/distribution-management-status.xml | 29 + .../resources/poms/validation/duplicate-module.xml | 31 + .../poms/validation/duplicate-plugin-execution.xml | 103 ++ .../resources/poms/validation/duplicate-plugin.xml | 81 ++ .../poms/validation/duplicate-profile-id.xml | 35 + .../resources/poms/validation/empty-module.xml | 30 + .../poms/validation/empty-plugin-version.xml | 34 + .../poms/validation/hard-coded-system-path.xml | 42 + .../poms/validation/incomplete-parent.xml | 30 + .../invalid-aggregator-packaging-pom.xml | 30 + .../resources/poms/validation/invalid-ids-pom.xml | 26 + .../resources/poms/validation/missing-1-pom.xml | 21 + .../poms/validation/missing-artifactId-pom.xml | 25 + .../missing-dependency-artifactId-pom.xml | 32 + .../validation/missing-dependency-exclusion-id.xml | 39 + .../validation/missing-dependency-groupId-pom.xml | 32 + .../missing-dependency-mgmt-artifactId-pom.xml | 34 + .../missing-dependency-mgmt-groupId-pom.xml | 34 + .../missing-dependency-mgmt-version-pom.xml | 34 + .../validation/missing-dependency-version-pom.xml | 32 + .../poms/validation/missing-groupId-pom.xml | 25 + .../poms/validation/missing-modelVersion-pom.xml | 25 + .../validation/missing-plugin-artifactId-pom.xml | 33 + .../missing-plugin-dependency-artifactId.xml | 41 + .../missing-plugin-dependency-groupId.xml | 41 + .../missing-plugin-dependency-version.xml | 41 + .../poms/validation/missing-plugin-version-pom.xml | 33 + .../validation/missing-report-artifactId-pom.xml | 33 + .../poms/validation/missing-report-version-pom.xml | 57 + .../poms/validation/missing-repository-id-pom.xml | 36 + .../validation/missing-resource-directory-pom.xml | 38 + .../resources/poms/validation/missing-type-pom.xml | 26 + .../poms/validation/missing-version-pom.xml | 25 + .../poms/validation/reserved-repository-id.xml | 50 + 162 files changed, 18551 insertions(+) create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/AbstractModelBuildingListener.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingResult.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblemCollector.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/FileModelSource.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuilder.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEvent.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEventCatapult.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingListener.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingResult.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelCache.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelCacheTag.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelData.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblem.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollector.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorExt.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorRequest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemUtils.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProcessor.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelSource.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelSource2.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/StringModelSource.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/UrlModelSource.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/composition/DependencyManagementImporter.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/InheritanceAssembler.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/BuildTimestampValueSource.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/MavenBuildTimestamp.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/PathTranslatingPostProcessor.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/UrlNormalizingPostProcessor.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelParseException.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelReader.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelWriter.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/locator/DefaultModelLocator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/locator/ModelLocator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultPluginManagementInjector.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/DependencyManagementInjector.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/PluginManagementInjector.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/normalization/DefaultModelNormalizer.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/normalization/ModelNormalizer.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultModelPathTranslator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultModelUrlNormalizer.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultPathTranslator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultUrlNormalizer.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/ModelPathTranslator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/ModelUrlNormalizer.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/PathTranslator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/UrlNormalizer.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultPluginConfigurationExpander.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportConfigurationExpander.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/LifecycleBindingsInjector.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/PluginConfigurationExpander.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportConfigurationExpander.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileInjector.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileSelector.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/InvalidRepositoryException.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/WorkspaceModelResolver.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/superpom/DefaultSuperPomProvider.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/superpom/SuperPomProvider.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/validation/ModelValidator.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/mdo/profiles.mdo create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.0.0.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/site/apt/index.apt create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/site/apt/super-pom.apt.vm create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/site/site.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/building/ComplexActivationTest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/building/DefaultModelBuilderFactoryTest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/AbstractModelInterpolatorTest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/MavenBuildTimestampTest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/path/DefaultUrlNormalizerTest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/factory/complex.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/factory/simple.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-child.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-expected.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-parent.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-dependency-exclusion-id.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-dependency-scope.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-dependency-version.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-classifier.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-type.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-modelVersion.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-plugin-dependency-scope.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-plugin-dependency-version.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-plugin-version.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-repository-id.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-snapshot-version.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-version.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/basedir-system-path.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/distribution-management-status.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-module.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-plugin-execution.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-plugin.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-profile-id.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/empty-module.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/empty-plugin-version.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/hard-coded-system-path.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/incomplete-parent.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/invalid-aggregator-packaging-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/invalid-ids-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-1-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-artifactId-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-artifactId-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-exclusion-id.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-groupId-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-artifactId-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-groupId-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-version-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-version-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-groupId-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-modelVersion-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-artifactId-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-dependency-artifactId.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-dependency-groupId.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-dependency-version.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-version-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-report-artifactId-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-report-version-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-repository-id-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-resource-directory-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-type-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-version-pom.xml create mode 100644 framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/reserved-repository-id.xml (limited to 'framework/src/maven/apache-maven-3.3.3/maven-model-builder') diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/pom.xml new file mode 100644 index 00000000..2b514052 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/pom.xml @@ -0,0 +1,86 @@ + + + + + + 4.0.0 + + + org.apache.maven + maven + 3.3.3 + + + maven-model-builder + + Maven Model Builder + The effective model builder, with inheritance, profile activation, interpolation, ... + + + scm:git:https://git-wip-us.apache.org/repos/asf/maven.git + scm:git:https://git-wip-us.apache.org/repos/asf/maven.git + maven-3.3.3 + + + + + org.codehaus.plexus + plexus-utils + + + org.codehaus.plexus + plexus-interpolation + + + org.codehaus.plexus + plexus-component-annotations + + + org.apache.maven + maven-model + + + org.apache.maven + maven-builder-support + + + com.google.guava + guava + + + org.eclipse.sisu + org.eclipse.sisu.plexus + test + + + org.sonatype.sisu + sisu-guice + no_aop + test + + + xmlunit + xmlunit + 1.3 + test + + + + + + + org.codehaus.plexus + plexus-component-metadata + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/AbstractModelBuildingListener.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/AbstractModelBuildingListener.java new file mode 100644 index 00000000..5138776a --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/AbstractModelBuildingListener.java @@ -0,0 +1,37 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Provides a skeleton implementation for model building listeners. The methods of this class are empty. + * + * @author Benjamin Bentmann + */ +public class AbstractModelBuildingListener + implements ModelBuildingListener +{ + + @Override + public void buildExtensionsAssembled( ModelBuildingEvent event ) + { + // default does nothing + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java new file mode 100644 index 00000000..52b3c9c8 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -0,0 +1,1309 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +import static org.apache.maven.model.building.Result.error; +import static org.apache.maven.model.building.Result.newResult; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.apache.maven.model.Activation; +import org.apache.maven.model.Build; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.InputLocation; +import org.apache.maven.model.InputSource; +import org.apache.maven.model.Model; +import org.apache.maven.model.Parent; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginManagement; +import org.apache.maven.model.Profile; +import org.apache.maven.model.Repository; +import org.apache.maven.model.building.ModelProblem.Severity; +import org.apache.maven.model.building.ModelProblem.Version; +import org.apache.maven.model.composition.DependencyManagementImporter; +import org.apache.maven.model.inheritance.InheritanceAssembler; +import org.apache.maven.model.interpolation.ModelInterpolator; +import org.apache.maven.model.io.ModelParseException; +import org.apache.maven.model.management.DependencyManagementInjector; +import org.apache.maven.model.management.PluginManagementInjector; +import org.apache.maven.model.normalization.ModelNormalizer; +import org.apache.maven.model.path.ModelPathTranslator; +import org.apache.maven.model.path.ModelUrlNormalizer; +import org.apache.maven.model.plugin.LifecycleBindingsInjector; +import org.apache.maven.model.plugin.PluginConfigurationExpander; +import org.apache.maven.model.plugin.ReportConfigurationExpander; +import org.apache.maven.model.plugin.ReportingConverter; +import org.apache.maven.model.profile.DefaultProfileActivationContext; +import org.apache.maven.model.profile.ProfileInjector; +import org.apache.maven.model.profile.ProfileSelector; +import org.apache.maven.model.resolution.InvalidRepositoryException; +import org.apache.maven.model.resolution.ModelResolver; +import org.apache.maven.model.resolution.UnresolvableModelException; +import org.apache.maven.model.resolution.WorkspaceModelResolver; +import org.apache.maven.model.superpom.SuperPomProvider; +import org.apache.maven.model.validation.ModelValidator; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; + +/** + * @author Benjamin Bentmann + */ +@Component( role = ModelBuilder.class ) +public class DefaultModelBuilder + implements ModelBuilder +{ + @Requirement + private ModelProcessor modelProcessor; + + @Requirement + private ModelValidator modelValidator; + + @Requirement + private ModelNormalizer modelNormalizer; + + @Requirement + private ModelInterpolator modelInterpolator; + + @Requirement + private ModelPathTranslator modelPathTranslator; + + @Requirement + private ModelUrlNormalizer modelUrlNormalizer; + + @Requirement + private SuperPomProvider superPomProvider; + + @Requirement + private InheritanceAssembler inheritanceAssembler; + + @Requirement + private ProfileSelector profileSelector; + + @Requirement + private ProfileInjector profileInjector; + + @Requirement + private PluginManagementInjector pluginManagementInjector; + + @Requirement + private DependencyManagementInjector dependencyManagementInjector; + + @Requirement + private DependencyManagementImporter dependencyManagementImporter; + + @Requirement( optional = true ) + private LifecycleBindingsInjector lifecycleBindingsInjector; + + @Requirement + private PluginConfigurationExpander pluginConfigurationExpander; + + @Requirement + private ReportConfigurationExpander reportConfigurationExpander; + + @Requirement + private ReportingConverter reportingConverter; + + public DefaultModelBuilder setModelProcessor( ModelProcessor modelProcessor ) + { + this.modelProcessor = modelProcessor; + return this; + } + + public DefaultModelBuilder setModelValidator( ModelValidator modelValidator ) + { + this.modelValidator = modelValidator; + return this; + } + + public DefaultModelBuilder setModelNormalizer( ModelNormalizer modelNormalizer ) + { + this.modelNormalizer = modelNormalizer; + return this; + } + + public DefaultModelBuilder setModelInterpolator( ModelInterpolator modelInterpolator ) + { + this.modelInterpolator = modelInterpolator; + return this; + } + + public DefaultModelBuilder setModelPathTranslator( ModelPathTranslator modelPathTranslator ) + { + this.modelPathTranslator = modelPathTranslator; + return this; + } + + public DefaultModelBuilder setModelUrlNormalizer( ModelUrlNormalizer modelUrlNormalizer ) + { + this.modelUrlNormalizer = modelUrlNormalizer; + return this; + } + + public DefaultModelBuilder setSuperPomProvider( SuperPomProvider superPomProvider ) + { + this.superPomProvider = superPomProvider; + return this; + } + + public DefaultModelBuilder setProfileSelector( ProfileSelector profileSelector ) + { + this.profileSelector = profileSelector; + return this; + } + + public DefaultModelBuilder setProfileInjector( ProfileInjector profileInjector ) + { + this.profileInjector = profileInjector; + return this; + } + + public DefaultModelBuilder setInheritanceAssembler( InheritanceAssembler inheritanceAssembler ) + { + this.inheritanceAssembler = inheritanceAssembler; + return this; + } + + public DefaultModelBuilder setDependencyManagementImporter( DependencyManagementImporter depMngmntImporter ) + { + this.dependencyManagementImporter = depMngmntImporter; + return this; + } + + public DefaultModelBuilder setDependencyManagementInjector( DependencyManagementInjector depMngmntInjector ) + { + this.dependencyManagementInjector = depMngmntInjector; + return this; + } + + public DefaultModelBuilder setLifecycleBindingsInjector( LifecycleBindingsInjector lifecycleBindingsInjector ) + { + this.lifecycleBindingsInjector = lifecycleBindingsInjector; + return this; + } + + public DefaultModelBuilder setPluginConfigurationExpander( PluginConfigurationExpander pluginConfigurationExpander ) + { + this.pluginConfigurationExpander = pluginConfigurationExpander; + return this; + } + + public DefaultModelBuilder setPluginManagementInjector( PluginManagementInjector pluginManagementInjector ) + { + this.pluginManagementInjector = pluginManagementInjector; + return this; + } + + public DefaultModelBuilder setReportConfigurationExpander( ReportConfigurationExpander reportConfigurationExpander ) + { + this.reportConfigurationExpander = reportConfigurationExpander; + return this; + } + + public DefaultModelBuilder setReportingConverter( ReportingConverter reportingConverter ) + { + this.reportingConverter = reportingConverter; + return this; + } + + @Override + public ModelBuildingResult build( ModelBuildingRequest request ) + throws ModelBuildingException + { + // phase 1 + DefaultModelBuildingResult result = new DefaultModelBuildingResult(); + + DefaultModelProblemCollector problems = new DefaultModelProblemCollector( result ); + + // profile activation + DefaultProfileActivationContext profileActivationContext = getProfileActivationContext( request ); + + problems.setSource( "(external profiles)" ); + List activeExternalProfiles = profileSelector.getActiveProfiles( request.getProfiles(), + profileActivationContext, problems ); + + result.setActiveExternalProfiles( activeExternalProfiles ); + + if ( !activeExternalProfiles.isEmpty() ) + { + Properties profileProps = new Properties(); + for ( Profile profile : activeExternalProfiles ) + { + profileProps.putAll( profile.getProperties() ); + } + profileProps.putAll( profileActivationContext.getUserProperties() ); + profileActivationContext.setUserProperties( profileProps ); + } + + // read and validate raw model + Model inputModel = request.getRawModel(); + if ( inputModel == null ) + { + inputModel = readModel( request.getModelSource(), request.getPomFile(), request, problems ); + } + + problems.setRootModel( inputModel ); + + ModelData resultData = new ModelData( request.getModelSource(), inputModel ); + ModelData superData = new ModelData( null, getSuperModel() ); + + Collection parentIds = new LinkedHashSet(); + List lineage = new ArrayList(); + + for ( ModelData currentData = resultData; currentData != null; ) + { + lineage.add( currentData ); + + Model rawModel = currentData.getModel(); + currentData.setRawModel( rawModel ); + + Model tmpModel = rawModel.clone(); + currentData.setModel( tmpModel ); + + problems.setSource( tmpModel ); + + // model normalization + modelNormalizer.mergeDuplicates( tmpModel, request, problems ); + + profileActivationContext.setProjectProperties( tmpModel.getProperties() ); + + List activePomProfiles = profileSelector.getActiveProfiles( rawModel.getProfiles(), + profileActivationContext, problems ); + currentData.setActiveProfiles( activePomProfiles ); + + Map interpolatedActivations = getProfileActivations( rawModel, false ); + injectProfileActivations( tmpModel, interpolatedActivations ); + + // profile injection + for ( Profile activeProfile : activePomProfiles ) + { + profileInjector.injectProfile( tmpModel, activeProfile, request, problems ); + } + + if ( currentData == resultData ) + { + for ( Profile activeProfile : activeExternalProfiles ) + { + profileInjector.injectProfile( tmpModel, activeProfile, request, problems ); + } + } + + if ( currentData == superData ) + { + break; + } + + configureResolver( request.getModelResolver(), tmpModel, problems ); + + ModelData parentData = readParent( tmpModel, currentData.getSource(), request, problems ); + + if ( parentData == null ) + { + currentData = superData; + } + else if ( currentData == resultData ) + { // First iteration - add initial parent id after version resolution. + currentData.setGroupId( currentData.getRawModel().getGroupId() == null ? parentData.getGroupId() + : currentData.getRawModel() + .getGroupId() ); + + currentData.setVersion( currentData.getRawModel().getVersion() == null ? parentData.getVersion() + : currentData.getRawModel() + .getVersion() ); + + currentData.setArtifactId( currentData.getRawModel().getArtifactId() ); + parentIds.add( currentData.getId() ); + // Reset - only needed for 'getId'. + currentData.setGroupId( null ); + currentData.setArtifactId( null ); + currentData.setVersion( null ); + currentData = parentData; + } + else if ( !parentIds.add( parentData.getId() ) ) + { + String message = "The parents form a cycle: "; + for ( String modelId : parentIds ) + { + message += modelId + " -> "; + } + message += parentData.getId(); + + problems.add( new ModelProblemCollectorRequest( ModelProblem.Severity.FATAL, ModelProblem.Version.BASE ) + .setMessage( message ) ); + + throw problems.newModelBuildingException(); + } + else + { + currentData = parentData; + } + } + + problems.setSource( inputModel ); + checkPluginVersions( lineage, request, problems ); + + // inheritance assembly + assembleInheritance( lineage, request, problems ); + + Model resultModel = resultData.getModel(); + + problems.setSource( resultModel ); + problems.setRootModel( resultModel ); + + // model interpolation + resultModel = interpolateModel( resultModel, request, problems ); + resultData.setModel( resultModel ); + + // url normalization + modelUrlNormalizer.normalize( resultModel, request ); + + // Now the fully interpolated model is available: reconfigure the resolver + configureResolver( request.getModelResolver(), resultModel, problems, true ); + + resultData.setGroupId( resultModel.getGroupId() ); + resultData.setArtifactId( resultModel.getArtifactId() ); + resultData.setVersion( resultModel.getVersion() ); + + result.setEffectiveModel( resultModel ); + + for ( ModelData currentData : lineage ) + { + String modelId = ( currentData != superData ) ? currentData.getId() : ""; + + result.addModelId( modelId ); + result.setActivePomProfiles( modelId, currentData.getActiveProfiles() ); + result.setRawModel( modelId, currentData.getRawModel() ); + } + + if ( !request.isTwoPhaseBuilding() ) + { + build( request, result ); + } + + return result; + } + + @Override + public ModelBuildingResult build( ModelBuildingRequest request, ModelBuildingResult result ) + throws ModelBuildingException + { + return build( request, result, new LinkedHashSet() ); + } + + private ModelBuildingResult build( ModelBuildingRequest request, ModelBuildingResult result, + Collection imports ) + throws ModelBuildingException + { + // phase 2 + Model resultModel = result.getEffectiveModel(); + + DefaultModelProblemCollector problems = new DefaultModelProblemCollector( result ); + problems.setSource( resultModel ); + problems.setRootModel( resultModel ); + + // model path translation + modelPathTranslator.alignToBaseDirectory( resultModel, resultModel.getProjectDirectory(), request ); + + // plugin management injection + pluginManagementInjector.injectManagement( resultModel, request, problems ); + + fireEvent( resultModel, request, problems, ModelBuildingEventCatapult.BUILD_EXTENSIONS_ASSEMBLED ); + + if ( request.isProcessPlugins() ) + { + if ( lifecycleBindingsInjector == null ) + { + throw new IllegalStateException( "lifecycle bindings injector is missing" ); + } + + // lifecycle bindings injection + lifecycleBindingsInjector.injectLifecycleBindings( resultModel, request, problems ); + } + + // dependency management import + importDependencyManagement( resultModel, request, problems, imports ); + + // dependency management injection + dependencyManagementInjector.injectManagement( resultModel, request, problems ); + + modelNormalizer.injectDefaultValues( resultModel, request, problems ); + + if ( request.isProcessPlugins() ) + { + // reports configuration + reportConfigurationExpander.expandPluginConfiguration( resultModel, request, problems ); + + // reports conversion to decoupled site plugin + reportingConverter.convertReporting( resultModel, request, problems ); + + // plugins configuration + pluginConfigurationExpander.expandPluginConfiguration( resultModel, request, problems ); + } + + // effective model validation + modelValidator.validateEffectiveModel( resultModel, request, problems ); + + if ( hasModelErrors( problems ) ) + { + throw problems.newModelBuildingException(); + } + + return result; + } + + @Override + public Result buildRawModel( File pomFile, int validationLevel, boolean locationTracking ) + { + final ModelBuildingRequest request = new DefaultModelBuildingRequest().setValidationLevel( validationLevel ) + .setLocationTracking( locationTracking ); + final DefaultModelProblemCollector collector = + new DefaultModelProblemCollector( new DefaultModelBuildingResult() ); + try + { + return newResult( readModel( null, pomFile, request, collector ), collector.getProblems() ); + } + catch ( ModelBuildingException e ) + { + return error( collector.getProblems() ); + } + } + + private Model readModel( ModelSource modelSource, File pomFile, ModelBuildingRequest request, + DefaultModelProblemCollector problems ) + throws ModelBuildingException + { + Model model; + + if ( modelSource == null ) + { + if ( pomFile != null ) + { + modelSource = new FileModelSource( pomFile ); + } + else + { + throw new IllegalArgumentException( "neither model source nor input file are specified" ); + } + } + + problems.setSource( modelSource.getLocation() ); + try + { + boolean strict = request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0; + InputSource source = request.isLocationTracking() ? new InputSource() : null; + + Map options = new HashMap(); + options.put( ModelProcessor.IS_STRICT, strict ); + options.put( ModelProcessor.INPUT_SOURCE, source ); + options.put( ModelProcessor.SOURCE, modelSource ); + + try + { + model = modelProcessor.read( modelSource.getInputStream(), options ); + } + catch ( ModelParseException e ) + { + if ( !strict ) + { + throw e; + } + + options.put( ModelProcessor.IS_STRICT, Boolean.FALSE ); + + try + { + model = modelProcessor.read( modelSource.getInputStream(), options ); + } + catch ( ModelParseException ne ) + { + // still unreadable even in non-strict mode, rethrow original error + throw e; + } + + if ( pomFile != null ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.V20 ) + .setMessage( "Malformed POM " + modelSource.getLocation() + ": " + e.getMessage() ) + .setException( e ) ); + } + else + { + problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 ) + .setMessage( "Malformed POM " + modelSource.getLocation() + ": " + e.getMessage() ) + .setException( e ) ); + } + } + + if ( source != null ) + { + source.setModelId( ModelProblemUtils.toId( model ) ); + source.setLocation( modelSource.getLocation() ); + } + } + catch ( ModelParseException e ) + { + problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE ) + .setMessage( "Non-parseable POM " + modelSource.getLocation() + ": " + e.getMessage() ) + .setException( e ) ); + throw problems.newModelBuildingException(); + } + catch ( IOException e ) + { + String msg = e.getMessage(); + if ( msg == null || msg.length() <= 0 ) + { + // NOTE: There's java.nio.charset.MalformedInputException and sun.io.MalformedInputException + if ( e.getClass().getName().endsWith( "MalformedInputException" ) ) + { + msg = "Some input bytes do not match the file encoding."; + } + else + { + msg = e.getClass().getSimpleName(); + } + } + problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE ) + .setMessage( "Non-readable POM " + modelSource.getLocation() + ": " + msg ).setException( e ) ); + throw problems.newModelBuildingException(); + } + + model.setPomFile( pomFile ); + + problems.setSource( model ); + modelValidator.validateRawModel( model, request, problems ); + + if ( hasFatalErrors( problems ) ) + { + throw problems.newModelBuildingException(); + } + + return model; + } + + private DefaultProfileActivationContext getProfileActivationContext( ModelBuildingRequest request ) + { + DefaultProfileActivationContext context = new DefaultProfileActivationContext(); + + context.setActiveProfileIds( request.getActiveProfileIds() ); + context.setInactiveProfileIds( request.getInactiveProfileIds() ); + context.setSystemProperties( request.getSystemProperties() ); + context.setUserProperties( request.getUserProperties() ); + context.setProjectDirectory( ( request.getPomFile() != null ) ? request.getPomFile().getParentFile() : null ); + + return context; + } + + private void configureResolver( ModelResolver modelResolver, Model model, DefaultModelProblemCollector problems ) + { + configureResolver( modelResolver, model, problems, false ); + } + + private void configureResolver( ModelResolver modelResolver, Model model, DefaultModelProblemCollector problems, + boolean replaceRepositories ) + { + if ( modelResolver == null ) + { + return; + } + + problems.setSource( model ); + + List repositories = model.getRepositories(); + + for ( Repository repository : repositories ) + { + try + { + modelResolver.addRepository( repository, replaceRepositories ); + } + catch ( InvalidRepositoryException e ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "Invalid repository " + repository.getId() + ": " + e.getMessage() ) + .setLocation( repository.getLocation( "" ) ).setException( e ) ); + } + } + } + + private void checkPluginVersions( List lineage, ModelBuildingRequest request, + ModelProblemCollector problems ) + { + if ( request.getValidationLevel() < ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ) + { + return; + } + + Map plugins = new HashMap(); + Map versions = new HashMap(); + Map managedVersions = new HashMap(); + + for ( int i = lineage.size() - 1; i >= 0; i-- ) + { + Model model = lineage.get( i ).getModel(); + Build build = model.getBuild(); + if ( build != null ) + { + for ( Plugin plugin : build.getPlugins() ) + { + String key = plugin.getKey(); + if ( versions.get( key ) == null ) + { + versions.put( key, plugin.getVersion() ); + plugins.put( key, plugin ); + } + } + PluginManagement mngt = build.getPluginManagement(); + if ( mngt != null ) + { + for ( Plugin plugin : mngt.getPlugins() ) + { + String key = plugin.getKey(); + if ( managedVersions.get( key ) == null ) + { + managedVersions.put( key, plugin.getVersion() ); + } + } + } + } + } + + for ( String key : versions.keySet() ) + { + if ( versions.get( key ) == null && managedVersions.get( key ) == null ) + { + InputLocation location = plugins.get( key ).getLocation( "" ); + problems + .add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 ) + .setMessage( "'build.plugins.plugin.version' for " + key + " is missing." ) + .setLocation( location ) ); + } + } + } + + private void assembleInheritance( List lineage, ModelBuildingRequest request, + ModelProblemCollector problems ) + { + for ( int i = lineage.size() - 2; i >= 0; i-- ) + { + Model parent = lineage.get( i + 1 ).getModel(); + Model child = lineage.get( i ).getModel(); + inheritanceAssembler.assembleModelInheritance( child, parent, request, problems ); + } + } + + private Map getProfileActivations( Model model, boolean clone ) + { + Map activations = new HashMap(); + for ( Profile profile : model.getProfiles() ) + { + Activation activation = profile.getActivation(); + + if ( activation == null ) + { + continue; + } + + if ( clone ) + { + activation = activation.clone(); + } + + activations.put( profile.getId(), activation ); + } + + return activations; + } + + private void injectProfileActivations( Model model, Map activations ) + { + for ( Profile profile : model.getProfiles() ) + { + Activation activation = profile.getActivation(); + + if ( activation == null ) + { + continue; + } + + // restore activation + profile.setActivation( activations.get( profile.getId() ) ); + } + } + + private Model interpolateModel( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + // save profile activations before interpolation, since they are evaluated with limited scope + Map originalActivations = getProfileActivations( model, true ); + + Model result = modelInterpolator.interpolateModel( model, model.getProjectDirectory(), request, problems ); + result.setPomFile( model.getPomFile() ); + + // restore profiles with file activation to their value before full interpolation + injectProfileActivations( model, originalActivations ); + + return result; + } + + private ModelData readParent( Model childModel, ModelSource childSource, ModelBuildingRequest request, + DefaultModelProblemCollector problems ) + throws ModelBuildingException + { + ModelData parentData; + + Parent parent = childModel.getParent(); + + if ( parent != null ) + { + String groupId = parent.getGroupId(); + String artifactId = parent.getArtifactId(); + String version = parent.getVersion(); + + parentData = getCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.RAW ); + + if ( parentData == null ) + { + parentData = readParentLocally( childModel, childSource, request, problems ); + + if ( parentData == null ) + { + parentData = readParentExternally( childModel, request, problems ); + } + + putCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.RAW, parentData ); + } + else + { + /* + * NOTE: This is a sanity check of the cache hit. If the cached parent POM was locally resolved, the + * child's should point at that parent, too. If it doesn't, we ignore the cache and + * resolve externally, to mimic the behavior if the cache didn't exist in the first place. Otherwise, + * the cache would obscure a bad POM. + */ + + File pomFile = parentData.getModel().getPomFile(); + if ( pomFile != null ) + { + ModelSource expectedParentSource = getParentPomFile( childModel, childSource ); + + if ( expectedParentSource instanceof ModelSource2 + && !pomFile.toURI().equals( ( (ModelSource2) expectedParentSource ).getLocationURI() ) ) + { + parentData = readParentExternally( childModel, request, problems ); + } + } + } + + Model parentModel = parentData.getModel(); + + if ( !"pom".equals( parentModel.getPackaging() ) ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "Invalid packaging for parent POM " + ModelProblemUtils.toSourceHint( parentModel ) + + ", must be \"pom\" but is \"" + parentModel.getPackaging() + "\"" ) + .setLocation( parentModel.getLocation( "packaging" ) ) ); + } + } + else + { + parentData = null; + } + + return parentData; + } + + private ModelData readParentLocally( Model childModel, ModelSource childSource, ModelBuildingRequest request, + DefaultModelProblemCollector problems ) + throws ModelBuildingException + { + final Parent parent = childModel.getParent(); + final ModelSource candidateSource; + final Model candidateModel; + final WorkspaceModelResolver resolver = request.getWorkspaceModelResolver(); + if ( resolver == null ) + { + candidateSource = getParentPomFile( childModel, childSource ); + + if ( candidateSource == null ) + { + return null; + } + + File pomFile = null; + if ( candidateSource instanceof FileModelSource ) + { + pomFile = ( (FileModelSource) candidateSource ).getPomFile(); + } + + candidateModel = readModel( candidateSource, pomFile, request, problems ); + } + else + { + try + { + candidateModel = + resolver.resolveRawModel( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() ); + } + catch ( UnresolvableModelException e ) + { + problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE ) // + .setMessage( e.getMessage().toString() ).setLocation( parent.getLocation( "" ) ).setException( e ) ); + throw problems.newModelBuildingException(); + } + if ( candidateModel == null ) + { + return null; + } + candidateSource = new FileModelSource( candidateModel.getPomFile() ); + } + + // + // TODO:jvz Why isn't all this checking the job of the duty of the workspace resolver, we know that we + // have a model that is suitable, yet more checks are done here and the one for the version is problematic + // before because with parents as ranges it will never work in this scenario. + // + + String groupId = candidateModel.getGroupId(); + if ( groupId == null && candidateModel.getParent() != null ) + { + groupId = candidateModel.getParent().getGroupId(); + } + String artifactId = candidateModel.getArtifactId(); + String version = candidateModel.getVersion(); + if ( version == null && candidateModel.getParent() != null ) + { + version = candidateModel.getParent().getVersion(); + } + + if ( groupId == null || !groupId.equals( parent.getGroupId() ) || artifactId == null + || !artifactId.equals( parent.getArtifactId() ) ) + { + StringBuilder buffer = new StringBuilder( 256 ); + buffer.append( "'parent.relativePath'" ); + if ( childModel != problems.getRootModel() ) + { + buffer.append( " of POM " ).append( ModelProblemUtils.toSourceHint( childModel ) ); + } + buffer.append( " points at " ).append( groupId ).append( ":" ).append( artifactId ); + buffer.append( " instead of " ).append( parent.getGroupId() ).append( ":" ); + buffer.append( parent.getArtifactId() ).append( ", please verify your project structure" ); + + problems.setSource( childModel ); + problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.BASE ) + .setMessage( buffer.toString() ).setLocation( parent.getLocation( "" ) ) ); + return null; + } + + // + // Here we just need to know that a version is fine to use but this validation we can do in our workspace + // resolver. + // + + /* + * if ( version == null || !version.equals( parent.getVersion() ) ) { return null; } + */ + + ModelData parentData = new ModelData( candidateSource, candidateModel, groupId, artifactId, version ); + + return parentData; + } + + private ModelSource getParentPomFile( Model childModel, ModelSource source ) + { + if ( !( source instanceof ModelSource2 ) ) + { + return null; + } + + String parentPath = childModel.getParent().getRelativePath(); + + if ( parentPath == null || parentPath.length() <= 0 ) + { + return null; + } + + return ( (ModelSource2) source ).getRelatedSource( parentPath ); + } + + private ModelData readParentExternally( Model childModel, ModelBuildingRequest request, + DefaultModelProblemCollector problems ) + throws ModelBuildingException + { + problems.setSource( childModel ); + + Parent parent = childModel.getParent().clone(); + + String groupId = parent.getGroupId(); + String artifactId = parent.getArtifactId(); + String version = parent.getVersion(); + + ModelResolver modelResolver = request.getModelResolver(); + + if ( modelResolver == null ) + { + throw new IllegalArgumentException( "no model resolver provided, cannot resolve parent POM " + + ModelProblemUtils.toId( groupId, artifactId, version ) + " for POM " + + ModelProblemUtils.toSourceHint( childModel ) ); + } + + ModelSource modelSource; + try + { + modelSource = modelResolver.resolveModel( parent ); + } + catch ( UnresolvableModelException e ) + { + StringBuilder buffer = new StringBuilder( 256 ); + buffer.append( "Non-resolvable parent POM" ); + if ( !containsCoordinates( e.getMessage(), groupId, artifactId, version ) ) + { + buffer.append( " " ).append( ModelProblemUtils.toId( groupId, artifactId, version ) ); + } + if ( childModel != problems.getRootModel() ) + { + buffer.append( " for " ).append( ModelProblemUtils.toId( childModel ) ); + } + buffer.append( ": " ).append( e.getMessage() ); + if ( childModel.getProjectDirectory() != null ) + { + if ( parent.getRelativePath() == null || parent.getRelativePath().length() <= 0 ) + { + buffer.append( " and 'parent.relativePath' points at no local POM" ); + } + else + { + buffer.append( " and 'parent.relativePath' points at wrong local POM" ); + } + } + + problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE ) + .setMessage( buffer.toString() ).setLocation( parent.getLocation( "" ) ).setException( e ) ); + throw problems.newModelBuildingException(); + } + + ModelBuildingRequest lenientRequest = request; + if ( request.getValidationLevel() > ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ) + { + lenientRequest = new FilterModelBuildingRequest( request ) + { + @Override + public int getValidationLevel() + { + return ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0; + } + }; + } + + Model parentModel = readModel( modelSource, null, lenientRequest, problems ); + + if ( !parent.getVersion().equals( version ) ) + { + if ( childModel.getVersion() == null ) + { + problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 ) + .setMessage( "Version must be a constant" ).setLocation( childModel.getLocation( "" ) ) ); + + } + else + { + if ( childModel.getVersion().indexOf( "${" ) > -1 ) + { + problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 ) + .setMessage( "Version must be a constant" ) + .setLocation( childModel.getLocation( "version" ) ) ); + + } + } + + // MNG-2199: What else to check here ? + } + + ModelData parentData = new ModelData( modelSource, parentModel, parent.getGroupId(), parent.getArtifactId(), + parent.getVersion() ); + + return parentData; + } + + private Model getSuperModel() + { + return superPomProvider.getSuperModel( "4.0.0" ).clone(); + } + + private void importDependencyManagement( Model model, ModelBuildingRequest request, + DefaultModelProblemCollector problems, Collection importIds ) + { + DependencyManagement depMngt = model.getDependencyManagement(); + + if ( depMngt == null ) + { + return; + } + + String importing = model.getGroupId() + ':' + model.getArtifactId() + ':' + model.getVersion(); + + importIds.add( importing ); + + final WorkspaceModelResolver workspaceResolver = request.getWorkspaceModelResolver(); + final ModelResolver modelResolver = request.getModelResolver(); + + ModelBuildingRequest importRequest = null; + + List importMngts = null; + + for ( Iterator it = depMngt.getDependencies().iterator(); it.hasNext(); ) + { + Dependency dependency = it.next(); + + if ( !"pom".equals( dependency.getType() ) || !"import".equals( dependency.getScope() ) ) + { + continue; + } + + it.remove(); + + String groupId = dependency.getGroupId(); + String artifactId = dependency.getArtifactId(); + String version = dependency.getVersion(); + + if ( groupId == null || groupId.length() <= 0 ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "'dependencyManagement.dependencies.dependency.groupId' for " + + dependency.getManagementKey() + " is missing." ) + .setLocation( dependency.getLocation( "" ) ) ); + continue; + } + if ( artifactId == null || artifactId.length() <= 0 ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "'dependencyManagement.dependencies.dependency.artifactId' for " + + dependency.getManagementKey() + " is missing." ) + .setLocation( dependency.getLocation( "" ) ) ); + continue; + } + if ( version == null || version.length() <= 0 ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "'dependencyManagement.dependencies.dependency.version' for " + + dependency.getManagementKey() + " is missing." ) + .setLocation( dependency.getLocation( "" ) ) ); + continue; + } + + String imported = groupId + ':' + artifactId + ':' + version; + + if ( importIds.contains( imported ) ) + { + String message = "The dependencies of type=pom and with scope=import form a cycle: "; + for ( String modelId : importIds ) + { + message += modelId + " -> "; + } + message += imported; + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( message ) ); + + continue; + } + + DependencyManagement importMngt = getCache( request.getModelCache(), groupId, artifactId, version, + ModelCacheTag.IMPORT ); + + if ( importMngt == null ) + { + if ( workspaceResolver == null && modelResolver == null ) + { + throw new IllegalArgumentException( "no model resolver provided, cannot resolve import POM " + + ModelProblemUtils.toId( groupId, artifactId, version ) + " for POM " + + ModelProblemUtils.toSourceHint( model ) ); + } + + Model importModel = null; + if ( workspaceResolver != null ) + { + try + { + importModel = workspaceResolver.resolveEffectiveModel( groupId, artifactId, version ); + } + catch ( UnresolvableModelException e ) + { + problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE ) + .setMessage( e.getMessage().toString() ).setException( e ) ); + continue; + } + } + + // no workspace resolver or workspace resolver returned null (i.e. model not in workspace) + if ( importModel == null ) + { + final ModelSource importSource; + try + { + importSource = modelResolver.resolveModel( groupId, artifactId, version ); + } + catch ( UnresolvableModelException e ) + { + StringBuilder buffer = new StringBuilder( 256 ); + buffer.append( "Non-resolvable import POM" ); + if ( !containsCoordinates( e.getMessage(), groupId, artifactId, version ) ) + { + buffer.append( " " ).append( ModelProblemUtils.toId( groupId, artifactId, version ) ); + } + buffer.append( ": " ).append( e.getMessage() ); + + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( buffer.toString() ).setLocation( dependency.getLocation( "" ) ) + .setException( e ) ); + continue; + } + + if ( importRequest == null ) + { + importRequest = new DefaultModelBuildingRequest(); + importRequest.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); + importRequest.setModelCache( request.getModelCache() ); + importRequest.setSystemProperties( request.getSystemProperties() ); + importRequest.setUserProperties( request.getUserProperties() ); + importRequest.setLocationTracking( request.isLocationTracking() ); + } + + importRequest.setModelSource( importSource ); + importRequest.setModelResolver( modelResolver.newCopy() ); + + final ModelBuildingResult importResult; + try + { + importResult = build( importRequest ); + } + catch ( ModelBuildingException e ) + { + problems.addAll( e.getProblems() ); + continue; + } + + problems.addAll( importResult.getProblems() ); + + importModel = importResult.getEffectiveModel(); + } + + importMngt = importModel.getDependencyManagement(); + + if ( importMngt == null ) + { + importMngt = new DependencyManagement(); + } + + putCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.IMPORT, importMngt ); + } + + if ( importMngts == null ) + { + importMngts = new ArrayList(); + } + + importMngts.add( importMngt ); + } + + importIds.remove( importing ); + + dependencyManagementImporter.importManagement( model, importMngts, request, problems ); + } + + private void putCache( ModelCache modelCache, String groupId, String artifactId, String version, + ModelCacheTag tag, T data ) + { + if ( modelCache != null ) + { + modelCache.put( groupId, artifactId, version, tag.getName(), tag.intoCache( data ) ); + } + } + + private T getCache( ModelCache modelCache, String groupId, String artifactId, String version, + ModelCacheTag tag ) + { + if ( modelCache != null ) + { + Object data = modelCache.get( groupId, artifactId, version, tag.getName() ); + if ( data != null ) + { + return tag.fromCache( tag.getType().cast( data ) ); + } + } + return null; + } + + private void fireEvent( Model model, ModelBuildingRequest request, ModelProblemCollector problems, + ModelBuildingEventCatapult catapult ) + throws ModelBuildingException + { + ModelBuildingListener listener = request.getModelBuildingListener(); + + if ( listener != null ) + { + ModelBuildingEvent event = new DefaultModelBuildingEvent( model, request, problems ); + + catapult.fire( listener, event ); + } + } + + private boolean containsCoordinates( String message, String groupId, String artifactId, String version ) + { + return message != null && ( groupId == null || message.contains( groupId ) ) + && ( artifactId == null || message.contains( artifactId ) ) + && ( version == null || message.contains( version ) ); + } + + protected boolean hasModelErrors( ModelProblemCollectorExt problems ) + { + if ( problems instanceof DefaultModelProblemCollector ) + { + return ( (DefaultModelProblemCollector) problems ).hasErrors(); + } + else + { + // the default execution path only knows the DefaultModelProblemCollector, + // only reason it's not in signature is because it's package private + throw new IllegalStateException(); + } + } + + protected boolean hasFatalErrors( ModelProblemCollectorExt problems ) + { + if ( problems instanceof DefaultModelProblemCollector ) + { + return ( (DefaultModelProblemCollector) problems ).hasFatalErrors(); + } + else + { + // the default execution path only knows the DefaultModelProblemCollector, + // only reason it's not in signature is because it's package private + throw new IllegalStateException(); + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java new file mode 100644 index 00000000..36a0f46a --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java @@ -0,0 +1,243 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.composition.DefaultDependencyManagementImporter; +import org.apache.maven.model.composition.DependencyManagementImporter; +import org.apache.maven.model.inheritance.DefaultInheritanceAssembler; +import org.apache.maven.model.inheritance.InheritanceAssembler; +import org.apache.maven.model.interpolation.ModelInterpolator; +import org.apache.maven.model.interpolation.StringSearchModelInterpolator; +import org.apache.maven.model.io.DefaultModelReader; +import org.apache.maven.model.io.ModelReader; +import org.apache.maven.model.locator.DefaultModelLocator; +import org.apache.maven.model.locator.ModelLocator; +import org.apache.maven.model.management.DefaultDependencyManagementInjector; +import org.apache.maven.model.management.DefaultPluginManagementInjector; +import org.apache.maven.model.management.DependencyManagementInjector; +import org.apache.maven.model.management.PluginManagementInjector; +import org.apache.maven.model.normalization.DefaultModelNormalizer; +import org.apache.maven.model.normalization.ModelNormalizer; +import org.apache.maven.model.path.DefaultModelPathTranslator; +import org.apache.maven.model.path.DefaultModelUrlNormalizer; +import org.apache.maven.model.path.DefaultPathTranslator; +import org.apache.maven.model.path.DefaultUrlNormalizer; +import org.apache.maven.model.path.ModelPathTranslator; +import org.apache.maven.model.path.ModelUrlNormalizer; +import org.apache.maven.model.path.PathTranslator; +import org.apache.maven.model.path.UrlNormalizer; +import org.apache.maven.model.plugin.DefaultPluginConfigurationExpander; +import org.apache.maven.model.plugin.DefaultReportConfigurationExpander; +import org.apache.maven.model.plugin.DefaultReportingConverter; +import org.apache.maven.model.plugin.LifecycleBindingsInjector; +import org.apache.maven.model.plugin.PluginConfigurationExpander; +import org.apache.maven.model.plugin.ReportConfigurationExpander; +import org.apache.maven.model.plugin.ReportingConverter; +import org.apache.maven.model.profile.DefaultProfileInjector; +import org.apache.maven.model.profile.DefaultProfileSelector; +import org.apache.maven.model.profile.ProfileInjector; +import org.apache.maven.model.profile.ProfileSelector; +import org.apache.maven.model.profile.activation.FileProfileActivator; +import org.apache.maven.model.profile.activation.JdkVersionProfileActivator; +import org.apache.maven.model.profile.activation.OperatingSystemProfileActivator; +import org.apache.maven.model.profile.activation.ProfileActivator; +import org.apache.maven.model.profile.activation.PropertyProfileActivator; +import org.apache.maven.model.superpom.DefaultSuperPomProvider; +import org.apache.maven.model.superpom.SuperPomProvider; +import org.apache.maven.model.validation.DefaultModelValidator; +import org.apache.maven.model.validation.ModelValidator; + +/** + * A factory to create model builder instances when no dependency injection is available. Note: This class is + * only meant as a utility for developers that want to employ the model builder outside of the Maven build system, Maven + * plugins should always acquire model builder instances via dependency injection. Developers might want to subclass + * this factory to provide custom implementations for some of the components used by the model builder. + * + * @author Benjamin Bentmann + */ +public class DefaultModelBuilderFactory +{ + + protected ModelProcessor newModelProcessor() + { + DefaultModelProcessor processor = new DefaultModelProcessor(); + processor.setModelLocator( newModelLocator() ); + processor.setModelReader( newModelReader() ); + return processor; + } + + protected ModelLocator newModelLocator() + { + return new DefaultModelLocator(); + } + + protected ModelReader newModelReader() + { + return new DefaultModelReader(); + } + + protected ProfileSelector newProfileSelector() + { + DefaultProfileSelector profileSelector = new DefaultProfileSelector(); + + for ( ProfileActivator activator : newProfileActivators() ) + { + profileSelector.addProfileActivator( activator ); + } + + return profileSelector; + } + + protected ProfileActivator[] newProfileActivators() + { + return new ProfileActivator[] { new JdkVersionProfileActivator(), new OperatingSystemProfileActivator(), + new PropertyProfileActivator(), new FileProfileActivator().setPathTranslator( newPathTranslator() ) }; + } + + protected UrlNormalizer newUrlNormalizer() + { + return new DefaultUrlNormalizer(); + } + + protected PathTranslator newPathTranslator() + { + return new DefaultPathTranslator(); + } + + protected ModelInterpolator newModelInterpolator() + { + UrlNormalizer normalizer = newUrlNormalizer(); + PathTranslator pathTranslator = newPathTranslator(); + return new StringSearchModelInterpolator().setPathTranslator( pathTranslator ).setUrlNormalizer( normalizer ); + } + + protected ModelValidator newModelValidator() + { + return new DefaultModelValidator(); + } + + protected ModelNormalizer newModelNormalizer() + { + return new DefaultModelNormalizer(); + } + + protected ModelPathTranslator newModelPathTranslator() + { + return new DefaultModelPathTranslator().setPathTranslator( newPathTranslator() ); + } + + protected ModelUrlNormalizer newModelUrlNormalizer() + { + return new DefaultModelUrlNormalizer().setUrlNormalizer( newUrlNormalizer() ); + } + + protected InheritanceAssembler newInheritanceAssembler() + { + return new DefaultInheritanceAssembler(); + } + + protected ProfileInjector newProfileInjector() + { + return new DefaultProfileInjector(); + } + + protected SuperPomProvider newSuperPomProvider() + { + return new DefaultSuperPomProvider().setModelProcessor( newModelProcessor() ); + } + + protected DependencyManagementImporter newDependencyManagementImporter() + { + return new DefaultDependencyManagementImporter(); + } + + protected DependencyManagementInjector newDependencyManagementInjector() + { + return new DefaultDependencyManagementInjector(); + } + + protected LifecycleBindingsInjector newLifecycleBindingsInjector() + { + return new StubLifecycleBindingsInjector(); + } + + protected PluginManagementInjector newPluginManagementInjector() + { + return new DefaultPluginManagementInjector(); + } + + protected PluginConfigurationExpander newPluginConfigurationExpander() + { + return new DefaultPluginConfigurationExpander(); + } + + protected ReportConfigurationExpander newReportConfigurationExpander() + { + return new DefaultReportConfigurationExpander(); + } + + protected ReportingConverter newReportingConverter() + { + return new DefaultReportingConverter(); + } + + /** + * Creates a new model builder instance. + * + * @return The new model builder instance, never {@code null}. + */ + public DefaultModelBuilder newInstance() + { + DefaultModelBuilder modelBuilder = new DefaultModelBuilder(); + + modelBuilder.setModelProcessor( newModelProcessor() ); + modelBuilder.setModelValidator( newModelValidator() ); + modelBuilder.setModelNormalizer( newModelNormalizer() ); + modelBuilder.setModelPathTranslator( newModelPathTranslator() ); + modelBuilder.setModelUrlNormalizer( newModelUrlNormalizer() ); + modelBuilder.setModelInterpolator( newModelInterpolator() ); + modelBuilder.setInheritanceAssembler( newInheritanceAssembler() ); + modelBuilder.setProfileInjector( newProfileInjector() ); + modelBuilder.setProfileSelector( newProfileSelector() ); + modelBuilder.setSuperPomProvider( newSuperPomProvider() ); + modelBuilder.setDependencyManagementImporter( newDependencyManagementImporter() ); + modelBuilder.setDependencyManagementInjector( newDependencyManagementInjector() ); + modelBuilder.setLifecycleBindingsInjector( newLifecycleBindingsInjector() ); + modelBuilder.setPluginManagementInjector( newPluginManagementInjector() ); + modelBuilder.setPluginConfigurationExpander( newPluginConfigurationExpander() ); + modelBuilder.setReportConfigurationExpander( newReportConfigurationExpander() ); + modelBuilder.setReportingConverter( newReportingConverter() ); + + return modelBuilder; + } + + private static class StubLifecycleBindingsInjector + implements LifecycleBindingsInjector + { + + @Override + public void injectLifecycleBindings( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + } + + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java new file mode 100644 index 00000000..f72403b2 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java @@ -0,0 +1,64 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; + +/** + * Holds data relevant for a model building event. + * + * @author Benjamin Bentmann + */ +class DefaultModelBuildingEvent + implements ModelBuildingEvent +{ + + private final Model model; + + private final ModelBuildingRequest request; + + private final ModelProblemCollector problems; + + public DefaultModelBuildingEvent( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + this.model = model; + this.request = request; + this.problems = problems; + } + + @Override + public Model getModel() + { + return model; + } + + @Override + public ModelBuildingRequest getRequest() + { + return request; + } + + @Override + public ModelProblemCollector getProblems() + { + return problems; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java new file mode 100644 index 00000000..8b4a01b3 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java @@ -0,0 +1,408 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Properties; + +import org.apache.maven.model.Model; +import org.apache.maven.model.Profile; +import org.apache.maven.model.resolution.ModelResolver; +import org.apache.maven.model.resolution.WorkspaceModelResolver; + +/** + * Collects settings that control building of effective models. + * + * @author Benjamin Bentmann + */ +public class DefaultModelBuildingRequest + implements ModelBuildingRequest +{ + + private Model rawModel; + + private File pomFile; + + private ModelSource modelSource; + + private int validationLevel = VALIDATION_LEVEL_STRICT; + + private boolean processPlugins; + + private boolean twoPhaseBuilding; + + private boolean locationTracking; + + private List profiles; + + private List activeProfileIds; + + private List inactiveProfileIds; + + private Properties systemProperties; + + private Properties userProperties; + + private Date buildStartTime; + + private ModelResolver modelResolver; + + private ModelBuildingListener modelBuildingListener; + + private ModelCache modelCache; + + private WorkspaceModelResolver workspaceResolver; + + /** + * Creates an empty request. + */ + public DefaultModelBuildingRequest() + { + } + + /** + * Creates a shallow copy of the specified request. + * + * @param request The request to copy, must not be {@code null}. + */ + public DefaultModelBuildingRequest( ModelBuildingRequest request ) + { + setPomFile( request.getPomFile() ); + setModelSource( request.getModelSource() ); + setValidationLevel( request.getValidationLevel() ); + setProcessPlugins( request.isProcessPlugins() ); + setTwoPhaseBuilding( request.isTwoPhaseBuilding() ); + setProfiles( request.getProfiles() ); + setActiveProfileIds( request.getActiveProfileIds() ); + setInactiveProfileIds( request.getInactiveProfileIds() ); + setSystemProperties( request.getSystemProperties() ); + setUserProperties( request.getUserProperties() ); + setBuildStartTime( request.getBuildStartTime() ); + setModelResolver( request.getModelResolver() ); + setModelBuildingListener( request.getModelBuildingListener() ); + setModelCache( request.getModelCache() ); + } + + @Override + public File getPomFile() + { + return pomFile; + } + + @Override + public DefaultModelBuildingRequest setPomFile( File pomFile ) + { + this.pomFile = ( pomFile != null ) ? pomFile.getAbsoluteFile() : null; + + return this; + } + + @Override + public synchronized ModelSource getModelSource() + { + if ( modelSource == null && pomFile != null ) + { + modelSource = new FileModelSource( pomFile ); + } + return modelSource; + } + + @Override + public DefaultModelBuildingRequest setModelSource( ModelSource modelSource ) + { + this.modelSource = modelSource; + + return this; + } + + @Override + public int getValidationLevel() + { + return validationLevel; + } + + @Override + public DefaultModelBuildingRequest setValidationLevel( int validationLevel ) + { + this.validationLevel = validationLevel; + + return this; + } + + @Override + public boolean isProcessPlugins() + { + return processPlugins; + } + + @Override + public DefaultModelBuildingRequest setProcessPlugins( boolean processPlugins ) + { + this.processPlugins = processPlugins; + + return this; + } + + @Override + public boolean isTwoPhaseBuilding() + { + return twoPhaseBuilding; + } + + @Override + public DefaultModelBuildingRequest setTwoPhaseBuilding( boolean twoPhaseBuilding ) + { + this.twoPhaseBuilding = twoPhaseBuilding; + + return this; + } + + @Override + public boolean isLocationTracking() + { + return locationTracking; + } + + @Override + public DefaultModelBuildingRequest setLocationTracking( boolean locationTracking ) + { + this.locationTracking = locationTracking; + + return this; + } + + @Override + public List getProfiles() + { + if ( profiles == null ) + { + profiles = new ArrayList(); + } + + return profiles; + } + + @Override + public DefaultModelBuildingRequest setProfiles( List profiles ) + { + if ( profiles != null ) + { + this.profiles = new ArrayList( profiles ); + } + else + { + this.profiles = null; + } + + return this; + } + + @Override + public List getActiveProfileIds() + { + if ( activeProfileIds == null ) + { + activeProfileIds = new ArrayList(); + } + + return activeProfileIds; + } + + @Override + public DefaultModelBuildingRequest setActiveProfileIds( List activeProfileIds ) + { + if ( activeProfileIds != null ) + { + this.activeProfileIds = new ArrayList( activeProfileIds ); + } + else + { + this.activeProfileIds = null; + } + + return this; + } + + @Override + public List getInactiveProfileIds() + { + if ( inactiveProfileIds == null ) + { + inactiveProfileIds = new ArrayList(); + } + + return inactiveProfileIds; + } + + @Override + public DefaultModelBuildingRequest setInactiveProfileIds( List inactiveProfileIds ) + { + if ( inactiveProfileIds != null ) + { + this.inactiveProfileIds = new ArrayList( inactiveProfileIds ); + } + else + { + this.inactiveProfileIds = null; + } + + return this; + } + + @Override + public Properties getSystemProperties() + { + if ( systemProperties == null ) + { + systemProperties = new Properties(); + } + + return systemProperties; + } + + @Override + public DefaultModelBuildingRequest setSystemProperties( Properties systemProperties ) + { + if ( systemProperties != null ) + { + this.systemProperties = new Properties(); + this.systemProperties.putAll( systemProperties ); + } + else + { + this.systemProperties = null; + } + + return this; + } + + @Override + public Properties getUserProperties() + { + if ( userProperties == null ) + { + userProperties = new Properties(); + } + + return userProperties; + } + + @Override + public DefaultModelBuildingRequest setUserProperties( Properties userProperties ) + { + if ( userProperties != null ) + { + this.userProperties = new Properties(); + this.userProperties.putAll( userProperties ); + } + else + { + this.userProperties = null; + } + + return this; + } + + @Override + public Date getBuildStartTime() + { + return buildStartTime; + } + + @Override + public ModelBuildingRequest setBuildStartTime( Date buildStartTime ) + { + this.buildStartTime = buildStartTime; + + return this; + } + + @Override + public ModelResolver getModelResolver() + { + return this.modelResolver; + } + + @Override + public DefaultModelBuildingRequest setModelResolver( ModelResolver modelResolver ) + { + this.modelResolver = modelResolver; + + return this; + } + + @Override + public ModelBuildingListener getModelBuildingListener() + { + return modelBuildingListener; + } + + @Override + public ModelBuildingRequest setModelBuildingListener( ModelBuildingListener modelBuildingListener ) + { + this.modelBuildingListener = modelBuildingListener; + + return this; + } + + @Override + public ModelCache getModelCache() + { + return this.modelCache; + } + + @Override + public DefaultModelBuildingRequest setModelCache( ModelCache modelCache ) + { + this.modelCache = modelCache; + + return this; + } + + @Override + public Model getRawModel() + { + return rawModel; + } + + @Override + public ModelBuildingRequest setRawModel( Model rawModel ) + { + this.rawModel = rawModel; + return this; + } + + @Override + public WorkspaceModelResolver getWorkspaceModelResolver() + { + return workspaceResolver; + } + + @Override + public ModelBuildingRequest setWorkspaceModelResolver( WorkspaceModelResolver workspaceResolver ) + { + this.workspaceResolver = workspaceResolver; + return this; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingResult.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingResult.java new file mode 100644 index 00000000..61fb434a --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingResult.java @@ -0,0 +1,180 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.maven.model.Model; +import org.apache.maven.model.Profile; + +/** + * Collects the output of the model builder. + * + * @author Benjamin Bentmann + */ +class DefaultModelBuildingResult + implements ModelBuildingResult +{ + + private Model effectiveModel; + + private List modelIds; + + private Map rawModels; + + private Map> activePomProfiles; + + private List activeExternalProfiles; + + private List problems; + + public DefaultModelBuildingResult() + { + modelIds = new ArrayList(); + rawModels = new HashMap(); + activePomProfiles = new HashMap>(); + activeExternalProfiles = new ArrayList(); + problems = new ArrayList(); + } + + @Override + public Model getEffectiveModel() + { + return effectiveModel; + } + + public DefaultModelBuildingResult setEffectiveModel( Model model ) + { + this.effectiveModel = model; + + return this; + } + + @Override + public List getModelIds() + { + return modelIds; + } + + public DefaultModelBuildingResult addModelId( String modelId ) + { + if ( modelId == null ) + { + throw new IllegalArgumentException( "no model identifier specified" ); + } + + modelIds.add( modelId ); + + return this; + } + + @Override + public Model getRawModel() + { + return rawModels.get( modelIds.get( 0 ) ); + } + + @Override + public Model getRawModel( String modelId ) + { + return rawModels.get( modelId ); + } + + public DefaultModelBuildingResult setRawModel( String modelId, Model rawModel ) + { + if ( modelId == null ) + { + throw new IllegalArgumentException( "no model identifier specified" ); + } + + rawModels.put( modelId, rawModel ); + + return this; + } + + @Override + public List getActivePomProfiles( String modelId ) + { + return activePomProfiles.get( modelId ); + } + + public DefaultModelBuildingResult setActivePomProfiles( String modelId, List activeProfiles ) + { + if ( modelId == null ) + { + throw new IllegalArgumentException( "no model identifier specified" ); + } + + if ( activeProfiles != null ) + { + this.activePomProfiles.put( modelId, new ArrayList( activeProfiles ) ); + } + else + { + this.activePomProfiles.remove( modelId ); + } + + return this; + } + + @Override + public List getActiveExternalProfiles() + { + return activeExternalProfiles; + } + + public DefaultModelBuildingResult setActiveExternalProfiles( List activeProfiles ) + { + if ( activeProfiles != null ) + { + this.activeExternalProfiles = new ArrayList( activeProfiles ); + } + else + { + this.activeExternalProfiles.clear(); + } + + return this; + } + + @Override + public List getProblems() + { + return problems; + } + + public DefaultModelBuildingResult setProblems( List problems ) + { + if ( problems != null ) + { + this.problems = new ArrayList( problems ); + } + else + { + this.problems.clear(); + } + + return this; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java new file mode 100644 index 00000000..0892f0a5 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java @@ -0,0 +1,175 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; + +/** + * Describes a problem that was encountered during model building. A problem can either be an exception that was thrown + * or a simple string message. In addition, a problem carries a hint about its source, e.g. the POM file that exhibits + * the problem. + * + * @author Benjamin Bentmann + */ +public class DefaultModelProblem + implements ModelProblem +{ + + private final String source; + + private final int lineNumber; + + private final int columnNumber; + + private final String modelId; + + private final String message; + + private final Exception exception; + + private final Severity severity; + + private final Version version; + + + /** + * Creates a new problem with the specified message and exception. + * + * @param message The message describing the problem, may be {@code null}. + * @param severity The severity level of the problem, may be {@code null} to default to + * {@link ModelProblem.Severity#ERROR}. + * @param source The source of the problem, may be {@code null}. + * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. + * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. + * @param exception The exception that caused this problem, may be {@code null}. + */ + //mkleint: does this need to be public? + public DefaultModelProblem( String message, Severity severity, Version version, Model source, int lineNumber, + int columnNumber, Exception exception ) + { + this( message, severity, version, ModelProblemUtils.toPath( source ), lineNumber, columnNumber, + ModelProblemUtils.toId( source ), exception ); + } + + /** + * Creates a new problem with the specified message and exception. + * + * @param message The message describing the problem, may be {@code null}. + * @param severity The severity level of the problem, may be {@code null} to default to + * {@link ModelProblem.Severity#ERROR}. + * @param version The version since the problem is relevant + * @param source A hint about the source of the problem like a file path, may be {@code null}. + * @param lineNumber The one-based index of the line containing the problem or {@code -1} if unknown. + * @param columnNumber The one-based index of the column containing the problem or {@code -1} if unknown. + * @param modelId The identifier of the model that exhibits the problem, may be {@code null}. + * @param exception The exception that caused this problem, may be {@code null}. + */ + //mkleint: does this need to be public? + public DefaultModelProblem( String message, Severity severity, Version version, String source, int lineNumber, + int columnNumber, String modelId, Exception exception ) + { + this.message = message; + this.severity = ( severity != null ) ? severity : Severity.ERROR; + this.source = ( source != null ) ? source : ""; + this.lineNumber = lineNumber; + this.columnNumber = columnNumber; + this.modelId = ( modelId != null ) ? modelId : ""; + this.exception = exception; + this.version = version; + } + + @Override + public String getSource() + { + return source; + } + + @Override + public int getLineNumber() + { + return lineNumber; + } + + @Override + public int getColumnNumber() + { + return columnNumber; + } + + @Override + public String getModelId() + { + return modelId; + } + + @Override + public Exception getException() + { + return exception; + } + + @Override + public String getMessage() + { + String msg; + + if ( message != null && message.length() > 0 ) + { + msg = message; + } + else + { + msg = exception.getMessage(); + + if ( msg == null ) + { + msg = ""; + } + } + + return msg; + } + + @Override + public Severity getSeverity() + { + return severity; + } + + @Override + public Version getVersion() + { + return version; + } + + + @Override + public String toString() + { + StringBuilder buffer = new StringBuilder( 128 ); + + buffer.append( "[" ).append( getSeverity() ).append( "] " ); + buffer.append( getMessage() ); + buffer.append( " @ " ).append( ModelProblemUtils.formatLocation( this, null ) ); + + return buffer.toString(); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblemCollector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblemCollector.java new file mode 100644 index 00000000..89d5cb21 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblemCollector.java @@ -0,0 +1,200 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.EnumSet; +import java.util.List; +import java.util.Set; + +import org.apache.maven.model.Model; +import org.apache.maven.model.io.ModelParseException; + +/** + * Collects problems that are encountered during model building. The primary purpose of this component is to account for + * the fact that the problem reporter has/should not have information about the calling context and hence cannot provide + * an expressive source hint for the model problem. Instead, the source hint is configured by the model builder before + * it delegates to other components that potentially encounter problems. Then, the problem reporter can focus on + * providing a simple error message, leaving the donkey work of creating a nice model problem to this component. + * + * @author Benjamin Bentmann + */ +class DefaultModelProblemCollector + implements ModelProblemCollectorExt +{ + + private final ModelBuildingResult result; + + private List problems; + + private String source; + + private Model sourceModel; + + private Model rootModel; + + private Set severities = EnumSet.noneOf( ModelProblem.Severity.class ); + + public DefaultModelProblemCollector( ModelBuildingResult result ) + { + this.result = result; + this.problems = result.getProblems(); + + for ( ModelProblem problem : this.problems ) + { + severities.add( problem.getSeverity() ); + } + } + + public boolean hasFatalErrors() + { + return severities.contains( ModelProblem.Severity.FATAL ); + } + + public boolean hasErrors() + { + return severities.contains( ModelProblem.Severity.ERROR ) || severities.contains( ModelProblem.Severity.FATAL ); + } + + @Override + public List getProblems() + { + return problems; + } + + public void setSource( String source ) + { + this.source = source; + this.sourceModel = null; + } + + public void setSource( Model source ) + { + this.sourceModel = source; + this.source = null; + + if ( rootModel == null ) + { + rootModel = source; + } + } + + private String getSource() + { + if ( source == null && sourceModel != null ) + { + source = ModelProblemUtils.toPath( sourceModel ); + } + return source; + } + + private String getModelId() + { + return ModelProblemUtils.toId( sourceModel ); + } + + public void setRootModel( Model rootModel ) + { + this.rootModel = rootModel; + } + + public Model getRootModel() + { + return rootModel; + } + + public String getRootModelId() + { + return ModelProblemUtils.toId( rootModel ); + } + + public void add( ModelProblem problem ) + { + problems.add( problem ); + + severities.add( problem.getSeverity() ); + } + + public void addAll( List problems ) + { + this.problems.addAll( problems ); + + for ( ModelProblem problem : problems ) + { + severities.add( problem.getSeverity() ); + } + } + + @Override + public void add( ModelProblemCollectorRequest req ) + { + int line = -1; + int column = -1; + String source = null; + String modelId = null; + + if ( req.getLocation() != null ) + { + line = req.getLocation().getLineNumber(); + column = req.getLocation().getColumnNumber(); + if ( req.getLocation().getSource() != null ) + { + modelId = req.getLocation().getSource().getModelId(); + source = req.getLocation().getSource().getLocation(); + } + } + + if ( modelId == null ) + { + modelId = getModelId(); + source = getSource(); + } + + if ( line <= 0 && column <= 0 && req.getException() instanceof ModelParseException ) + { + ModelParseException e = (ModelParseException) req.getException(); + line = e.getLineNumber(); + column = e.getColumnNumber(); + } + + ModelProblem problem = + new DefaultModelProblem( req.getMessage(), req.getSeverity(), req.getVersion(), source, line, column, + modelId, req.getException() ); + + add( problem ); + } + + public ModelBuildingException newModelBuildingException() + { + ModelBuildingResult result = this.result; + if ( result.getModelIds().isEmpty() ) + { + DefaultModelBuildingResult tmp = new DefaultModelBuildingResult(); + tmp.setEffectiveModel( result.getEffectiveModel() ); + tmp.setProblems( getProblems() ); + tmp.setActiveExternalProfiles( result.getActiveExternalProfiles() ); + String id = getRootModelId(); + tmp.addModelId( id ); + tmp.setRawModel( id, getRootModel() ); + result = tmp; + } + return new ModelBuildingException( result ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java new file mode 100644 index 00000000..a4d5fa93 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java @@ -0,0 +1,84 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.util.Map; + +import org.apache.maven.model.Model; +import org.apache.maven.model.io.ModelReader; +import org.apache.maven.model.locator.ModelLocator; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; + +@Component( role = ModelProcessor.class ) +public class DefaultModelProcessor + implements ModelProcessor +{ + + @Requirement + private ModelLocator locator; + + @Requirement + private ModelReader reader; + + public DefaultModelProcessor setModelLocator( ModelLocator locator ) + { + this.locator = locator; + return this; + } + + public DefaultModelProcessor setModelReader( ModelReader reader ) + { + this.reader = reader; + return this; + } + + @Override + public File locatePom( File projectDirectory ) + { + return locator.locatePom( projectDirectory ); + } + + @Override + public Model read( File input, Map options ) + throws IOException + { + return reader.read( input, options ); + } + + @Override + public Model read( Reader input, Map options ) + throws IOException + { + return reader.read( input, options ); + } + + @Override + public Model read( InputStream input, Map options ) + throws IOException + { + return reader.read( input, options ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/FileModelSource.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/FileModelSource.java new file mode 100644 index 00000000..a2e11417 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/FileModelSource.java @@ -0,0 +1,83 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.net.URI; + +import org.apache.maven.building.FileSource; + +/** + * Wraps an ordinary {@link File} as a model source. + * + * @author Benjamin Bentmann + */ +public class FileModelSource extends FileSource implements ModelSource2 +{ + + /** + * Creates a new model source backed by the specified file. + * + * @param pomFile The POM file, must not be {@code null}. + */ + public FileModelSource( File pomFile ) + { + super( pomFile ); + } + + /** + * + * @return the file of this source + * + * @deprecated instead use {@link #getFile()} + */ + @Deprecated + public File getPomFile() + { + return getFile(); + } + + @Override + public ModelSource2 getRelatedSource( String relPath ) + { + relPath = relPath.replace( '\\', File.separatorChar ).replace( '/', File.separatorChar ); + + File relatedPom = new File( getFile().getParentFile(), relPath ); + + if ( relatedPom.isDirectory() ) + { + // TODO figure out how to reuse ModelLocator.locatePom(File) here + relatedPom = new File( relatedPom, "pom.xml" ); + } + + if ( relatedPom.isFile() && relatedPom.canRead() ) + { + return new FileModelSource( new File( relatedPom.toURI().normalize() ) ); + } + + return null; + } + + @Override + public URI getLocationURI() + { + return getFile().toURI(); + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java new file mode 100644 index 00000000..c5c2cbfa --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java @@ -0,0 +1,285 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.Date; +import java.util.List; +import java.util.Properties; + +import org.apache.maven.model.Model; +import org.apache.maven.model.Profile; +import org.apache.maven.model.resolution.ModelResolver; +import org.apache.maven.model.resolution.WorkspaceModelResolver; + +/** + * A model building request that delegates all methods invocations to another request, meant for easy transformations by + * subclassing. + * + * @author Benjamin Bentmann + */ +class FilterModelBuildingRequest + implements ModelBuildingRequest +{ + + protected ModelBuildingRequest request; + + public FilterModelBuildingRequest( ModelBuildingRequest request ) + { + this.request = request; + } + + @Override + public File getPomFile() + { + return request.getPomFile(); + } + + @Override + public FilterModelBuildingRequest setPomFile( File pomFile ) + { + request.setPomFile( pomFile ); + + return this; + } + + @Override + public ModelSource getModelSource() + { + return request.getModelSource(); + } + + @Override + public FilterModelBuildingRequest setModelSource( ModelSource modelSource ) + { + request.setModelSource( modelSource ); + + return this; + } + + @Override + public int getValidationLevel() + { + return request.getValidationLevel(); + } + + @Override + public FilterModelBuildingRequest setValidationLevel( int validationLevel ) + { + request.setValidationLevel( validationLevel ); + + return this; + } + + @Override + public boolean isProcessPlugins() + { + return request.isProcessPlugins(); + } + + @Override + public FilterModelBuildingRequest setProcessPlugins( boolean processPlugins ) + { + request.setProcessPlugins( processPlugins ); + + return this; + } + + @Override + public boolean isTwoPhaseBuilding() + { + return request.isTwoPhaseBuilding(); + } + + @Override + public FilterModelBuildingRequest setTwoPhaseBuilding( boolean twoPhaseBuilding ) + { + request.setTwoPhaseBuilding( twoPhaseBuilding ); + + return this; + } + + @Override + public boolean isLocationTracking() + { + return request.isLocationTracking(); + } + + @Override + public FilterModelBuildingRequest setLocationTracking( boolean locationTracking ) + { + request.setLocationTracking( locationTracking ); + + return this; + } + + @Override + public List getProfiles() + { + return request.getProfiles(); + } + + @Override + public FilterModelBuildingRequest setProfiles( List profiles ) + { + request.setProfiles( profiles ); + + return this; + } + + @Override + public List getActiveProfileIds() + { + return request.getActiveProfileIds(); + } + + @Override + public FilterModelBuildingRequest setActiveProfileIds( List activeProfileIds ) + { + request.setActiveProfileIds( activeProfileIds ); + + return this; + } + + @Override + public List getInactiveProfileIds() + { + return request.getInactiveProfileIds(); + } + + @Override + public FilterModelBuildingRequest setInactiveProfileIds( List inactiveProfileIds ) + { + request.setInactiveProfileIds( inactiveProfileIds ); + + return this; + } + + @Override + public Properties getSystemProperties() + { + return request.getSystemProperties(); + } + + @Override + public FilterModelBuildingRequest setSystemProperties( Properties systemProperties ) + { + request.setSystemProperties( systemProperties ); + + return this; + } + + @Override + public Properties getUserProperties() + { + return request.getUserProperties(); + } + + @Override + public FilterModelBuildingRequest setUserProperties( Properties userProperties ) + { + request.setUserProperties( userProperties ); + + return this; + } + + @Override + public Date getBuildStartTime() + { + return request.getBuildStartTime(); + } + + @Override + public ModelBuildingRequest setBuildStartTime( Date buildStartTime ) + { + request.setBuildStartTime( buildStartTime ); + + return this; + } + + @Override + public ModelResolver getModelResolver() + { + return request.getModelResolver(); + } + + @Override + public FilterModelBuildingRequest setModelResolver( ModelResolver modelResolver ) + { + request.setModelResolver( modelResolver ); + + return this; + } + + @Override + public ModelBuildingListener getModelBuildingListener() + { + return request.getModelBuildingListener(); + } + + @Override + public ModelBuildingRequest setModelBuildingListener( ModelBuildingListener modelBuildingListener ) + { + request.setModelBuildingListener( modelBuildingListener ); + + return this; + } + + @Override + public ModelCache getModelCache() + { + return request.getModelCache(); + } + + @Override + public FilterModelBuildingRequest setModelCache( ModelCache modelCache ) + { + request.setModelCache( modelCache ); + + return this; + } + + @Override + public Model getRawModel() + { + return request.getRawModel(); + } + + @Override + public ModelBuildingRequest setRawModel( Model rawModel ) + { + request.setRawModel( rawModel ); + return this; + } + + @Override + public WorkspaceModelResolver getWorkspaceModelResolver() + { + return request.getWorkspaceModelResolver(); + } + + @Override + public ModelBuildingRequest setWorkspaceModelResolver( WorkspaceModelResolver workspaceResolver ) + { + request.setWorkspaceModelResolver( workspaceResolver ); + return this; + } + +} \ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuilder.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuilder.java new file mode 100644 index 00000000..2a49a213 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuilder.java @@ -0,0 +1,67 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +import org.apache.maven.model.Model; + +/** + * Builds the effective model from a POM. + * + * @author Benjamin Bentmann + */ +public interface ModelBuilder +{ + + /** + * Builds the effective model of the specified POM. + * + * @param request The model building request that holds the parameters, must not be {@code null}. + * @return The result of the model building, never {@code null}. + * @throws ModelBuildingException If the effective model could not be built. + */ + ModelBuildingResult build( ModelBuildingRequest request ) + throws ModelBuildingException; + + /** + * Builds the effective model by completing the specified interim result which was produced by a previous call to + * {@link #build(ModelBuildingRequest)} with {@link ModelBuildingRequest#isTwoPhaseBuilding()} being {@code true}. + * The model building request passed to this method must be the same as the one used for the first phase of the + * model building. + * + * @param request The model building request that holds the parameters, must not be {@code null}. + * @param result The interim result of the first phase of model building, must not be {@code null}. + * @return The result of the model building, never {@code null}. + * @throws ModelBuildingException If the effective model could not be built. + */ + ModelBuildingResult build( ModelBuildingRequest request, ModelBuildingResult result ) + throws ModelBuildingException; + + /** + * Performs only the part of {@link ModelBuilder#build(ModelBuildingRequest)} that loads the raw model + * + * @param request + * @return + * @throws ModelBuildingException + */ + Result buildRawModel( File pomFile, int validationLevel, boolean locationTracking ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEvent.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEvent.java new file mode 100644 index 00000000..2995b1bf --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEvent.java @@ -0,0 +1,53 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; + +/** + * Holds data relevant for a model building event. + * + * @author Benjamin Bentmann + */ +public interface ModelBuildingEvent +{ + + /** + * Gets the model being built. The precise state of this model depends on the event being fired. + * + * @return The model being built, never {@code null}. + */ + Model getModel(); + + /** + * Gets the model building request being processed. + * + * @return The model building request being processed, never {@code null}. + */ + ModelBuildingRequest getRequest(); + + /** + * Gets the container used to collect problems that were encountered while processing the event. + * + * @return The container used to collect problems that were encountered, never {@code null}. + */ + ModelProblemCollector getProblems(); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEventCatapult.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEventCatapult.java new file mode 100644 index 00000000..092dc4e0 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEventCatapult.java @@ -0,0 +1,48 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Assists in firing events from a generic method by abstracting from the actual callback method to be called on the + * listener. + * + * @author Benjamin Bentmann + */ +interface ModelBuildingEventCatapult +{ + + /** + * Notifies the specified listener of the given event. + * + * @param listener The listener to notify, must not be {@code null}. + * @param event The event to fire, must not be {@code null}. + */ + void fire( ModelBuildingListener listener, ModelBuildingEvent event ); + + ModelBuildingEventCatapult BUILD_EXTENSIONS_ASSEMBLED = new ModelBuildingEventCatapult() + { + @Override + public void fire( ModelBuildingListener listener, ModelBuildingEvent event ) + { + listener.buildExtensionsAssembled( event ); + } + }; + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java new file mode 100644 index 00000000..434cb591 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java @@ -0,0 +1,180 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Collections; +import java.util.List; + +import org.apache.maven.model.Model; + +/** + * Signals one ore more errors during model building. The model builder tries to collect as many problems as possible + * before eventually failing to provide callers with rich error information. Use {@link #getProblems()} to query the + * details of the failure. + * + * @author Benjamin Bentmann + */ +public class ModelBuildingException + extends Exception +{ + + private final ModelBuildingResult result; + + /** + * Creates a new exception with the specified problems. + * + * @param model The model that could not be built, may be {@code null}. + * @param modelId The identifier of the model that could not be built, may be {@code null}. + * @param problems The problems that causes this exception, may be {@code null}. + * @deprecated Use {@link #ModelBuildingException(ModelBuildingResult)} instead. + */ + @Deprecated + public ModelBuildingException( Model model, String modelId, List problems ) + { + super( toMessage( modelId, problems ) ); + + if ( model != null ) + { + DefaultModelBuildingResult tmp = new DefaultModelBuildingResult(); + if ( modelId == null ) + { + modelId = ""; + } + tmp.addModelId( modelId ); + tmp.setRawModel( modelId, model ); + tmp.setProblems( problems ); + result = tmp; + } + else + { + result = null; + } + } + + /** + * Creates a new exception from the specified interim result and its associated problems. + * + * @param result The interim result, may be {@code null}. + */ + public ModelBuildingException( ModelBuildingResult result ) + { + super( toMessage( result ) ); + this.result = result; + } + + /** + * Gets the interim result of the model building up to the point where it failed. + * + * @return The interim model building result or {@code null} if not available. + */ + public ModelBuildingResult getResult() + { + return result; + } + + /** + * Gets the model that could not be built properly. + * + * @return The erroneous model or {@code null} if not available. + */ + public Model getModel() + { + if ( result == null ) + { + return null; + } + if ( result.getEffectiveModel() != null ) + { + return result.getEffectiveModel(); + } + return result.getRawModel(); + } + + /** + * Gets the identifier of the POM whose effective model could not be built. The general format of the identifier is + * {@code ::} but some of these coordinates may still be unknown at the point the + * exception is thrown so this information is merely meant to assist the user. + * + * @return The identifier of the POM or an empty string if not known, never {@code null}. + */ + public String getModelId() + { + if ( result == null || result.getModelIds().isEmpty() ) + { + return ""; + } + return result.getModelIds().get( 0 ); + } + + /** + * Gets the problems that caused this exception. + * + * @return The problems that caused this exception, never {@code null}. + */ + public List getProblems() + { + if ( result == null ) + { + return Collections.emptyList(); + } + return result.getProblems(); + } + + private static String toMessage( ModelBuildingResult result ) + { + if ( result != null && !result.getModelIds().isEmpty() ) + { + return toMessage( result.getModelIds().get( 0 ), result.getProblems() ); + } + return null; + } + + private static String toMessage( String modelId, List problems ) + { + StringWriter buffer = new StringWriter( 1024 ); + + PrintWriter writer = new PrintWriter( buffer ); + + writer.print( problems.size() ); + writer.print( ( problems.size() == 1 ) ? " problem was " : " problems were " ); + writer.print( "encountered while building the effective model" ); + if ( modelId != null && modelId.length() > 0 ) + { + writer.print( " for " ); + writer.print( modelId ); + } + writer.println(); + + for ( ModelProblem problem : problems ) + { + writer.print( "[" ); + writer.print( problem.getSeverity() ); + writer.print( "] " ); + writer.print( problem.getMessage() ); + writer.print( " @ " ); + writer.println( ModelProblemUtils.formatLocation( problem, modelId ) ); + } + + return buffer.toString(); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingListener.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingListener.java new file mode 100644 index 00000000..21029cc8 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingListener.java @@ -0,0 +1,40 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Defines events that the model builder fires during construction of the effective model. When a listener encounteres + * errors while processing the event, it can report these problems via {@link ModelBuildingEvent#getProblems()}. + * Note: To cope with future extensions to this interface, it is strongly recommended to extend + * {@link AbstractModelBuildingListener} rather than to directly implement this interface. + * + * @author Benjamin Bentmann + */ +public interface ModelBuildingListener +{ + + /** + * Notifies the listener that the model has been constructed to the extent where build extensions can be processed. + * + * @param event The details about the event. + */ + void buildExtensionsAssembled( ModelBuildingEvent event ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java new file mode 100644 index 00000000..c10274db --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java @@ -0,0 +1,338 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.Date; +import java.util.List; +import java.util.Properties; + +import org.apache.maven.model.Model; +import org.apache.maven.model.Profile; +import org.apache.maven.model.resolution.ModelResolver; +import org.apache.maven.model.resolution.WorkspaceModelResolver; + +/** + * Collects settings that control the building of effective models. + * + * @author Benjamin Bentmann + */ +public interface ModelBuildingRequest +{ + + /** + * Denotes minimal validation of POMs. This validation level is meant for processing of POMs from repositories + * during metadata retrieval. + */ + int VALIDATION_LEVEL_MINIMAL = 0; + + /** + * Denotes validation as performed by Maven 2.0. This validation level is meant as a compatibility mode to allow + * users to migrate their projects. + */ + int VALIDATION_LEVEL_MAVEN_2_0 = 20; + + /** + * Denotes validation as performed by Maven 3.0. This validation level is meant for existing projects. + */ + int VALIDATION_LEVEL_MAVEN_3_0 = 30; + + /** + * Denotes validation as performed by Maven 3.1. This validation level is meant for new projects. + */ + int VALIDATION_LEVEL_MAVEN_3_1 = 31; + + /** + * Denotes strict validation as recommended by the current Maven version. + */ + int VALIDATION_LEVEL_STRICT = VALIDATION_LEVEL_MAVEN_3_0; + + /** + * Gets the raw model to build. If not set, model source will be used to load raw model. + * + * @return The raw model to build or {@code null} if not set. + */ + Model getRawModel(); + + /** + * Set raw model. + * + * @param model + */ + ModelBuildingRequest setRawModel( Model rawModel ); + + /** + * Gets the source of the POM to process. + * + * @return The source of the POM or {@code null} if not set. + */ + ModelSource getModelSource(); + + /** + * Sets the source of the POM to process. Eventually, either {@link #setModelSource(ModelSource)} or + * {@link #setPomFile(File)} must be set. + * + * @param modelSource The source of the POM to process, may be {@code null}. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setModelSource( ModelSource modelSource ); + + /** + * Gets the POM file of the project to build. + * + * @return The POM file of the project or {@code null} if not applicable (i.e. when processing a POM from the + * repository). + */ + File getPomFile(); + + /** + * Sets the POM file of the project to build. Note that providing the path to a POM file via this method will make + * the model builder operate in project mode. This mode is meant for effective models that are employed during the + * build process of a local project. Hence the effective model will support the notion of a project directory. To + * build the model for a POM from the repository, use {@link #setModelSource(ModelSource)} in combination with a + * {@link FileModelSource} instead. + * + * @param pomFile The POM file of the project to build the effective model for, may be {@code null} to build the + * model of some POM from the repository. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setPomFile( File pomFile ); + + /** + * Gets the level of validation to perform on processed models. + * + * @return The level of validation to perform on processed models. + */ + int getValidationLevel(); + + /** + * Sets the level of validation to perform on processed models. For building of projects, + * {@link #VALIDATION_LEVEL_STRICT} should be used to ensure proper building. For the mere retrievel of dependencies + * during artifact resolution, {@link #VALIDATION_LEVEL_MINIMAL} should be used to account for models of poor + * quality. By default, models are validated in strict mode. + * + * @param validationLevel The level of validation to perform on processed models. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setValidationLevel( int validationLevel ); + + /** + * Indicates whether plugin executions and configurations should be processed. If enabled, lifecycle-induced plugin + * executions will be injected into the model and common plugin configuration will be propagated to individual + * executions. + * + * @return {@code true} if plugins should be processed, {@code false} otherwise. + */ + boolean isProcessPlugins(); + + /** + * Controls the processing of plugin executions and configurations. + * + * @param processPlugins {@code true} to enable plugin processing, {@code false} otherwise. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setProcessPlugins( boolean processPlugins ); + + /** + * Indicates whether the model building should happen in two phases. If enabled, the initial invocation of the model + * builder will only produce an interim result which may be used to analyze inter-model dependencies before the + * final invocation of the model builder is performed. + * + * @return {@code true} if two-phase building is enabled, {@code false} if the model should be build in a single + * step. + */ + boolean isTwoPhaseBuilding(); + + /** + * Enables/disables two-phase building. If enabled, the initial invocation of the model builder will only produce an + * interim result which may be used to analyze inter-model dependencies before the final invocation of the model + * builder is performed. + * + * @param twoPhaseBuilding {@code true} to enable two-phase building, {@code false} if the model should be build in + * a single step. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setTwoPhaseBuilding( boolean twoPhaseBuilding ); + + /** + * Indicates whether the model should track the line/column number of the model source from which it was parsed. + * + * @return {@code true} if location tracking is enabled, {@code false} otherwise. + */ + boolean isLocationTracking(); + + /** + * Enables/disables the tracking of line/column numbers for the model source being parsed. By default, input + * locations are not tracked. + * + * @param locationTracking {@code true} to enable location tracking, {@code false} to disable it. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setLocationTracking( boolean locationTracking ); + + /** + * Gets the external profiles that should be considered for model building. + * + * @return The external profiles that should be considered for model building, never {@code null}. + */ + List getProfiles(); + + /** + * Sets the external profiles that should be considered for model building. + * + * @param profiles The external profiles that should be considered for model building, may be {@code null}. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setProfiles( List profiles ); + + /** + * Gets the identifiers of those profiles that should be activated by explicit demand. + * + * @return The identifiers of those profiles to activate, never {@code null}. + */ + List getActiveProfileIds(); + + /** + * Sets the identifiers of those profiles that should be activated by explicit demand. + * + * @param activeProfileIds The identifiers of those profiles to activate, may be {@code null}. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setActiveProfileIds( List activeProfileIds ); + + /** + * Gets the identifiers of those profiles that should be deactivated by explicit demand. + * + * @return The identifiers of those profiles to deactivate, never {@code null}. + */ + List getInactiveProfileIds(); + + /** + * Sets the identifiers of those profiles that should be deactivated by explicit demand. + * + * @param inactiveProfileIds The identifiers of those profiles to deactivate, may be {@code null}. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setInactiveProfileIds( List inactiveProfileIds ); + + /** + * Gets the system properties to use for interpolation and profile activation. The system properties are collected + * from the runtime environment like {@link System#getProperties()} and environment variables. + * + * @return The system properties, never {@code null}. + */ + Properties getSystemProperties(); + + /** + * Sets the system properties to use for interpolation and profile activation. The system properties are collected + * from the runtime environment like {@link System#getProperties()} and environment variables. + * + * @param systemProperties The system properties, may be {@code null}. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setSystemProperties( Properties systemProperties ); + + /** + * Gets the user properties to use for interpolation and profile activation. The user properties have been + * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command + * line. + * + * @return The user properties, never {@code null}. + */ + Properties getUserProperties(); + + /** + * Sets the user properties to use for interpolation and profile activation. The user properties have been + * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command + * line. + * + * @param userProperties The user properties, may be {@code null}. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setUserProperties( Properties userProperties ); + + /** + * Gets the start time of the build. + * + * @return The start time of the build or {@code null} if unknown. + */ + Date getBuildStartTime(); + + /** + * Sets the start time of the build. + * + * @param buildStartTime The start time of the build, may be {@code null}. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setBuildStartTime( Date buildStartTime ); + + /** + * Gets the model resolver to use for resolution of mixins or parents that are not locally reachable from the + * project directory. + * + * @return The model resolver or {@code null} if not set. + */ + ModelResolver getModelResolver(); + + /** + * Sets the model resolver to use for resolution of mixins or parents that are not locally reachable from the + * project directory. + * + * @param modelResolver The model resolver to use, may be {@code null}. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setModelResolver( ModelResolver modelResolver ); + + /** + * Gets the model building listener to notify during the build process. + * + * @return The model building listener to notify or {@code null} if none. + */ + ModelBuildingListener getModelBuildingListener(); + + /** + * Sets the model building listener to notify during the build process. + * + * @param modelBuildingListener The model building listener to notify, may be {@code null}. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setModelBuildingListener( ModelBuildingListener modelBuildingListener ); + + /** + * Gets the model cache to use for reuse of previously built models. + * + * @return The model cache or {@code null} if not set. + */ + ModelCache getModelCache(); + + /** + * Sets the model cache to use for reuse of previously built models. This is an optional component that serves + * performance optimizations. + * + * @param modelCache The model cache to use, may be {@code null}. + * @return This request, never {@code null}. + */ + ModelBuildingRequest setModelCache( ModelCache modelCache ); + + WorkspaceModelResolver getWorkspaceModelResolver(); + + ModelBuildingRequest setWorkspaceModelResolver( WorkspaceModelResolver workspaceResolver ); + +} \ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingResult.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingResult.java new file mode 100644 index 00000000..44b12958 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingResult.java @@ -0,0 +1,99 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; + +import org.apache.maven.model.Model; +import org.apache.maven.model.Profile; + +/** + * Collects the output of the model builder. + * + * @author Benjamin Bentmann + */ +public interface ModelBuildingResult +{ + + /** + * Gets the sequence of model identifiers that denote the lineage of models from which the effective model was + * constructed. Model identifiers have the form {@code ::}. The first identifier from + * the list denotes the model on which the model builder was originally invoked. The last identifier will always be + * an empty string that by definition denotes the super POM. + * + * @return The model identifiers from the lineage of models, never {@code null}. + */ + List getModelIds(); + + /** + * Gets the assembled model. + * + * @return The assembled model, never {@code null}. + */ + Model getEffectiveModel(); + + /** + * Gets the raw model as it was read from the input model source. Apart from basic validation, the raw model has not + * undergone any updates by the model builder, e.g. reflects neither inheritance nor interpolation. + * + * @return The raw model, never {@code null}. + */ + Model getRawModel(); + + /** + * Gets the specified raw model as it was read from a model source. Apart from basic validation, a raw model has not + * undergone any updates by the model builder, e.g. reflects neither inheritance nor interpolation. The model + * identifier should be from the collection obtained by {@link #getModelIds()}. As a special case, an empty string + * can be used as the identifier for the super POM. + * + * @param modelId The identifier of the desired raw model, must not be {@code null}. + * @return The raw model or {@code null} if the specified model id does not refer to a known model. + */ + Model getRawModel( String modelId ); + + /** + * Gets the profiles from the specified model that were active during model building. The model identifier should be + * from the collection obtained by {@link #getModelIds()}. As a special case, an empty string can be used as the + * identifier for the super POM. + * + * @param modelId The identifier of the model whose active profiles should be retrieved, must not be {@code null}. + * @return The active profiles of the model or an empty list if none or {@code null} if the specified model id does + * not refer to a known model. + */ + List getActivePomProfiles( String modelId ); + + /** + * Gets the external profiles that were active during model building. External profiles are those that were + * contributed by {@link ModelBuildingRequest#getProfiles()}. + * + * @return The active external profiles or an empty list if none, never {@code null}. + */ + List getActiveExternalProfiles(); + + /** + * Gets the problems that were encountered during the model building. Note that only problems of severity + * {@link ModelProblem.Severity#WARNING} and below are reported here. Problems with a higher severity level cause + * the model builder to fail with a {@link ModelBuildingException}. + * + * @return The problems that were encountered during the model building, can be empty but never {@code null}. + */ + List getProblems(); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelCache.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelCache.java new file mode 100644 index 00000000..132a5113 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelCache.java @@ -0,0 +1,56 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Caches auxiliary data used during model building like already processed raw/effective models. The data in the cache + * is meant for exclusive consumption by the model builder and is opaque to the cache implementation. The cache key is + * formed by a combination of group id, artifact id, version and tag. The first three components generally refer to the + * identify of a model. The tag allows for further classification of the associated data on the sole discretion of the + * model builder. + * + * @author Benjamin Bentmann + */ +public interface ModelCache +{ + + /** + * Puts the specified data into the cache. + * + * @param groupId The group id of the cache record, must not be {@code null}. + * @param artifactId The artifact id of the cache record, must not be {@code null}. + * @param version The version of the cache record, must not be {@code null}. + * @param tag The tag of the cache record, must not be {@code null}. + * @param data The data to store in the cache, must not be {@code null}. + */ + void put( String groupId, String artifactId, String version, String tag, Object data ); + + /** + * Gets the specified data from the cache. + * + * @param groupId The group id of the cache record, must not be {@code null}. + * @param artifactId The artifact id of the cache record, must not be {@code null}. + * @param version The version of the cache record, must not be {@code null}. + * @param tag The tag of the cache record, must not be {@code null}. + * @return The requested data or {@code null} if none was present in the cache. + */ + Object get( String groupId, String artifactId, String version, String tag ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelCacheTag.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelCacheTag.java new file mode 100644 index 00000000..8452f967 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelCacheTag.java @@ -0,0 +1,132 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.Model; + +/** + * Describes a tag used by the model builder to access a {@link ModelCache}. This interface basically aggregates a name + * and a class to provide some type safety when working with the otherwise untyped cache. + * + * @author Benjamin Bentmann + * @param The type of data associated with the tag. + */ +interface ModelCacheTag +{ + + /** + * Gets the name of the tag. + * + * @return The name of the tag, must not be {@code null}. + */ + String getName(); + + /** + * Gets the type of data associated with this tag. + * + * @return The type of data, must not be {@code null}. + */ + Class getType(); + + /** + * Creates a copy of the data suitable for storage in the cache. The original data to store can be mutated after the + * cache is populated but the state of the cache must not change so we need to make a copy. + * + * @param data The data to store in the cache, must not be {@code null}. + * @return The data being stored in the cache, never {@code null}. + */ + T intoCache( T data ); + + /** + * Creates a copy of the data suitable for retrieval from the cache. The retrieved data can be mutated after the + * cache is queried but the state of the cache must not change so we need to make a copy. + * + * @param data The data to retrieve from the cache, must not be {@code null}. + * @return The data being retrieved from the cache, never {@code null}. + */ + T fromCache( T data ); + + /** + * The tag used to denote raw model data. + */ + ModelCacheTag RAW = new ModelCacheTag() + { + + @Override + public String getName() + { + return "raw"; + } + + @Override + public Class getType() + { + return ModelData.class; + } + + @Override + public ModelData intoCache( ModelData data ) + { + Model model = ( data.getModel() != null ) ? data.getModel().clone() : null; + return new ModelData( data.getSource(), model, data.getGroupId(), data.getArtifactId(), data.getVersion() ); + } + + @Override + public ModelData fromCache( ModelData data ) + { + return intoCache( data ); + } + + }; + + /** + * The tag used to denote an effective dependency management section from an imported model. + */ + ModelCacheTag IMPORT = new ModelCacheTag() + { + + @Override + public String getName() + { + return "import"; + } + + @Override + public Class getType() + { + return DependencyManagement.class; + } + + @Override + public DependencyManagement intoCache( DependencyManagement data ) + { + return ( data != null ) ? data.clone() : null; + } + + @Override + public DependencyManagement fromCache( DependencyManagement data ) + { + return intoCache( data ); + } + + }; + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelData.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelData.java new file mode 100644 index 00000000..4fefe0df --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelData.java @@ -0,0 +1,222 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; + +import org.apache.maven.model.Model; +import org.apache.maven.model.Profile; + +/** + * Holds a model along with some auxiliary information. This internal utility class assists the model builder during POM + * processing by providing a means to transport information that cannot be (easily) extracted from the model itself. + * + * @author Benjamin Bentmann + */ +class ModelData +{ + private final ModelSource source; + + private Model model; + + private Model rawModel; + + private List activeProfiles; + + private String groupId; + + private String artifactId; + + private String version; + + /** + * Creates a new container for the specified model. + * + * @param model The model to wrap, may be {@code null}. + */ + public ModelData( ModelSource source, Model model ) + { + this.source = source; + this.model = model; + } + + /** + * Creates a new container for the specified model. + * + * @param model The model to wrap, may be {@code null}. + * @param groupId The effective group identifier of the model, may be {@code null}. + * @param artifactId The effective artifact identifier of the model, may be {@code null}. + * @param version The effective version of the model, may be {@code null}. + */ + public ModelData( ModelSource source, Model model, String groupId, String artifactId, String version ) + { + this.source = source; + this.model = model; + setGroupId( groupId ); + setArtifactId( artifactId ); + setVersion( version ); + } + + public ModelSource getSource() + { + return source; + } + + /** + * Gets the model being wrapped. + * + * @return The model or {@code null} if not set. + */ + public Model getModel() + { + return model; + } + + /** + * Sets the model being wrapped. + * + * @param model The model, may be {@code null}. + */ + public void setModel( Model model ) + { + this.model = model; + } + + /** + * Gets the raw model being wrapped. + * + * @return The raw model or {@code null} if not set. + */ + public Model getRawModel() + { + return rawModel; + } + + /** + * Sets the raw model being wrapped. + * + * @param rawModel The raw model, may be {@code null}. + */ + public void setRawModel( Model rawModel ) + { + this.rawModel = rawModel; + } + + /** + * Gets the active profiles from the model. + * + * @return The active profiles or {@code null} if not set. + */ + public List getActiveProfiles() + { + return activeProfiles; + } + + /** + * Sets the active profiles from the model. + * + * @param activeProfiles The active profiles, may be {@code null}. + */ + public void setActiveProfiles( List activeProfiles ) + { + this.activeProfiles = activeProfiles; + } + + /** + * Gets the effective group identifier of the model. + * + * @return The effective group identifier of the model or an empty string if unknown, never {@code null}. + */ + public String getGroupId() + { + return ( groupId != null ) ? groupId : ""; + } + + /** + * Sets the effective group identifier of the model. + * + * @param groupId The effective group identifier of the model, may be {@code null}. + */ + public void setGroupId( String groupId ) + { + this.groupId = groupId; + } + + /** + * Gets the effective artifact identifier of the model. + * + * @return The effective artifact identifier of the model or an empty string if unknown, never {@code null}. + */ + public String getArtifactId() + { + return ( artifactId != null ) ? artifactId : ""; + } + + /** + * Sets the effective artifact identifier of the model. + * + * @param artifactId The effective artifact identifier of the model, may be {@code null}. + */ + public void setArtifactId( String artifactId ) + { + this.artifactId = artifactId; + } + + /** + * Gets the effective version of the model. + * + * @return The effective version of the model or an empty string if unknown, never {@code null}. + */ + public String getVersion() + { + return ( version != null ) ? version : ""; + } + + /** + * Sets the effective version of the model. + * + * @param version The effective version of the model, may be {@code null}. + */ + public void setVersion( String version ) + { + this.version = version; + } + + /** + * Gets the effective identifier of the model in the form {@code ::}. + * + * @return The effective identifier of the model, never {@code null}. + */ + public String getId() + { + StringBuilder buffer = new StringBuilder( 96 ); + + buffer.append( getGroupId() ).append( ':' ).append( getArtifactId() ).append( ':' ).append( getVersion() ); + + return buffer.toString(); + } + + @Override + public String toString() + { + return String.valueOf( model ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblem.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblem.java new file mode 100644 index 00000000..43272bac --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblem.java @@ -0,0 +1,117 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Describes a problem that was encountered during model building. A problem can either be an exception that was thrown + * or a simple string message. In addition, a problem carries a hint about its source, e.g. the POM file that exhibits + * the problem. + * + * @author Benjamin Bentmann + */ +public interface ModelProblem +{ + + /** + * The different severity levels for a problem, in decreasing order. + */ + enum Severity + { + + FATAL, // + ERROR, // + WARNING // + + } + + enum Version + { + //based on ModeBuildingResult.validationLevel + BASE, + V20, + V30, + V31 + } + + /** + * Gets the hint about the source of the problem. While the syntax of this hint is unspecified and depends on the + * creator of the problem, the general expectation is that the hint provides sufficient information to the user to + * track the problem back to its origin. A concrete example for such a source hint can be the file path or URL from + * which a POM was read. + * + * @return The hint about the source of the problem or an empty string if unknown, never {@code null}. + */ + String getSource(); + + /** + * Gets the one-based index of the line containing the problem. The line number should refer to some text file that + * is given by {@link #getSource()}. + * + * @return The one-based index of the line containing the problem or a non-positive value if unknown. + */ + int getLineNumber(); + + /** + * Gets the one-based index of the column containing the problem. The column number should refer to some text file + * that is given by {@link #getSource()}. + * + * @return The one-based index of the column containing the problem or non-positive value if unknown. + */ + int getColumnNumber(); + + /** + * Gets the identifier of the model from which the problem originated. While the general form of this identifier is + * groupId:artifactId:version the returned identifier need not be complete. The identifier is derived + * from the information that is available at the point the problem occurs and as such merely serves as a best effort + * to provide information to the user to track the problem back to its origin. + * + * @return The identifier of the model from which the problem originated or an empty string if unknown, never + * {@code null}. + */ + String getModelId(); + + /** + * Gets the exception that caused this problem (if any). + * + * @return The exception that caused this problem or {@code null} if not applicable. + */ + Exception getException(); + + /** + * Gets the message that describes this problem. + * + * @return The message describing this problem, never {@code null}. + */ + String getMessage(); + + /** + * Gets the severity level of this problem. + * + * @return The severity level of this problem, never {@code null}. + */ + Severity getSeverity(); + + /** + * Gets the applicable maven version/validation level of this problem + * @return The version, never {@code null}. + */ + Version getVersion(); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollector.java new file mode 100644 index 00000000..e9561e54 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollector.java @@ -0,0 +1,41 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Collects problems that are encountered during model building. The primary purpose of this component is to account for + * the fact that the problem reporter has/should not have information about the calling context and hence cannot provide + * an expressive source hint for the model problem. Instead, the source hint is configured by the model builder before + * it delegates to other components that potentially encounter problems. Then, the problem reporter can focus on + * providing a simple error message, leaving the donkey work of creating a nice model problem to this component. + * + * @author Benjamin Bentmann + */ +public interface ModelProblemCollector +{ + + /** + * Adds the specified problem. + * + * @param req must not be null + */ + void add( ModelProblemCollectorRequest req ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorExt.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorExt.java new file mode 100644 index 00000000..7977d3a6 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorExt.java @@ -0,0 +1,37 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; + +/** + * Extends the ModelproblemCollector by the capacity of returning the collected problems. + * @author Milos Kleint + */ +public interface ModelProblemCollectorExt extends ModelProblemCollector +{ + + /** + * The collected problems. + * @return a list of model problems encountered, never {@code null} + */ + List getProblems(); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorRequest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorRequest.java new file mode 100644 index 00000000..d213cc48 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorRequest.java @@ -0,0 +1,101 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.InputLocation; +import org.apache.maven.model.building.ModelProblem.Severity; +import org.apache.maven.model.building.ModelProblem.Version; + +/** + * Class to wrap request parameters to ModelProblemCollector.addProblem + * + * @author mkleint + */ +public final class ModelProblemCollectorRequest +{ + + private final ModelProblem.Severity severity; + private final ModelProblem.Version version; + private Exception exception; + private String message; + private InputLocation location; + + /** + * Create a new request with mandatory parameters. + * @param severity + * @param version + */ + public ModelProblemCollectorRequest( Severity severity, Version version ) + { + this.severity = severity; + this.version = version; + if ( severity == null ) + { + throw new IllegalStateException( "No severity declared" ); + } + if ( version == null ) + { + throw new IllegalStateException( "No version declared." ); + } + } + + public Severity getSeverity() + { + return severity; + } + + public Version getVersion() + { + return version; + } + + public Exception getException() + { + return exception; + } + + public ModelProblemCollectorRequest setException( Exception exception ) + { + this.exception = exception; + return this; + } + + public String getMessage() + { + return message; + } + + public ModelProblemCollectorRequest setMessage( String message ) + { + this.message = message; + return this; + } + + public InputLocation getLocation() + { + return location; + } + + public ModelProblemCollectorRequest setLocation( InputLocation location ) + { + this.location = location; + return this; + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemUtils.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemUtils.java new file mode 100644 index 00000000..806c28d4 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemUtils.java @@ -0,0 +1,171 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +import org.apache.maven.model.Model; + +/** + * Assists in the handling of model problems. + * + * @author Benjamin Bentmann + */ +public class ModelProblemUtils +{ + + /** + * Creates a user-friendly source hint for the specified model. + * + * @param model The model to create a source hint for, may be {@code null}. + * @return The user-friendly source hint, never {@code null}. + */ + static String toSourceHint( Model model ) + { + if ( model == null ) + { + return ""; + } + + StringBuilder buffer = new StringBuilder( 192 ); + + buffer.append( toId( model ) ); + + File pomFile = model.getPomFile(); + if ( pomFile != null ) + { + buffer.append( " (" ).append( pomFile ).append( ")" ); + } + + return buffer.toString(); + } + + static String toPath( Model model ) + { + String path = ""; + + if ( model != null ) + { + File pomFile = model.getPomFile(); + + if ( pomFile != null ) + { + path = pomFile.getAbsolutePath(); + } + } + + return path; + } + + static String toId( Model model ) + { + if ( model == null ) + { + return ""; + } + + String groupId = model.getGroupId(); + if ( groupId == null && model.getParent() != null ) + { + groupId = model.getParent().getGroupId(); + } + + String artifactId = model.getArtifactId(); + + String version = model.getVersion(); + if ( version == null ) + { + version = "[unknown-version]"; + } + + return toId( groupId, artifactId, version ); + } + + /** + * Creates a user-friendly artifact id from the specified coordinates. + * + * @param groupId The group id, may be {@code null}. + * @param artifactId The artifact id, may be {@code null}. + * @param version The version, may be {@code null}. + * @return The user-friendly artifact id, never {@code null}. + */ + static String toId( String groupId, String artifactId, String version ) + { + StringBuilder buffer = new StringBuilder( 96 ); + + buffer.append( ( groupId != null && groupId.length() > 0 ) ? groupId : "[unknown-group-id]" ); + buffer.append( ':' ); + buffer.append( ( artifactId != null && artifactId.length() > 0 ) ? artifactId : "[unknown-artifact-id]" ); + buffer.append( ':' ); + buffer.append( ( version != null && version.length() > 0 ) ? version : "[unknown-version]" ); + + return buffer.toString(); + } + + /** + * Creates a string with all location details for the specified model problem. If the project identifier is + * provided, the generated location will omit the model id and source information and only give line/column + * information for problems originating directly from this POM. + * + * @param problem The problem whose location should be formatted, must not be {@code null}. + * @param projectId The {@code ::} of the corresponding project, may be {@code null} + * to force output of model id and source. + * @return The formatted problem location or an empty string if unknown, never {@code null}. + */ + public static String formatLocation( ModelProblem problem, String projectId ) + { + StringBuilder buffer = new StringBuilder( 256 ); + + if ( !problem.getModelId().equals( projectId ) ) + { + buffer.append( problem.getModelId() ); + + if ( problem.getSource().length() > 0 ) + { + if ( buffer.length() > 0 ) + { + buffer.append( ", " ); + } + buffer.append( problem.getSource() ); + } + } + + if ( problem.getLineNumber() > 0 ) + { + if ( buffer.length() > 0 ) + { + buffer.append( ", " ); + } + buffer.append( "line " ).append( problem.getLineNumber() ); + } + + if ( problem.getColumnNumber() > 0 ) + { + if ( buffer.length() > 0 ) + { + buffer.append( ", " ); + } + buffer.append( "column " ).append( problem.getColumnNumber() ); + } + + return buffer.toString(); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProcessor.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProcessor.java new file mode 100644 index 00000000..ca34845c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProcessor.java @@ -0,0 +1,32 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.io.ModelReader; +import org.apache.maven.model.locator.ModelLocator; + +@SuppressWarnings( "checkstyle:interfaceistype" ) +public interface ModelProcessor + extends ModelLocator, ModelReader +{ + + String SOURCE = "org.apache.maven.model.building.source"; + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelSource.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelSource.java new file mode 100644 index 00000000..5db8edba --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelSource.java @@ -0,0 +1,38 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.building.Source; + +/** + * Provides access to the contents of a POM independently of the backing store (e.g. file system, database, memory). + *

+ * This interface does not support loading of parent POM(s) from the same backing store, integrators are strongly + * encouraged to implement {@link ModelSource2} instead of implementing this interface directly. + * + * @author Benjamin Bentmann + * @see ModelSource2 + * @deprecated instead use {@link Source} + */ +@Deprecated +public interface ModelSource extends Source +{ + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelSource2.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelSource2.java new file mode 100644 index 00000000..3e123d08 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelSource2.java @@ -0,0 +1,56 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.net.URI; + +/** + * Provides access to the contents of a POM independently of the backing store (e.g. file system, database, memory). + *

+ * Unlike {@link ModelSource}, this interface supports loading of parent POM(s) from the same backing store and allows + * construction of MavenProject instances without the need to have parent POM(s) available from local or remote + * repositories. + *

+ * ModelSource2 instances are cached in {@link ModelBuildingRequest#getModelCache()}. Implementations must guarantee + * that the connection to the backing store remains active until request's {@link ModelCache} is discarded or flushed. + */ +public interface ModelSource2 + extends ModelSource +{ + /** + * Returns model source identified by a path relative to this model source POM. Implementation MUST + * be able to accept relPath parameter values that + *

    + *
  • use either / or \ file path separator
  • + *
  • have .. parent directory references
  • + *
  • point either at file or directory, in the latter case POM file name 'pom.xml' needs to be used by the + * requested model source.
  • + *
+ * + * @param relPath is the path of the requested model source relative to this model source POM. + * @return related model source or null if no such model source. + */ + ModelSource2 getRelatedSource( String relPath ); + + /** + * Returns location of the POM, never null. + */ + URI getLocationURI(); +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java new file mode 100644 index 00000000..a9628977 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java @@ -0,0 +1,255 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import static com.google.common.base.Predicates.in; +import static com.google.common.collect.Iterables.any; +import static com.google.common.collect.Iterables.concat; +import static com.google.common.collect.Iterables.transform; +import static java.util.Collections.singleton; +import static java.util.EnumSet.of; +import static org.apache.maven.model.building.ModelProblem.Severity.ERROR; +import static org.apache.maven.model.building.ModelProblem.Severity.FATAL; + +import java.util.Arrays; +import java.util.Collections; + +import org.apache.maven.model.building.ModelProblem.Severity; + +import com.google.common.base.Function; +import com.google.common.base.Predicates; +import com.google.common.collect.Iterables; + +/** + * There are various forms of results that are represented by this class: + *
    + *
  1. success - in which case only the model field is set + *
  2. success with warnings - model field + non-error model problems + *
  3. error - no model, but diagnostics + *
  4. error - (partial) model and diagnostics + *
+ * Could encode these variants as subclasses, but kept in one for now + * + * @author bbusjaeger + * @param + */ +public class Result +{ + + /** + * Success without warnings + * + * @param model + * @return + */ + public static Result success( T model ) + { + return success( model, Collections.emptyList() ); + } + + /** + * Success with warnings + * + * @param model + * @param problems + * @return + */ + public static Result success( T model, Iterable problems ) + { + assert !hasErrors( problems ); + return new Result( false, model, problems ); + } + + /** + * Success with warnings + * + * @param model + * @param results + * @return + */ + public static Result success( T model, Result... results ) + { + return success( model, Iterables.concat( Iterables.transform( Arrays.asList( results ), GET_PROBLEMS ) ) ); + } + + /** + * Error with problems describing the cause + * + * @param problems + * @return + */ + public static Result error( Iterable problems ) + { + return error( null, problems ); + } + + public static Result error( T model ) + { + return error( model, Collections.emptyList() ); + } + + public static Result error( Result result ) + { + return error( result.getProblems() ); + } + + public static Result error( Result... results ) + { + return error( Iterables.concat( Iterables.transform( Arrays.asList( results ), GET_PROBLEMS ) ) ); + } + + /** + * Error with partial result and problems describing the cause + * + * @param model + * @param problems + * @return + */ + public static Result error( T model, Iterable problems ) + { + return new Result( true, model, problems ); + } + + /** + * New result - determine whether error or success by checking problems for errors + * + * @param model + * @param problems + * @return + */ + public static Result newResult( T model, Iterable problems ) + { + return new Result( hasErrors( problems ), model, problems ); + } + + /** + * New result consisting of given result and new problem. Convenience for newResult(result.get(), + * concat(result.getProblems(),problems)). + * + * @param result + * @param problem + * @return + */ + public static Result addProblem( Result result, ModelProblem problem ) + { + return addProblems( result, singleton( problem ) ); + } + + /** + * New result that includes the given + * + * @param result + * @param problems + * @return + */ + public static Result addProblems( Result result, Iterable problems ) + { + return new Result( result.hasErrors() || hasErrors( problems ), result.get(), concat( result.getProblems(), + problems ) ); + } + + public static Result addProblems( Result result, Result... results ) + { + return addProblems( result, Iterables.concat( Iterables.transform( Arrays.asList( results ), GET_PROBLEMS ) ) ); + } + + /** + * Turns the given results into a single result by combining problems and models into single collection. + * + * @param results + * @return + */ + public static Result> newResultSet( Iterable> results ) + { + final boolean hasErrors = any( transform( results, new Function, Boolean>() + { + @Override + public Boolean apply( Result input ) + { + return input.hasErrors(); + } + } ), Predicates.equalTo( true ) ); + final Iterable models = transform( results, new Function, T>() + { + @Override + public T apply( Result input ) + { + return input.get(); + } + } ); + final Iterable problems = concat( transform( results, GET_PROBLEMS ) ); + return new Result>( hasErrors, models, problems ); + } + + // helper to determine if problems contain error + private static boolean hasErrors( Iterable problems ) + { + return any( transform( problems, new Function() + { + @Override + public Severity apply( ModelProblem input ) + { + return input.getSeverity(); + } + } ), in( of( ERROR, FATAL ) ) ); + } + + /** + * Class definition + */ + + private final boolean errors; + + private final T value; + + private final Iterable problems; + + private Result( boolean errors, T model, Iterable problems ) + { + this.errors = errors; + this.value = model; + this.problems = problems; + } + + public Iterable getProblems() + { + return problems; + } + + public T get() + { + return value; + } + + public boolean hasErrors() + { + return errors; + } + + private static final Function, Iterable> GET_PROBLEMS = + new Function, Iterable>() + { + @Override + public Iterable apply( Result input ) + { + return input.getProblems(); + } + }; +} \ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/StringModelSource.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/StringModelSource.java new file mode 100644 index 00000000..cf9c4ce1 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/StringModelSource.java @@ -0,0 +1,56 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.building.StringSource; + +/** + * Wraps an ordinary {@link CharSequence} as a model source. + * + * @author Benjamin Bentmann + * + * @deprecated instead use {@link StringSource} + */ +@Deprecated +public class StringModelSource extends StringSource + implements ModelSource +{ + + /** + * Creates a new model source backed by the specified string. + * + * @param pom The POM's string representation, may be empty or {@code null}. + */ + public StringModelSource( CharSequence pom ) + { + this( pom, null ); + } + + /** + * Creates a new model source backed by the specified string. + * + * @param pom The POM's string representation, may be empty or {@code null}. + * @param location The location to report for this use, may be {@code null}. + */ + public StringModelSource( CharSequence pom, String location ) + { + super( pom, location ); + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/UrlModelSource.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/UrlModelSource.java new file mode 100644 index 00000000..e41d74b3 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/building/UrlModelSource.java @@ -0,0 +1,46 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.net.URL; + +import org.apache.maven.building.UrlSource; + +/** + * Wraps an ordinary {@link URL} as a model source. + * + * @author Benjamin Bentmann + * + * @deprecated instead use {@link UrlSource} + */ +@Deprecated +public class UrlModelSource extends UrlSource + implements ModelSource +{ + /** + * Creates a new model source backed by the specified URL. + * + * @param pomUrl The POM file, must not be {@code null}. + */ + public UrlModelSource( URL pomUrl ) + { + super( pomUrl ); + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java new file mode 100644 index 00000000..5860af65 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java @@ -0,0 +1,83 @@ +package org.apache.maven.model.composition; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.codehaus.plexus.component.annotations.Component; + +/** + * Handles the import of dependency management from other models into the target model. + * + * @author Benjamin Bentmann + */ +@Component( role = DependencyManagementImporter.class ) +public class DefaultDependencyManagementImporter + implements DependencyManagementImporter +{ + + @Override + public void importManagement( Model target, List sources, + ModelBuildingRequest request, ModelProblemCollector problems ) + { + if ( sources != null && !sources.isEmpty() ) + { + Map dependencies = new LinkedHashMap(); + + DependencyManagement depMngt = target.getDependencyManagement(); + + if ( depMngt != null ) + { + for ( Dependency dependency : depMngt.getDependencies() ) + { + dependencies.put( dependency.getManagementKey(), dependency ); + } + } + else + { + depMngt = new DependencyManagement(); + target.setDependencyManagement( depMngt ); + } + + for ( DependencyManagement source : sources ) + { + for ( Dependency dependency : source.getDependencies() ) + { + String key = dependency.getManagementKey(); + if ( !dependencies.containsKey( key ) ) + { + dependencies.put( key, dependency ); + } + } + } + + depMngt.setDependencies( new ArrayList( dependencies.values() ) ); + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/composition/DependencyManagementImporter.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/composition/DependencyManagementImporter.java new file mode 100644 index 00000000..06496429 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/composition/DependencyManagementImporter.java @@ -0,0 +1,48 @@ +package org.apache.maven.model.composition; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; + +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles the import of dependency management from other models into the target model. + * + * @author Benjamin Bentmann + */ +public interface DependencyManagementImporter +{ + + /** + * Imports the specified dependency management sections into the given target model. + * + * @param target The model into which to import the dependency management section, must not be null. + * @param sources The dependency management sections to import, may be null. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void importManagement( Model target, List sources, ModelBuildingRequest request, + ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java new file mode 100644 index 00000000..609f441e --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java @@ -0,0 +1,255 @@ +package org.apache.maven.model.inheritance; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.maven.model.Model; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginContainer; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.Reporting; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.merge.MavenModelMerger; +import org.codehaus.plexus.component.annotations.Component; + +/** + * Handles inheritance of model values. + * + * @author Benjamin Bentmann + */ +@Component( role = InheritanceAssembler.class ) +public class DefaultInheritanceAssembler + implements InheritanceAssembler +{ + + private InheritanceModelMerger merger = new InheritanceModelMerger(); + + @Override + public void assembleModelInheritance( Model child, Model parent, ModelBuildingRequest request, + ModelProblemCollector problems ) + { + Map hints = new HashMap(); + hints.put( MavenModelMerger.CHILD_PATH_ADJUSTMENT, getChildPathAdjustment( child, parent ) ); + merger.merge( child, parent, false, hints ); + } + + /** + * Calculates the relative path from the base directory of the parent to the parent directory of the base directory + * of the child. The general idea is to adjust inherited URLs to match the project layout (in SCM). + * + *

This calculation is only a heuristic based on our conventions. + * In detail, the algo relies on the following assumptions:

    + *
  • The parent uses aggregation and refers to the child via the modules section
  • + *
  • The module path to the child is considered to + * point at the POM rather than its base directory if the path ends with ".xml" (ignoring case)
  • + *
  • The name of the child's base directory matches the artifact id of the child.
  • + *
+ * Note that for the sake of independence from the user + * environment, the filesystem is intentionally not used for the calculation.

+ * + * @param child The child model, must not be null. + * @param parent The parent model, may be null. + * @return The path adjustment, can be empty but never null. + */ + private String getChildPathAdjustment( Model child, Model parent ) + { + String adjustment = ""; + + if ( parent != null ) + { + String childName = child.getArtifactId(); + + /* + * This logic exists only for the sake of backward-compat with 2.x (MNG-5000). In generally, it is wrong to + * base URL inheritance on the project directory names as this information is unavailable for POMs in the + * repository. In other words, projects where artifactId != projectDirName will see different effective URLs + * depending on how the POM was constructed. + */ + File childDirectory = child.getProjectDirectory(); + if ( childDirectory != null ) + { + childName = childDirectory.getName(); + } + + for ( String module : parent.getModules() ) + { + module = module.replace( '\\', '/' ); + + if ( module.regionMatches( true, module.length() - 4, ".xml", 0, 4 ) ) + { + module = module.substring( 0, module.lastIndexOf( '/' ) + 1 ); + } + + String moduleName = module; + if ( moduleName.endsWith( "/" ) ) + { + moduleName = moduleName.substring( 0, moduleName.length() - 1 ); + } + + int lastSlash = moduleName.lastIndexOf( '/' ); + + moduleName = moduleName.substring( lastSlash + 1 ); + + if ( moduleName.equals( childName ) && lastSlash >= 0 ) + { + adjustment = module.substring( 0, lastSlash ); + break; + } + } + } + + return adjustment; + } + + protected static class InheritanceModelMerger + extends MavenModelMerger + { + + @Override + protected void mergePluginContainer_Plugins( PluginContainer target, PluginContainer source, + boolean sourceDominant, Map context ) + { + List src = source.getPlugins(); + if ( !src.isEmpty() ) + { + List tgt = target.getPlugins(); + Map master = new LinkedHashMap( src.size() * 2 ); + + for ( Plugin element : src ) + { + if ( element.isInherited() || !element.getExecutions().isEmpty() ) + { + // NOTE: Enforce recursive merge to trigger merging/inheritance logic for executions + Plugin plugin = new Plugin(); + plugin.setLocation( "", element.getLocation( "" ) ); + plugin.setGroupId( null ); + mergePlugin( plugin, element, sourceDominant, context ); + + Object key = getPluginKey( element ); + + master.put( key, plugin ); + } + } + + Map> predecessors = new LinkedHashMap>(); + List pending = new ArrayList(); + for ( Plugin element : tgt ) + { + Object key = getPluginKey( element ); + Plugin existing = master.get( key ); + if ( existing != null ) + { + mergePlugin( element, existing, sourceDominant, context ); + + master.put( key, element ); + + if ( !pending.isEmpty() ) + { + predecessors.put( key, pending ); + pending = new ArrayList(); + } + } + else + { + pending.add( element ); + } + } + + List result = new ArrayList( src.size() + tgt.size() ); + for ( Map.Entry entry : master.entrySet() ) + { + List pre = predecessors.get( entry.getKey() ); + if ( pre != null ) + { + result.addAll( pre ); + } + result.add( entry.getValue() ); + } + result.addAll( pending ); + + target.setPlugins( result ); + } + } + + @Override + protected void mergePlugin( Plugin target, Plugin source, boolean sourceDominant, Map context ) + { + if ( source.isInherited() ) + { + mergeConfigurationContainer( target, source, sourceDominant, context ); + } + mergePlugin_GroupId( target, source, sourceDominant, context ); + mergePlugin_ArtifactId( target, source, sourceDominant, context ); + mergePlugin_Version( target, source, sourceDominant, context ); + mergePlugin_Extensions( target, source, sourceDominant, context ); + mergePlugin_Dependencies( target, source, sourceDominant, context ); + mergePlugin_Executions( target, source, sourceDominant, context ); + } + + @Override + protected void mergeReporting_Plugins( Reporting target, Reporting source, boolean sourceDominant, + Map context ) + { + List src = source.getPlugins(); + if ( !src.isEmpty() ) + { + List tgt = target.getPlugins(); + Map merged = + new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); + + for ( ReportPlugin element : src ) + { + Object key = getReportPluginKey( element ); + if ( element.isInherited() ) + { + // NOTE: Enforce recursive merge to trigger merging/inheritance logic for executions as well + ReportPlugin plugin = new ReportPlugin(); + plugin.setLocation( "", element.getLocation( "" ) ); + plugin.setGroupId( null ); + mergeReportPlugin( plugin, element, sourceDominant, context ); + + merged.put( key, plugin ); + } + } + + for ( ReportPlugin element : tgt ) + { + Object key = getReportPluginKey( element ); + ReportPlugin existing = merged.get( key ); + if ( existing != null ) + { + mergeReportPlugin( element, existing, sourceDominant, context ); + } + merged.put( key, element ); + } + + target.setPlugins( new ArrayList( merged.values() ) ); + } + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/InheritanceAssembler.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/InheritanceAssembler.java new file mode 100644 index 00000000..a191e52d --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/InheritanceAssembler.java @@ -0,0 +1,48 @@ +package org.apache.maven.model.inheritance; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles inheritance of model values. + * + * @author Benjamin Bentmann + */ +public interface InheritanceAssembler +{ + + /** + * Merges values from the specified parent model into the given child model. Implementations are expected to keep + * parent and child completely decoupled by injecting deep copies of objects into the child rather than the original + * objects from the parent. + * + * @param child The child model into which to merge the values inherited from the parent, must not be + * null. + * @param parent The (read-only) parent model from which to inherit the values, may be null. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void assembleModelInheritance( Model child, Model parent, ModelBuildingRequest request, + ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java new file mode 100644 index 00000000..1390a4ed --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java @@ -0,0 +1,271 @@ +package org.apache.maven.model.interpolation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblem.Severity; +import org.apache.maven.model.building.ModelProblem.Version; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.building.ModelProblemCollectorRequest; +import org.apache.maven.model.path.PathTranslator; +import org.apache.maven.model.path.UrlNormalizer; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.interpolation.AbstractValueSource; +import org.codehaus.plexus.interpolation.InterpolationException; +import org.codehaus.plexus.interpolation.InterpolationPostProcessor; +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.MapBasedValueSource; +import org.codehaus.plexus.interpolation.ObjectBasedValueSource; +import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor; +import org.codehaus.plexus.interpolation.PrefixedObjectValueSource; +import org.codehaus.plexus.interpolation.PrefixedValueSourceWrapper; +import org.codehaus.plexus.interpolation.RecursionInterceptor; +import org.codehaus.plexus.interpolation.ValueSource; + +/** + * Use a regular expression search to find and resolve expressions within the POM. + * + * @author jdcasey Created on Feb 3, 2005 + */ +public abstract class AbstractStringBasedModelInterpolator + implements ModelInterpolator +{ + private static final List PROJECT_PREFIXES = Arrays.asList( "pom.", "project." ); + + private static final Collection TRANSLATED_PATH_EXPRESSIONS; + + static + { + Collection translatedPrefixes = new HashSet(); + + // MNG-1927, MNG-2124, MNG-3355: + // If the build section is present and the project directory is non-null, we should make + // sure interpolation of the directories below uses translated paths. + // Afterward, we'll double back and translate any paths that weren't covered during interpolation via the + // code below... + translatedPrefixes.add( "build.directory" ); + translatedPrefixes.add( "build.outputDirectory" ); + translatedPrefixes.add( "build.testOutputDirectory" ); + translatedPrefixes.add( "build.sourceDirectory" ); + translatedPrefixes.add( "build.testSourceDirectory" ); + translatedPrefixes.add( "build.scriptSourceDirectory" ); + translatedPrefixes.add( "reporting.outputDirectory" ); + + TRANSLATED_PATH_EXPRESSIONS = translatedPrefixes; + } + + @Requirement + private PathTranslator pathTranslator; + + @Requirement + private UrlNormalizer urlNormalizer; + + private Interpolator interpolator; + + private RecursionInterceptor recursionInterceptor; + + public AbstractStringBasedModelInterpolator() + { + interpolator = createInterpolator(); + recursionInterceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES ); + } + + public AbstractStringBasedModelInterpolator setPathTranslator( PathTranslator pathTranslator ) + { + this.pathTranslator = pathTranslator; + return this; + } + + public AbstractStringBasedModelInterpolator setUrlNormalizer( UrlNormalizer urlNormalizer ) + { + this.urlNormalizer = urlNormalizer; + return this; + } + + protected List createValueSources( final Model model, final File projectDir, + final ModelBuildingRequest config, + final ModelProblemCollector problems ) + { + Properties modelProperties = model.getProperties(); + + ValueSource modelValueSource1 = new PrefixedObjectValueSource( PROJECT_PREFIXES, model, false ); + if ( config.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ) + { + modelValueSource1 = new ProblemDetectingValueSource( modelValueSource1, "pom.", "project.", problems ); + } + + ValueSource modelValueSource2 = new ObjectBasedValueSource( model ); + if ( config.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ) + { + modelValueSource2 = new ProblemDetectingValueSource( modelValueSource2, "", "project.", problems ); + } + + // NOTE: Order counts here! + List valueSources = new ArrayList( 9 ); + + if ( projectDir != null ) + { + ValueSource basedirValueSource = new PrefixedValueSourceWrapper( new AbstractValueSource( false ) + { + @Override + public Object getValue( String expression ) + { + if ( "basedir".equals( expression ) ) + { + return projectDir.getAbsolutePath(); + } + return null; + } + }, PROJECT_PREFIXES, true ); + valueSources.add( basedirValueSource ); + + ValueSource baseUriValueSource = new PrefixedValueSourceWrapper( new AbstractValueSource( false ) + { + @Override + public Object getValue( String expression ) + { + if ( "baseUri".equals( expression ) ) + { + return projectDir.getAbsoluteFile().toURI().toString(); + } + return null; + } + }, PROJECT_PREFIXES, false ); + valueSources.add( baseUriValueSource ); + valueSources.add( new BuildTimestampValueSource( config.getBuildStartTime(), modelProperties ) ); + } + + valueSources.add( modelValueSource1 ); + + valueSources.add( new MapBasedValueSource( config.getUserProperties() ) ); + + valueSources.add( new MapBasedValueSource( modelProperties ) ); + + valueSources.add( new MapBasedValueSource( config.getSystemProperties() ) ); + + valueSources.add( new AbstractValueSource( false ) + { + @Override + public Object getValue( String expression ) + { + return config.getSystemProperties().getProperty( "env." + expression ); + } + } ); + + valueSources.add( modelValueSource2 ); + + return valueSources; + } + + protected List createPostProcessors( final Model model, + final File projectDir, + final ModelBuildingRequest config ) + { + List processors = new ArrayList( 2 ); + if ( projectDir != null ) + { + processors.add( new PathTranslatingPostProcessor( PROJECT_PREFIXES, TRANSLATED_PATH_EXPRESSIONS, + projectDir, pathTranslator ) ); + } + processors.add( new UrlNormalizingPostProcessor( urlNormalizer ) ); + return processors; + } + + protected String interpolateInternal( String src, List valueSources, + List postProcessors, + ModelProblemCollector problems ) + { + if ( !src.contains( "${" ) ) + { + return src; + } + + String result = src; + synchronized ( this ) + { + + for ( ValueSource vs : valueSources ) + { + interpolator.addValueSource( vs ); + } + + for ( InterpolationPostProcessor postProcessor : postProcessors ) + { + interpolator.addPostProcessor( postProcessor ); + } + + try + { + try + { + result = interpolator.interpolate( result, recursionInterceptor ); + } + catch ( InterpolationException e ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( e.getMessage() ).setException( e ) ); + } + + interpolator.clearFeedback(); + } + finally + { + for ( ValueSource vs : valueSources ) + { + interpolator.removeValuesSource( vs ); + } + + for ( InterpolationPostProcessor postProcessor : postProcessors ) + { + interpolator.removePostProcessor( postProcessor ); + } + } + } + + return result; + } + + protected RecursionInterceptor getRecursionInterceptor() + { + return recursionInterceptor; + } + + protected void setRecursionInterceptor( RecursionInterceptor recursionInterceptor ) + { + this.recursionInterceptor = recursionInterceptor; + } + + protected abstract Interpolator createInterpolator(); + + protected final Interpolator getInterpolator() + { + return interpolator; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/BuildTimestampValueSource.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/BuildTimestampValueSource.java new file mode 100644 index 00000000..30809b85 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/BuildTimestampValueSource.java @@ -0,0 +1,47 @@ +package org.apache.maven.model.interpolation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Date; +import java.util.Properties; + +import org.codehaus.plexus.interpolation.AbstractValueSource; + +class BuildTimestampValueSource + extends AbstractValueSource +{ + private final MavenBuildTimestamp mavenBuildTimestamp; + + public BuildTimestampValueSource( Date startTime, Properties properties ) + { + super( false ); + this.mavenBuildTimestamp = new MavenBuildTimestamp( startTime, properties ); + } + + @Override + public Object getValue( String expression ) + { + if ( "build.timestamp".equals( expression ) || "maven.build.timestamp".equals( expression ) ) + { + return mavenBuildTimestamp.formattedTimestamp(); + } + return null; + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/MavenBuildTimestamp.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/MavenBuildTimestamp.java new file mode 100644 index 00000000..447f0efe --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/MavenBuildTimestamp.java @@ -0,0 +1,70 @@ +package org.apache.maven.model.interpolation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Properties; +import java.util.TimeZone; + +public class MavenBuildTimestamp +{ + // ISO 8601-compliant timestamp for machine readability + public static final String DEFAULT_BUILD_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + + public static final String BUILD_TIMESTAMP_FORMAT_PROPERTY = "maven.build.timestamp.format"; + + private String formattedTimestamp; + + public MavenBuildTimestamp() + { + this( new Date() ); + } + + public MavenBuildTimestamp( Date time ) + { + this( time, DEFAULT_BUILD_TIMESTAMP_FORMAT ); + } + + public MavenBuildTimestamp( Date time, Properties properties ) + { + this( time, properties != null ? properties.getProperty( BUILD_TIMESTAMP_FORMAT_PROPERTY ) : null ); + } + + public MavenBuildTimestamp( Date time, String timestampFormat ) + { + if ( timestampFormat == null ) + { + timestampFormat = DEFAULT_BUILD_TIMESTAMP_FORMAT; + } + if ( time == null ) + { + time = new Date(); + } + SimpleDateFormat dateFormat = new SimpleDateFormat( timestampFormat ); + dateFormat.setTimeZone( TimeZone.getTimeZone( "UTC" ) ); + formattedTimestamp = dateFormat.format( time ); + } + + public String formattedTimestamp() + { + return formattedTimestamp; + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolator.java new file mode 100644 index 00000000..d2b01c1d --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolator.java @@ -0,0 +1,54 @@ +package org.apache.maven.model.interpolation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +import java.io.File; + +/** + * Replaces expressions of the form ${token} with their effective values. Effective values are basically + * calculated from the elements of the model itself and the execution properties from the building request. + * + * @author jdcasey + *

+ * Created on Feb 2, 2005 + */ +public interface ModelInterpolator +{ + + /** + * Interpolates expressions in the specified model. Note that implementations are free to either interpolate the + * provided model directly or to create a clone of the model and interpolate the clone. Callers should always use + * the returned model and must not rely on the input model being updated. + * + * @param model The model to interpolate, must not be {@code null}. + * @param projectDir The project directory, may be {@code null} if the model does not belong to a local project but + * to some artifact's metadata. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + * @return The interpolated model, never {@code null}. + */ + Model interpolateModel( Model model, File projectDir, ModelBuildingRequest request, + ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/PathTranslatingPostProcessor.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/PathTranslatingPostProcessor.java new file mode 100644 index 00000000..1aeafddc --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/PathTranslatingPostProcessor.java @@ -0,0 +1,67 @@ +package org.apache.maven.model.interpolation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.path.PathTranslator; +import org.codehaus.plexus.interpolation.InterpolationPostProcessor; +import org.codehaus.plexus.interpolation.util.ValueSourceUtils; + +import java.io.File; +import java.util.Collection; +import java.util.List; + +/** + * + */ +class PathTranslatingPostProcessor + implements InterpolationPostProcessor +{ + + private final Collection unprefixedPathKeys; + private final File projectDir; + private final PathTranslator pathTranslator; + private final List expressionPrefixes; + + public PathTranslatingPostProcessor( List expressionPrefixes, Collection unprefixedPathKeys, + File projectDir, PathTranslator pathTranslator ) + { + this.expressionPrefixes = expressionPrefixes; + this.unprefixedPathKeys = unprefixedPathKeys; + this.projectDir = projectDir; + this.pathTranslator = pathTranslator; + } + + @Override + public Object execute( String expression, Object value ) + { + if ( value != null ) + { + expression = ValueSourceUtils.trimPrefix( expression, expressionPrefixes, true ); + + if ( unprefixedPathKeys.contains( expression ) ) + { + return pathTranslator.alignToBaseDirectory( String.valueOf( value ), projectDir ); + } + } + + return null; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java new file mode 100644 index 00000000..be5b227e --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java @@ -0,0 +1,87 @@ +package org.apache.maven.model.interpolation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; + +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.building.ModelProblem.Severity; +import org.apache.maven.model.building.ModelProblem.Version; +import org.apache.maven.model.building.ModelProblemCollectorRequest; +import org.codehaus.plexus.interpolation.ValueSource; + +/** + * Wraps another value source and intercepts interpolated expressions, checking for problems. + * + * @author Benjamin Bentmann + */ +class ProblemDetectingValueSource + implements ValueSource +{ + + private final ValueSource valueSource; + + private final String bannedPrefix; + + private final String newPrefix; + + private final ModelProblemCollector problems; + + public ProblemDetectingValueSource( ValueSource valueSource, String bannedPrefix, String newPrefix, + ModelProblemCollector problems ) + { + this.valueSource = valueSource; + this.bannedPrefix = bannedPrefix; + this.newPrefix = newPrefix; + this.problems = problems; + } + + @Override + public Object getValue( String expression ) + { + Object value = valueSource.getValue( expression ); + + if ( value != null && expression.startsWith( bannedPrefix ) ) + { + String msg = "The expression ${" + expression + "} is deprecated."; + if ( newPrefix != null && newPrefix.length() > 0 ) + { + msg += " Please use ${" + newPrefix + expression.substring( bannedPrefix.length() ) + "} instead."; + } + problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 ).setMessage( msg ) ); + } + + return value; + } + + @Override + @SuppressWarnings( "unchecked" ) + public List getFeedback() + { + return valueSource.getFeedback(); + } + + @Override + public void clearFeedback() + { + valueSource.clearFeedback(); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java new file mode 100644 index 00000000..c40f9bd5 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java @@ -0,0 +1,504 @@ +package org.apache.maven.model.interpolation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblem.Severity; +import org.apache.maven.model.building.ModelProblem.Version; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.building.ModelProblemCollectorRequest; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.interpolation.InterpolationPostProcessor; +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.StringSearchInterpolator; +import org.codehaus.plexus.interpolation.ValueSource; + +import java.io.File; +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +@Component( role = ModelInterpolator.class ) +public class StringSearchModelInterpolator + extends AbstractStringBasedModelInterpolator +{ + + private static final Map, InterpolateObjectAction.CacheItem> CACHED_ENTRIES = + new ConcurrentHashMap, InterpolateObjectAction.CacheItem>( 80, 0.75f, 2 ); + // Empirical data from 3.x, actual =40 + + + @Override + public Model interpolateModel( Model model, File projectDir, ModelBuildingRequest config, + ModelProblemCollector problems ) + { + interpolateObject( model, model, projectDir, config, problems ); + + return model; + } + + protected void interpolateObject( Object obj, Model model, File projectDir, ModelBuildingRequest config, + ModelProblemCollector problems ) + { + try + { + List valueSources = createValueSources( model, projectDir, config, problems ); + List postProcessors = + createPostProcessors( model, projectDir, config ); + + InterpolateObjectAction action = + new InterpolateObjectAction( obj, valueSources, postProcessors, this, problems ); + + AccessController.doPrivileged( action ); + } + finally + { + getInterpolator().clearAnswers(); + } + } + + @Override + protected Interpolator createInterpolator() + { + StringSearchInterpolator interpolator = new StringSearchInterpolator(); + interpolator.setCacheAnswers( true ); + + return interpolator; + } + + private static final class InterpolateObjectAction + implements PrivilegedAction + { + + private final LinkedList interpolationTargets; + + private final StringSearchModelInterpolator modelInterpolator; + + private final List valueSources; + + private final List postProcessors; + + private final ModelProblemCollector problems; + + public InterpolateObjectAction( Object target, List valueSources, + List postProcessors, + StringSearchModelInterpolator modelInterpolator, + ModelProblemCollector problems ) + { + this.valueSources = valueSources; + this.postProcessors = postProcessors; + + this.interpolationTargets = new LinkedList(); + interpolationTargets.add( target ); + + this.modelInterpolator = modelInterpolator; + + this.problems = problems; + } + + @Override + public Object run() + { + while ( !interpolationTargets.isEmpty() ) + { + Object obj = interpolationTargets.removeFirst(); + + traverseObjectWithParents( obj.getClass(), obj ); + } + + return null; + } + + + private String interpolate( String value ) + { + return modelInterpolator.interpolateInternal( value, valueSources, postProcessors, problems ); + } + + private void traverseObjectWithParents( Class cls, Object target ) + { + if ( cls == null ) + { + return; + } + + CacheItem cacheEntry = getCacheEntry( cls ); + if ( cacheEntry.isArray() ) + { + evaluateArray( target, this ); + } + else if ( cacheEntry.isQualifiedForInterpolation ) + { + cacheEntry.interpolate( target, this ); + + traverseObjectWithParents( cls.getSuperclass(), target ); + } + } + + + private CacheItem getCacheEntry( Class cls ) + { + CacheItem cacheItem = CACHED_ENTRIES.get( cls ); + if ( cacheItem == null ) + { + cacheItem = new CacheItem( cls ); + CACHED_ENTRIES.put( cls, cacheItem ); + } + return cacheItem; + } + + private static void evaluateArray( Object target, InterpolateObjectAction ctx ) + { + int len = Array.getLength( target ); + for ( int i = 0; i < len; i++ ) + { + Object value = Array.get( target, i ); + if ( value != null ) + { + if ( String.class == value.getClass() ) + { + String interpolated = ctx.interpolate( (String) value ); + + if ( !interpolated.equals( value ) ) + { + Array.set( target, i, interpolated ); + } + } + else + { + ctx.interpolationTargets.add( value ); + } + } + } + } + + private static class CacheItem + { + private final boolean isArray; + + private final boolean isQualifiedForInterpolation; + + private final CacheField[] fields; + + private boolean isQualifiedForInterpolation( Class cls ) + { + return !cls.getName().startsWith( "java" ); + } + + private boolean isQualifiedForInterpolation( Field field, Class fieldType ) + { + if ( Map.class.equals( fieldType ) && "locations".equals( field.getName() ) ) + { + return false; + } + + //noinspection SimplifiableIfStatement + if ( fieldType.isPrimitive() ) + { + return false; + } + + return !"parent".equals( field.getName() ); + } + + CacheItem( Class clazz ) + { + this.isQualifiedForInterpolation = isQualifiedForInterpolation( clazz ); + this.isArray = clazz.isArray(); + List fields = new ArrayList(); + for ( Field currentField : clazz.getDeclaredFields() ) + { + Class type = currentField.getType(); + if ( isQualifiedForInterpolation( currentField, type ) ) + { + if ( String.class == type ) + { + if ( !Modifier.isFinal( currentField.getModifiers() ) ) + { + fields.add( new StringField( currentField ) ); + } + } + else if ( List.class.isAssignableFrom( type ) ) + { + fields.add( new ListField( currentField ) ); + } + else if ( Collection.class.isAssignableFrom( type ) ) + { + throw new RuntimeException( "We dont interpolate into collections, use a list instead" ); + } + else if ( Map.class.isAssignableFrom( type ) ) + { + fields.add( new MapField( currentField ) ); + } + else + { + fields.add( new ObjectField( currentField ) ); + } + } + + } + this.fields = fields.toArray( new CacheField[fields.size()] ); + + } + + public void interpolate( Object target, InterpolateObjectAction interpolateObjectAction ) + { + for ( CacheField field : fields ) + { + field.interpolate( target, interpolateObjectAction ); + } + } + + public boolean isArray() + { + return isArray; + } + } + + abstract static class CacheField + { + protected final Field field; + + CacheField( Field field ) + { + this.field = field; + } + + void interpolate( Object target, InterpolateObjectAction interpolateObjectAction ) + { + synchronized ( field ) + { + boolean isAccessible = field.isAccessible(); + field.setAccessible( true ); + try + { + doInterpolate( target, interpolateObjectAction ); + } + catch ( IllegalArgumentException e ) + { + interpolateObjectAction.problems.add( + new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( + "Failed to interpolate field3: " + field + " on class: " + + field.getType().getName() ).setException( + e ) ); // todo: Not entirely the same message + } + catch ( IllegalAccessException e ) + { + interpolateObjectAction.problems.add( + new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( + "Failed to interpolate field4: " + field + " on class: " + + field.getType().getName() ).setException( e ) ); + } + finally + { + field.setAccessible( isAccessible ); + } + } + + + } + + abstract void doInterpolate( Object target, InterpolateObjectAction ctx ) + throws IllegalAccessException; + } + + static final class StringField + extends CacheField + { + StringField( Field field ) + { + super( field ); + } + + @Override + void doInterpolate( Object target, InterpolateObjectAction ctx ) + throws IllegalAccessException + { + String value = (String) field.get( target ); + if ( value == null ) + { + return; + } + + String interpolated = ctx.interpolate( value ); + + if ( !interpolated.equals( value ) ) + { + field.set( target, interpolated ); + } + } + } + + static final class ListField + extends CacheField + { + ListField( Field field ) + { + super( field ); + } + + @Override + void doInterpolate( Object target, InterpolateObjectAction ctx ) + throws IllegalAccessException + { + @SuppressWarnings( "unchecked" ) List c = (List) field.get( target ); + if ( c == null ) + { + return; + } + + int size = c.size(); + Object value; + for ( int i = 0; i < size; i++ ) + { + + value = c.get( i ); + + if ( value != null ) + { + if ( String.class == value.getClass() ) + { + String interpolated = ctx.interpolate( (String) value ); + + if ( !interpolated.equals( value ) ) + { + try + { + c.set( i, interpolated ); + } + catch ( UnsupportedOperationException e ) + { + return; + } + } + } + else + { + if ( value.getClass().isArray() ) + { + evaluateArray( value, ctx ); + } + else + { + ctx.interpolationTargets.add( value ); + } + } + } + } + } + } + + static final class MapField + extends CacheField + { + MapField( Field field ) + { + super( field ); + } + + @Override + void doInterpolate( Object target, InterpolateObjectAction ctx ) + throws IllegalAccessException + { + @SuppressWarnings( "unchecked" ) Map m = (Map) field.get( target ); + if ( m == null || m.isEmpty() ) + { + return; + } + + for ( Map.Entry entry : m.entrySet() ) + { + Object value = entry.getValue(); + + if ( value == null ) + { + continue; + } + + if ( String.class == value.getClass() ) + { + String interpolated = ctx.interpolate( (String) value ); + + if ( !interpolated.equals( value ) ) + { + try + { + entry.setValue( interpolated ); + } + catch ( UnsupportedOperationException ignore ) + { + // nop + } + } + } + else if ( value.getClass().isArray() ) + { + evaluateArray( value, ctx ); + } + else + { + ctx.interpolationTargets.add( value ); + } + } + } + } + + static final class ObjectField + extends CacheField + { + private final boolean isArray; + + ObjectField( Field field ) + { + super( field ); + this.isArray = field.getType().isArray(); + } + + @Override + void doInterpolate( Object target, InterpolateObjectAction ctx ) + throws IllegalAccessException + { + Object value = field.get( target ); + if ( value != null ) + { + if ( isArray ) + { + evaluateArray( value, ctx ); + } + else + { + ctx.interpolationTargets.add( value ); + } + } + } + } + + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/UrlNormalizingPostProcessor.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/UrlNormalizingPostProcessor.java new file mode 100644 index 00000000..63fb82d6 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/UrlNormalizingPostProcessor.java @@ -0,0 +1,69 @@ +package org.apache.maven.model.interpolation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.HashSet; +import java.util.Set; + +import org.apache.maven.model.path.UrlNormalizer; +import org.codehaus.plexus.interpolation.InterpolationPostProcessor; + +/** + * Ensures that expressions referring to URLs evaluate to normalized URLs. + * + * @author Benjamin Bentmann + */ +class UrlNormalizingPostProcessor + implements InterpolationPostProcessor +{ + + private static final Set URL_EXPRESSIONS; + + static + { + Set expressions = new HashSet(); + expressions.add( "project.url" ); + expressions.add( "project.scm.url" ); + expressions.add( "project.scm.connection" ); + expressions.add( "project.scm.developerConnection" ); + expressions.add( "project.distributionManagement.site.url" ); + + URL_EXPRESSIONS = expressions; + } + + private UrlNormalizer normalizer; + + public UrlNormalizingPostProcessor( UrlNormalizer normalizer ) + { + this.normalizer = normalizer; + } + + @Override + public Object execute( String expression, Object value ) + { + if ( value != null && URL_EXPRESSIONS.contains( expression ) ) + { + return normalizer.normalize( value.toString() ); + } + + return null; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java new file mode 100644 index 00000000..c927b60f --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java @@ -0,0 +1,134 @@ +package org.apache.maven.model.io; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.util.Map; + +import org.apache.maven.model.InputSource; +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.model.io.xpp3.MavenXpp3ReaderEx; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +/** + * Handles deserialization of a model from some kind of textual format like XML. + * + * @author Benjamin Bentmann + */ +@Component( role = ModelReader.class ) +public class DefaultModelReader + implements ModelReader +{ + + @Override + public Model read( File input, Map options ) + throws IOException + { + if ( input == null ) + { + throw new IllegalArgumentException( "input file missing" ); + } + + Model model = read( new FileInputStream( input ), options ); + + model.setPomFile( input ); + + return model; + } + + @Override + public Model read( Reader input, Map options ) + throws IOException + { + if ( input == null ) + { + throw new IllegalArgumentException( "input reader missing" ); + } + + try + { + return read( input, isStrict( options ), getSource( options ) ); + } + finally + { + IOUtil.close( input ); + } + } + + @Override + public Model read( InputStream input, Map options ) + throws IOException + { + if ( input == null ) + { + throw new IllegalArgumentException( "input stream missing" ); + } + + try + { + return read( ReaderFactory.newXmlReader( input ), isStrict( options ), getSource( options ) ); + } + finally + { + IOUtil.close( input ); + } + } + + private boolean isStrict( Map options ) + { + Object value = ( options != null ) ? options.get( IS_STRICT ) : null; + return value == null || Boolean.parseBoolean( value.toString() ); + } + + private InputSource getSource( Map options ) + { + Object value = ( options != null ) ? options.get( INPUT_SOURCE ) : null; + return (InputSource) value; + } + + private Model read( Reader reader, boolean strict, InputSource source ) + throws IOException + { + try + { + if ( source != null ) + { + return new MavenXpp3ReaderEx().read( reader, strict, source ); + } + else + { + return new MavenXpp3Reader().read( reader, strict ); + } + } + catch ( XmlPullParserException e ) + { + throw new ModelParseException( e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e ); + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java new file mode 100644 index 00000000..7294de3c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java @@ -0,0 +1,118 @@ +package org.apache.maven.model.io; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.Map; + +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Writer; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.WriterFactory; + +/** + * Handles serialization of a model into some kind of textual format like XML. + * + * @author Benjamin Bentmann + */ +@Component( role = ModelWriter.class ) +public class DefaultModelWriter + implements ModelWriter +{ + + @Override + public void write( File output, Map options, Model model ) + throws IOException + { + if ( output == null ) + { + throw new IllegalArgumentException( "output file missing" ); + } + + if ( model == null ) + { + throw new IllegalArgumentException( "model missing" ); + } + + output.getParentFile().mkdirs(); + + write( WriterFactory.newXmlWriter( output ), options, model ); + } + + @Override + public void write( Writer output, Map options, Model model ) + throws IOException + { + if ( output == null ) + { + throw new IllegalArgumentException( "output writer missing" ); + } + + if ( model == null ) + { + throw new IllegalArgumentException( "model missing" ); + } + + try + { + MavenXpp3Writer w = new MavenXpp3Writer(); + w.write( output, model ); + } + finally + { + IOUtil.close( output ); + } + } + + @Override + public void write( OutputStream output, Map options, Model model ) + throws IOException + { + if ( output == null ) + { + throw new IllegalArgumentException( "output stream missing" ); + } + + if ( model == null ) + { + throw new IllegalArgumentException( "model missing" ); + } + + try + { + String encoding = model.getModelEncoding(); + if ( encoding == null || encoding.length() <= 0 ) + { + encoding = "UTF-8"; + } + write( new OutputStreamWriter( output, encoding ), options, model ); + } + finally + { + IOUtil.close( output ); + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelParseException.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelParseException.java new file mode 100644 index 00000000..1b2cbc34 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelParseException.java @@ -0,0 +1,93 @@ +package org.apache.maven.model.io; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; + +/** + * Signals a failure to parse the POM due to invalid syntax (e.g. non-wellformed XML or unknown elements). + * + * @author Benjamin Bentmann + */ +public class ModelParseException + extends IOException +{ + + /** + * The one-based index of the line containing the error. + */ + private final int lineNumber; + + /** + * The one-based index of the column containing the error. + */ + private final int columnNumber; + + /** + * Creates a new parser exception with the specified details. + * + * @param message The error message, may be {@code null}. + * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. + * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. + */ + public ModelParseException( String message, int lineNumber, int columnNumber ) + { + super( message ); + this.lineNumber = lineNumber; + this.columnNumber = columnNumber; + } + + /** + * Creates a new parser exception with the specified details. + * + * @param message The error message, may be {@code null}. + * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. + * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. + * @param cause The nested cause of this error, may be {@code null}. + */ + public ModelParseException( String message, int lineNumber, int columnNumber, Throwable cause ) + { + super( message ); + initCause( cause ); + this.lineNumber = lineNumber; + this.columnNumber = columnNumber; + } + + /** + * Gets the one-based index of the line containing the error. + * + * @return The one-based index of the line containing the error or a non-positive value if unknown. + */ + public int getLineNumber() + { + return lineNumber; + } + + /** + * Gets the one-based index of the column containing the error. + * + * @return The one-based index of the column containing the error or non-positive value if unknown. + */ + public int getColumnNumber() + { + return columnNumber; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelReader.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelReader.java new file mode 100644 index 00000000..75a5ebee --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelReader.java @@ -0,0 +1,89 @@ +package org.apache.maven.model.io; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.util.Map; + +import org.apache.maven.model.Model; + +/** + * Handles deserialization of a model from some kind of textual format like XML. + * + * @author Benjamin Bentmann + */ +public interface ModelReader +{ + + /** + * The key for the option to enable strict parsing. This option is of type {@link Boolean} and defaults to {@code + * true}. If {@code false}, unknown elements will be ignored instead of causing a failure. + */ + String IS_STRICT = "org.apache.maven.model.io.isStrict"; + + /** + * The key for the option to enable tracking of line/column numbers. This option is of type + * {@link org.apache.maven.model.InputSource} and defaults to {@code null}. Providing an input source enables + * location tracking. + */ + String INPUT_SOURCE = "org.apache.maven.model.io.inputSource"; + + /** + * Reads the model from the specified file. + * + * @param input The file to deserialize the model from, must not be {@code null}. + * @param options The options to use for deserialization, may be {@code null} to use the default values. + * @return The deserialized model, never {@code null}. + * @throws IOException If the model could not be deserialized. + * @throws ModelParseException If the input format could not be parsed. + */ + Model read( File input, Map options ) + throws IOException, ModelParseException; + + /** + * Reads the model from the specified character reader. The reader will be automatically closed before the method + * returns. + * + * @param input The reader to deserialize the model from, must not be {@code null}. + * @param options The options to use for deserialization, may be {@code null} to use the default values. + * @return The deserialized model, never {@code null}. + * @throws IOException If the model could not be deserialized. + * @throws ModelParseException If the input format could not be parsed. + */ + Model read( Reader input, Map options ) + throws IOException, ModelParseException; + + /** + * Reads the model from the specified byte stream. The stream will be automatically closed before the method + * returns. + * + * @param input The stream to deserialize the model from, must not be {@code null}. + * @param options The options to use for deserialization, may be {@code null} to use the default values. + * @return The deserialized model, never {@code null}. + * @throws IOException If the model could not be deserialized. + * @throws ModelParseException If the input format could not be parsed. + */ + Model read( InputStream input, Map options ) + throws IOException, ModelParseException; + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelWriter.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelWriter.java new file mode 100644 index 00000000..af7e0cab --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelWriter.java @@ -0,0 +1,74 @@ +package org.apache.maven.model.io; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.io.Writer; +import java.util.Map; + +import org.apache.maven.model.Model; + +/** + * Handles serialization of a model into some kind of textual format like XML. + * + * @author Benjamin Bentmann + */ +public interface ModelWriter +{ + + /** + * Writes the supplied model to the specified file. Any non-existing parent directories of the output file will be + * created automatically. + * + * @param output The file to serialize the model to, must not be {@code null}. + * @param options The options to use for serialization, may be {@code null} to use the default values. + * @param model The model to serialize, must not be {@code null}. + * @throws IOException If the model could not be serialized. + */ + void write( File output, Map options, Model model ) + throws IOException; + + /** + * Writes the supplied model to the specified character writer. The writer will be automatically closed before the + * method returns. + * + * @param output The writer to serialize the model to, must not be {@code null}. + * @param options The options to use for serialization, may be {@code null} to use the default values. + * @param model The model to serialize, must not be {@code null}. + * @throws IOException If the model could not be serialized. + */ + void write( Writer output, Map options, Model model ) + throws IOException; + + /** + * Writes the supplied model to the specified byte stream. The stream will be automatically closed before the method + * returns. + * + * @param output The stream to serialize the model to, must not be {@code null}. + * @param options The options to use for serialization, may be {@code null} to use the default values. + * @param model The model to serialize, must not be {@code null}. + * @throws IOException If the model could not be serialized. + */ + void write( OutputStream output, Map options, Model model ) + throws IOException; + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/locator/DefaultModelLocator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/locator/DefaultModelLocator.java new file mode 100644 index 00000000..299da65f --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/locator/DefaultModelLocator.java @@ -0,0 +1,42 @@ +package org.apache.maven.model.locator; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +import org.codehaus.plexus.component.annotations.Component; + +/** + * Locates a POM file within a project base directory. + * + * @author Benjamin Bentmann + */ +@Component( role = ModelLocator.class ) +public class DefaultModelLocator + implements ModelLocator +{ + + @Override + public File locatePom( File projectDirectory ) + { + return new File( projectDirectory, "pom.xml" ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/locator/ModelLocator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/locator/ModelLocator.java new file mode 100644 index 00000000..3aa0045c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/locator/ModelLocator.java @@ -0,0 +1,44 @@ +package org.apache.maven.model.locator; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +/** + * Locates a POM file within a project base directory. + * + * @author Benjamin Bentmann + */ +public interface ModelLocator +{ + + /** + * Locates the POM file within the specified project directory. In case the given project directory does not exist + * or does not contain a POM file, the return value indicates the expected path to the POM file. Sub directories of + * the project directory will not be considered when locating the POM file. The return value will be an absolute + * path if the project directory is given as an absolute path. + * + * @param projectDirectory The (possibly non-existent) base directory to locate the POM file in, must not be {@code + * null}. + * @return The path to the (possibly non-existent) POM file, never {@code null}. + */ + File locatePom( File projectDirectory ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java new file mode 100644 index 00000000..bfeafcb7 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java @@ -0,0 +1,110 @@ +package org.apache.maven.model.management; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.Exclusion; +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.merge.MavenModelMerger; +import org.codehaus.plexus.component.annotations.Component; + +/** + * Handles injection of dependency management into the model. + * + * @author Benjamin Bentmann + */ +@Component( role = DependencyManagementInjector.class ) +public class DefaultDependencyManagementInjector + implements DependencyManagementInjector +{ + + private ManagementModelMerger merger = new ManagementModelMerger(); + + @Override + public void injectManagement( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + merger.mergeManagedDependencies( model ); + } + + protected static class ManagementModelMerger + extends MavenModelMerger + { + + public void mergeManagedDependencies( Model model ) + { + DependencyManagement dependencyManagement = model.getDependencyManagement(); + if ( dependencyManagement != null ) + { + Map dependencies = new HashMap(); + Map context = Collections.emptyMap(); + + for ( Dependency dependency : model.getDependencies() ) + { + Object key = getDependencyKey( dependency ); + dependencies.put( key, dependency ); + } + + for ( Dependency managedDependency : dependencyManagement.getDependencies() ) + { + Object key = getDependencyKey( managedDependency ); + Dependency dependency = dependencies.get( key ); + if ( dependency != null ) + { + mergeDependency( dependency, managedDependency, false, context ); + } + } + } + } + + @Override + protected void mergeDependency_Optional( Dependency target, Dependency source, boolean sourceDominant, + Map context ) + { + // optional flag is not managed + } + + @Override + protected void mergeDependency_Exclusions( Dependency target, Dependency source, boolean sourceDominant, + Map context ) + { + List tgt = target.getExclusions(); + if ( tgt.isEmpty() ) + { + List src = source.getExclusions(); + + for ( Exclusion element : src ) + { + Exclusion clone = element.clone(); + target.addExclusion( clone ); + } + } + } + + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultPluginManagementInjector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultPluginManagementInjector.java new file mode 100644 index 00000000..75d7d878 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultPluginManagementInjector.java @@ -0,0 +1,137 @@ +package org.apache.maven.model.management; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.maven.model.Build; +import org.apache.maven.model.Model; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginContainer; +import org.apache.maven.model.PluginExecution; +import org.apache.maven.model.PluginManagement; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.merge.MavenModelMerger; +import org.codehaus.plexus.component.annotations.Component; + +/** + * Handles injection of plugin management into the model. + * + * @author Benjamin Bentmann + */ +@Component( role = PluginManagementInjector.class ) +public class DefaultPluginManagementInjector + implements PluginManagementInjector +{ + + private ManagementModelMerger merger = new ManagementModelMerger(); + + @Override + public void injectManagement( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + merger.mergeManagedBuildPlugins( model ); + } + + protected static class ManagementModelMerger + extends MavenModelMerger + { + + public void mergeManagedBuildPlugins( Model model ) + { + Build build = model.getBuild(); + if ( build != null ) + { + PluginManagement pluginManagement = build.getPluginManagement(); + if ( pluginManagement != null ) + { + mergePluginContainer_Plugins( build, pluginManagement ); + } + } + } + + private void mergePluginContainer_Plugins( PluginContainer target, PluginContainer source ) + { + List src = source.getPlugins(); + if ( !src.isEmpty() ) + { + List tgt = target.getPlugins(); + + Map managedPlugins = new LinkedHashMap( src.size() * 2 ); + + Map context = Collections.emptyMap(); + + for ( Plugin element : src ) + { + Object key = getPluginKey( element ); + managedPlugins.put( key, element ); + } + + for ( Plugin element : tgt ) + { + Object key = getPluginKey( element ); + Plugin managedPlugin = managedPlugins.get( key ); + if ( managedPlugin != null ) + { + mergePlugin( element, managedPlugin, false, context ); + } + } + } + } + + @Override + protected void mergePlugin_Executions( Plugin target, Plugin source, boolean sourceDominant, + Map context ) + { + List src = source.getExecutions(); + if ( !src.isEmpty() ) + { + List tgt = target.getExecutions(); + + Map merged = + new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); + + for ( PluginExecution element : src ) + { + Object key = getPluginExecutionKey( element ); + merged.put( key, element.clone() ); + } + + for ( PluginExecution element : tgt ) + { + Object key = getPluginExecutionKey( element ); + PluginExecution existing = merged.get( key ); + if ( existing != null ) + { + mergePluginExecution( element, existing, sourceDominant, context ); + } + merged.put( key, element ); + } + + target.setExecutions( new ArrayList( merged.values() ) ); + } + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/DependencyManagementInjector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/DependencyManagementInjector.java new file mode 100644 index 00000000..3b70a09c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/DependencyManagementInjector.java @@ -0,0 +1,44 @@ +package org.apache.maven.model.management; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles injection of dependency management into the model. + * + * @author Benjamin Bentmann + */ +public interface DependencyManagementInjector +{ + + /** + * Merges default values from the dependency management section of the given model into itself. + * + * @param model The model into which to merge the values specified by its dependency management sections, must not + * be null. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void injectManagement( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/PluginManagementInjector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/PluginManagementInjector.java new file mode 100644 index 00000000..7384fdf0 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/management/PluginManagementInjector.java @@ -0,0 +1,44 @@ +package org.apache.maven.model.management; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles injection of plugin management into the model. + * + * @author Benjamin Bentmann + */ +public interface PluginManagementInjector +{ + + /** + * Merges default values from the plugin management section of the given model into itself. + * + * @param model The model into which to merge the values specified by its plugin management section, must not be + * null. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void injectManagement( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java new file mode 100644 index 00000000..2727a111 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java @@ -0,0 +1,729 @@ +package org.apache.maven.model.merge; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.maven.model.BuildBase; +import org.apache.maven.model.CiManagement; +import org.apache.maven.model.Contributor; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DeploymentRepository; +import org.apache.maven.model.Developer; +import org.apache.maven.model.DistributionManagement; +import org.apache.maven.model.Exclusion; +import org.apache.maven.model.Extension; +import org.apache.maven.model.InputLocation; +import org.apache.maven.model.IssueManagement; +import org.apache.maven.model.License; +import org.apache.maven.model.MailingList; +import org.apache.maven.model.Model; +import org.apache.maven.model.ModelBase; +import org.apache.maven.model.Organization; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginExecution; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.ReportSet; +import org.apache.maven.model.Repository; +import org.apache.maven.model.RepositoryBase; +import org.apache.maven.model.Scm; +import org.apache.maven.model.Site; + +/** + * The domain-specific model merger for the Maven POM, overriding generic code from parent class when necessary with + * more adapted algorithms. + * + * @author Benjamin Bentmann + */ +public class MavenModelMerger + extends ModelMerger +{ + + /** + * The hint key for the child path adjustment used during inheritance for URL calculations. + */ + public static final String CHILD_PATH_ADJUSTMENT = "child-path-adjustment"; + + /** + * The context key for the artifact id of the target model. + */ + private static final String ARTIFACT_ID = "artifact-id"; + + @Override + protected void mergeModel( Model target, Model source, boolean sourceDominant, Map context ) + { + context.put( ARTIFACT_ID, target.getArtifactId() ); + + super.mergeModel( target, source, sourceDominant, context ); + } + + @Override + protected void mergeModel_Name( Model target, Model source, boolean sourceDominant, Map context ) + { + String src = source.getName(); + if ( src != null ) + { + if ( sourceDominant ) + { + target.setName( src ); + target.setLocation( "name", source.getLocation( "name" ) ); + } + } + } + + @Override + protected void mergeModel_Url( Model target, Model source, boolean sourceDominant, Map context ) + { + String src = source.getUrl(); + if ( src != null ) + { + if ( sourceDominant ) + { + target.setUrl( src ); + target.setLocation( "url", source.getLocation( "url" ) ); + } + else if ( target.getUrl() == null ) + { + target.setUrl( appendPath( src, context ) ); + target.setLocation( "url", source.getLocation( "url" ) ); + } + } + } + + /* + * TODO: Whether the merge continues recursively into an existing node or not could be an option for the generated + * merger + */ + @Override + protected void mergeModel_Organization( Model target, Model source, boolean sourceDominant, + Map context ) + { + Organization src = source.getOrganization(); + if ( src != null ) + { + Organization tgt = target.getOrganization(); + if ( tgt == null ) + { + tgt = new Organization(); + tgt.setLocation( "", src.getLocation( "" ) ); + target.setOrganization( tgt ); + mergeOrganization( tgt, src, sourceDominant, context ); + } + } + } + + @Override + protected void mergeModel_IssueManagement( Model target, Model source, boolean sourceDominant, + Map context ) + { + IssueManagement src = source.getIssueManagement(); + if ( src != null ) + { + IssueManagement tgt = target.getIssueManagement(); + if ( tgt == null ) + { + tgt = new IssueManagement(); + tgt.setLocation( "", src.getLocation( "" ) ); + target.setIssueManagement( tgt ); + mergeIssueManagement( tgt, src, sourceDominant, context ); + } + } + } + + @Override + protected void mergeModel_CiManagement( Model target, Model source, boolean sourceDominant, + Map context ) + { + CiManagement src = source.getCiManagement(); + if ( src != null ) + { + CiManagement tgt = target.getCiManagement(); + if ( tgt == null ) + { + tgt = new CiManagement(); + tgt.setLocation( "", src.getLocation( "" ) ); + target.setCiManagement( tgt ); + mergeCiManagement( tgt, src, sourceDominant, context ); + } + } + } + + @Override + protected void mergeModel_ModelVersion( Model target, Model source, boolean sourceDominant, + Map context ) + { + // neither inherited nor injected + } + + @Override + protected void mergeModel_ArtifactId( Model target, Model source, boolean sourceDominant, + Map context ) + { + // neither inherited nor injected + } + + @Override + protected void mergeModel_Profiles( Model target, Model source, boolean sourceDominant, + Map context ) + { + // neither inherited nor injected + } + + @Override + protected void mergeModel_Prerequisites( Model target, Model source, boolean sourceDominant, + Map context ) + { + // neither inherited nor injected + } + + @Override + protected void mergeModel_Licenses( Model target, Model source, boolean sourceDominant, + Map context ) + { + if ( target.getLicenses().isEmpty() ) + { + target.setLicenses( new ArrayList( source.getLicenses() ) ); + } + } + + @Override + protected void mergeModel_Developers( Model target, Model source, boolean sourceDominant, + Map context ) + { + if ( target.getDevelopers().isEmpty() ) + { + target.setDevelopers( new ArrayList( source.getDevelopers() ) ); + } + } + + @Override + protected void mergeModel_Contributors( Model target, Model source, boolean sourceDominant, + Map context ) + { + if ( target.getContributors().isEmpty() ) + { + target.setContributors( new ArrayList( source.getContributors() ) ); + } + } + + @Override + protected void mergeModel_MailingLists( Model target, Model source, boolean sourceDominant, + Map context ) + { + if ( target.getMailingLists().isEmpty() ) + { + target.setMailingLists( new ArrayList( source.getMailingLists() ) ); + } + } + + @Override + protected void mergeModelBase_Modules( ModelBase target, ModelBase source, boolean sourceDominant, + Map context ) + { + List src = source.getModules(); + if ( !src.isEmpty() && sourceDominant ) + { + List indices = new ArrayList(); + List tgt = target.getModules(); + Set excludes = new LinkedHashSet( tgt ); + List merged = new ArrayList( tgt.size() + src.size() ); + merged.addAll( tgt ); + for ( int i = 0, n = tgt.size(); i < n; i++ ) + { + indices.add( i ); + } + for ( int i = 0, n = src.size(); i < n; i++ ) + { + String s = src.get( i ); + if ( !excludes.contains( s ) ) + { + merged.add( s ); + indices.add( ~i ); + } + } + target.setModules( merged ); + target.setLocation( "modules", InputLocation.merge( target.getLocation( "modules" ), + source.getLocation( "modules" ), indices ) ); + } + } + + /* + * TODO: The order of the merged list could be controlled by an attribute in the model association: target-first, + * source-first, dominant-first, recessive-first + */ + @Override + protected void mergeModelBase_Repositories( ModelBase target, ModelBase source, boolean sourceDominant, + Map context ) + { + List src = source.getRepositories(); + if ( !src.isEmpty() ) + { + List tgt = target.getRepositories(); + Map merged = new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); + + List dominant, recessive; + if ( sourceDominant ) + { + dominant = src; + recessive = tgt; + } + else + { + dominant = tgt; + recessive = src; + } + + for ( Repository element : dominant ) + { + Object key = getRepositoryKey( element ); + merged.put( key, element ); + } + + for ( Repository element : recessive ) + { + Object key = getRepositoryKey( element ); + if ( !merged.containsKey( key ) ) + { + merged.put( key, element ); + } + } + + target.setRepositories( new ArrayList( merged.values() ) ); + } + } + + @Override + protected void mergeModelBase_PluginRepositories( ModelBase target, ModelBase source, boolean sourceDominant, + Map context ) + { + List src = source.getPluginRepositories(); + if ( !src.isEmpty() ) + { + List tgt = target.getPluginRepositories(); + Map merged = new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); + + List dominant, recessive; + if ( sourceDominant ) + { + dominant = src; + recessive = tgt; + } + else + { + dominant = tgt; + recessive = src; + } + + for ( Repository element : dominant ) + { + Object key = getRepositoryKey( element ); + merged.put( key, element ); + } + + for ( Repository element : recessive ) + { + Object key = getRepositoryKey( element ); + if ( !merged.containsKey( key ) ) + { + merged.put( key, element ); + } + } + + target.setPluginRepositories( new ArrayList( merged.values() ) ); + } + } + + /* + * TODO: Whether duplicates should be removed looks like an option for the generated merger. + */ + @Override + protected void mergeBuildBase_Filters( BuildBase target, BuildBase source, boolean sourceDominant, + Map context ) + { + List src = source.getFilters(); + if ( !src.isEmpty() ) + { + List tgt = target.getFilters(); + Set excludes = new LinkedHashSet( tgt ); + List merged = new ArrayList( tgt.size() + src.size() ); + merged.addAll( tgt ); + for ( String s : src ) + { + if ( !excludes.contains( s ) ) + { + merged.add( s ); + } + } + target.setFilters( merged ); + } + } + + @Override + protected void mergeBuildBase_Resources( BuildBase target, BuildBase source, boolean sourceDominant, + Map context ) + { + if ( sourceDominant || target.getResources().isEmpty() ) + { + super.mergeBuildBase_Resources( target, source, sourceDominant, context ); + } + } + + @Override + protected void mergeBuildBase_TestResources( BuildBase target, BuildBase source, boolean sourceDominant, + Map context ) + { + if ( sourceDominant || target.getTestResources().isEmpty() ) + { + super.mergeBuildBase_TestResources( target, source, sourceDominant, context ); + } + } + + @Override + protected void mergeDistributionManagement_Repository( DistributionManagement target, + DistributionManagement source, boolean sourceDominant, + Map context ) + { + DeploymentRepository src = source.getRepository(); + if ( src != null ) + { + DeploymentRepository tgt = target.getRepository(); + if ( sourceDominant || tgt == null ) + { + tgt = new DeploymentRepository(); + tgt.setLocation( "", src.getLocation( "" ) ); + target.setRepository( tgt ); + mergeDeploymentRepository( tgt, src, sourceDominant, context ); + } + } + } + + @Override + protected void mergeDistributionManagement_SnapshotRepository( DistributionManagement target, + DistributionManagement source, + boolean sourceDominant, + Map context ) + { + DeploymentRepository src = source.getSnapshotRepository(); + if ( src != null ) + { + DeploymentRepository tgt = target.getSnapshotRepository(); + if ( sourceDominant || tgt == null ) + { + tgt = new DeploymentRepository(); + tgt.setLocation( "", src.getLocation( "" ) ); + target.setSnapshotRepository( tgt ); + mergeDeploymentRepository( tgt, src, sourceDominant, context ); + } + } + } + + @Override + protected void mergeDistributionManagement_Site( DistributionManagement target, DistributionManagement source, + boolean sourceDominant, Map context ) + { + Site src = source.getSite(); + if ( src != null ) + { + Site tgt = target.getSite(); + if ( sourceDominant || tgt == null ) + { + tgt = new Site(); + tgt.setLocation( "", src.getLocation( "" ) ); + target.setSite( tgt ); + mergeSite( tgt, src, sourceDominant, context ); + } + } + } + + @Override + protected void mergeSite_Url( Site target, Site source, boolean sourceDominant, Map context ) + { + String src = source.getUrl(); + if ( src != null ) + { + if ( sourceDominant ) + { + target.setUrl( src ); + target.setLocation( "url", source.getLocation( "url" ) ); + } + else if ( target.getUrl() == null ) + { + target.setUrl( appendPath( src, context ) ); + target.setLocation( "url", source.getLocation( "url" ) ); + } + } + } + + @Override + protected void mergeScm_Url( Scm target, Scm source, boolean sourceDominant, Map context ) + { + String src = source.getUrl(); + if ( src != null ) + { + if ( sourceDominant ) + { + target.setUrl( src ); + target.setLocation( "url", source.getLocation( "url" ) ); + } + else if ( target.getUrl() == null ) + { + target.setUrl( appendPath( src, context ) ); + target.setLocation( "url", source.getLocation( "url" ) ); + } + } + } + + @Override + protected void mergeScm_Connection( Scm target, Scm source, boolean sourceDominant, Map context ) + { + String src = source.getConnection(); + if ( src != null ) + { + if ( sourceDominant ) + { + target.setConnection( src ); + target.setLocation( "connection", source.getLocation( "connection" ) ); + } + else if ( target.getConnection() == null ) + { + target.setConnection( appendPath( src, context ) ); + target.setLocation( "connection", source.getLocation( "connection" ) ); + } + } + } + + @Override + protected void mergeScm_DeveloperConnection( Scm target, Scm source, boolean sourceDominant, + Map context ) + { + String src = source.getDeveloperConnection(); + if ( src != null ) + { + if ( sourceDominant ) + { + target.setDeveloperConnection( src ); + target.setLocation( "developerConnection", source.getLocation( "developerConnection" ) ); + } + else if ( target.getDeveloperConnection() == null ) + { + target.setDeveloperConnection( appendPath( src, context ) ); + target.setLocation( "developerConnection", source.getLocation( "developerConnection" ) ); + } + } + } + + @Override + protected void mergePlugin_Executions( Plugin target, Plugin source, boolean sourceDominant, + Map context ) + { + List src = source.getExecutions(); + if ( !src.isEmpty() ) + { + List tgt = target.getExecutions(); + Map merged = + new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); + + for ( PluginExecution element : src ) + { + if ( sourceDominant + || ( element.getInherited() != null ? element.isInherited() : source.isInherited() ) ) + { + Object key = getPluginExecutionKey( element ); + merged.put( key, element ); + } + } + + for ( PluginExecution element : tgt ) + { + Object key = getPluginExecutionKey( element ); + PluginExecution existing = merged.get( key ); + if ( existing != null ) + { + mergePluginExecution( element, existing, sourceDominant, context ); + } + merged.put( key, element ); + } + + target.setExecutions( new ArrayList( merged.values() ) ); + } + } + + @Override + protected void mergePluginExecution_Goals( PluginExecution target, PluginExecution source, boolean sourceDominant, + Map context ) + { + List src = source.getGoals(); + if ( !src.isEmpty() ) + { + List tgt = target.getGoals(); + Set excludes = new LinkedHashSet( tgt ); + List merged = new ArrayList( tgt.size() + src.size() ); + merged.addAll( tgt ); + for ( String s : src ) + { + if ( !excludes.contains( s ) ) + { + merged.add( s ); + } + } + target.setGoals( merged ); + } + } + + @Override + protected void mergeReportPlugin_ReportSets( ReportPlugin target, ReportPlugin source, boolean sourceDominant, + Map context ) + { + List src = source.getReportSets(); + if ( !src.isEmpty() ) + { + List tgt = target.getReportSets(); + Map merged = new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); + + for ( ReportSet rset : src ) + { + if ( sourceDominant || ( rset.getInherited() != null ? rset.isInherited() : source.isInherited() ) ) + { + Object key = getReportSetKey( rset ); + merged.put( key, rset ); + } + } + + for ( ReportSet element : tgt ) + { + Object key = getReportSetKey( element ); + ReportSet existing = merged.get( key ); + if ( existing != null ) + { + mergeReportSet( element, existing, sourceDominant, context ); + } + merged.put( key, element ); + } + + target.setReportSets( new ArrayList( merged.values() ) ); + } + } + + @Override + protected Object getDependencyKey( Dependency dependency ) + { + return dependency.getManagementKey(); + } + + @Override + protected Object getPluginKey( Plugin plugin ) + { + return plugin.getKey(); + } + + @Override + protected Object getPluginExecutionKey( PluginExecution pluginExecution ) + { + return pluginExecution.getId(); + } + + @Override + protected Object getReportPluginKey( ReportPlugin reportPlugin ) + { + return reportPlugin.getKey(); + } + + @Override + protected Object getReportSetKey( ReportSet reportSet ) + { + return reportSet.getId(); + } + + @Override + protected Object getRepositoryBaseKey( RepositoryBase repositoryBase ) + { + return repositoryBase.getId(); + } + + @Override + protected Object getExtensionKey( Extension extension ) + { + return extension.getGroupId() + ':' + extension.getArtifactId(); + } + + @Override + protected Object getExclusionKey( Exclusion exclusion ) + { + return exclusion.getGroupId() + ':' + exclusion.getArtifactId(); + } + + private String appendPath( String parentPath, Map context ) + { + Object artifactId = context.get( ARTIFACT_ID ); + Object childPathAdjustment = context.get( CHILD_PATH_ADJUSTMENT ); + + if ( artifactId != null && childPathAdjustment != null ) + { + return appendPath( parentPath, artifactId.toString(), childPathAdjustment.toString() ); + } + else + { + return parentPath; + } + } + + private String appendPath( String parentPath, String childPath, String pathAdjustment ) + { + String path = parentPath; + path = concatPath( path, pathAdjustment ); + path = concatPath( path, childPath ); + return path; + } + + private String concatPath( String base, String path ) + { + String result = base; + + if ( path != null && path.length() > 0 ) + { + if ( ( result.endsWith( "/" ) && !path.startsWith( "/" ) ) + || ( !result.endsWith( "/" ) && path.startsWith( "/" ) ) ) + { + result += path; + } + else if ( result.endsWith( "/" ) && path.startsWith( "/" ) ) + { + result += path.substring( 1 ); + } + else + { + result += '/'; + result += path; + } + if ( base.endsWith( "/" ) && !result.endsWith( "/" ) ) + { + result += '/'; + } + } + + return result; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/normalization/DefaultModelNormalizer.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/normalization/DefaultModelNormalizer.java new file mode 100644 index 00000000..262dd3f5 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/normalization/DefaultModelNormalizer.java @@ -0,0 +1,135 @@ +package org.apache.maven.model.normalization; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.maven.model.Build; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Model; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.merge.MavenModelMerger; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.StringUtils; + +/** + * Handles normalization of a model. + * + * @author Benjamin Bentmann + */ +@Component( role = ModelNormalizer.class ) +public class DefaultModelNormalizer + implements ModelNormalizer +{ + + private DuplicateMerger merger = new DuplicateMerger(); + + @Override + public void mergeDuplicates( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + Build build = model.getBuild(); + if ( build != null ) + { + List plugins = build.getPlugins(); + Map normalized = new LinkedHashMap( plugins.size() * 2 ); + + for ( Plugin plugin : plugins ) + { + Object key = plugin.getKey(); + Plugin first = normalized.get( key ); + if ( first != null ) + { + merger.mergePlugin( plugin, first ); + } + normalized.put( key, plugin ); + } + + if ( plugins.size() != normalized.size() ) + { + build.setPlugins( new ArrayList( normalized.values() ) ); + } + } + + /* + * NOTE: This is primarily to keep backward-compat with Maven 2.x which did not validate that dependencies are + * unique within a single POM. Upon multiple declarations, 2.x just kept the last one but retained the order of + * the first occurrence. So when we're in lenient/compat mode, we have to deal with such broken POMs and mimic + * the way 2.x works. When we're in strict mode, the removal of duplicates just saves other merging steps from + * aftereffects and bogus error messages. + */ + List dependencies = model.getDependencies(); + Map normalized = new LinkedHashMap( dependencies.size() * 2 ); + + for ( Dependency dependency : dependencies ) + { + normalized.put( dependency.getManagementKey(), dependency ); + } + + if ( dependencies.size() != normalized.size() ) + { + model.setDependencies( new ArrayList( normalized.values() ) ); + } + } + + protected static class DuplicateMerger + extends MavenModelMerger + { + + public void mergePlugin( Plugin target, Plugin source ) + { + super.mergePlugin( target, source, false, Collections.emptyMap() ); + } + + } + + @Override + public void injectDefaultValues( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + injectDependencyDefaults( model.getDependencies() ); + + Build build = model.getBuild(); + if ( build != null ) + { + for ( Plugin plugin : build.getPlugins() ) + { + injectDependencyDefaults( plugin.getDependencies() ); + } + } + } + + private void injectDependencyDefaults( List dependencies ) + { + for ( Dependency dependency : dependencies ) + { + if ( StringUtils.isEmpty( dependency.getScope() ) ) + { + // we cannot set this directly in the MDO due to the interactions with dependency management + dependency.setScope( "compile" ); + } + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/normalization/ModelNormalizer.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/normalization/ModelNormalizer.java new file mode 100644 index 00000000..7cab86b6 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/normalization/ModelNormalizer.java @@ -0,0 +1,54 @@ +package org.apache.maven.model.normalization; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles normalization of a model. In this context, normalization is the process of producing a canonical + * representation for models that physically look different but are semantically equivalent. + * + * @author Benjamin Bentmann + */ +public interface ModelNormalizer +{ + + /** + * Merges duplicate elements like multiple declarations of the same build plugin in the specified model. + * + * @param model The model whose duplicate elements should be merged, must not be {@code null}. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void mergeDuplicates( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + + /** + * Sets default values in the specified model that for technical reasons cannot be set directly in the Modello + * definition. + * + * @param model The model in which to set the default values, must not be {@code null}. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void injectDefaultValues( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultModelPathTranslator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultModelPathTranslator.java new file mode 100644 index 00000000..51fa60e6 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultModelPathTranslator.java @@ -0,0 +1,111 @@ +package org.apache.maven.model.path; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.apache.maven.model.Build; +import org.apache.maven.model.Model; +import org.apache.maven.model.Reporting; +import org.apache.maven.model.Resource; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; + +/** + * Resolves relative paths within a model against a specific base directory. + * + * @author Benjamin Bentmann + */ +@Component( role = ModelPathTranslator.class ) +public class DefaultModelPathTranslator + implements ModelPathTranslator +{ + + @Requirement + private PathTranslator pathTranslator; + + public DefaultModelPathTranslator setPathTranslator( PathTranslator pathTranslator ) + { + this.pathTranslator = pathTranslator; + return this; + } + + @Override + public void alignToBaseDirectory( Model model, File basedir, ModelBuildingRequest request ) + { + if ( model == null || basedir == null ) + { + return; + } + + Build build = model.getBuild(); + + if ( build != null ) + { + build.setDirectory( alignToBaseDirectory( build.getDirectory(), basedir ) ); + + build.setSourceDirectory( alignToBaseDirectory( build.getSourceDirectory(), basedir ) ); + + build.setTestSourceDirectory( alignToBaseDirectory( build.getTestSourceDirectory(), basedir ) ); + + build.setScriptSourceDirectory( alignToBaseDirectory( build.getScriptSourceDirectory(), basedir ) ); + + for ( Resource resource : build.getResources() ) + { + resource.setDirectory( alignToBaseDirectory( resource.getDirectory(), basedir ) ); + } + + for ( Resource resource : build.getTestResources() ) + { + resource.setDirectory( alignToBaseDirectory( resource.getDirectory(), basedir ) ); + } + + if ( build.getFilters() != null ) + { + List filters = new ArrayList( build.getFilters().size() ); + for ( String filter : build.getFilters() ) + { + filters.add( alignToBaseDirectory( filter, basedir ) ); + } + build.setFilters( filters ); + } + + build.setOutputDirectory( alignToBaseDirectory( build.getOutputDirectory(), basedir ) ); + + build.setTestOutputDirectory( alignToBaseDirectory( build.getTestOutputDirectory(), basedir ) ); + } + + Reporting reporting = model.getReporting(); + + if ( reporting != null ) + { + reporting.setOutputDirectory( alignToBaseDirectory( reporting.getOutputDirectory(), basedir ) ); + } + } + + private String alignToBaseDirectory( String path, File basedir ) + { + return pathTranslator.alignToBaseDirectory( path, basedir ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultModelUrlNormalizer.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultModelUrlNormalizer.java new file mode 100644 index 00000000..2093f8fb --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultModelUrlNormalizer.java @@ -0,0 +1,84 @@ +package org.apache.maven.model.path; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.DistributionManagement; +import org.apache.maven.model.Model; +import org.apache.maven.model.Scm; +import org.apache.maven.model.Site; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; + +/** + * Normalizes URLs to remove the ugly parent references "../" that got potentially inserted by URL adjustment during + * model inheritance. + * + * @author Benjamin Bentmann + */ +@Component( role = ModelUrlNormalizer.class ) +public class DefaultModelUrlNormalizer + implements ModelUrlNormalizer +{ + + @Requirement + private UrlNormalizer urlNormalizer; + + public DefaultModelUrlNormalizer setUrlNormalizer( UrlNormalizer urlNormalizer ) + { + this.urlNormalizer = urlNormalizer; + return this; + } + + @Override + public void normalize( Model model, ModelBuildingRequest request ) + { + if ( model == null ) + { + return; + } + + model.setUrl( normalize( model.getUrl() ) ); + + Scm scm = model.getScm(); + if ( scm != null ) + { + scm.setUrl( normalize( scm.getUrl() ) ); + scm.setConnection( normalize( scm.getConnection() ) ); + scm.setDeveloperConnection( normalize( scm.getDeveloperConnection() ) ); + } + + DistributionManagement dist = model.getDistributionManagement(); + if ( dist != null ) + { + Site site = dist.getSite(); + if ( site != null ) + { + site.setUrl( normalize( site.getUrl() ) ); + } + } + } + + private String normalize( String url ) + { + return urlNormalizer.normalize( url ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultPathTranslator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultPathTranslator.java new file mode 100644 index 00000000..1ad9d034 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultPathTranslator.java @@ -0,0 +1,66 @@ +package org.apache.maven.model.path; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +import org.codehaus.plexus.component.annotations.Component; + +/** + * Resolves relative paths against a specific base directory. + * + * @author Benjamin Bentmann + */ +@Component( role = PathTranslator.class ) +public class DefaultPathTranslator + implements PathTranslator +{ + + @Override + public String alignToBaseDirectory( String path, File basedir ) + { + String result = path; + + if ( path != null && basedir != null ) + { + path = path.replace( '\\', File.separatorChar ).replace( '/', File.separatorChar ); + + File file = new File( path ); + if ( file.isAbsolute() ) + { + // path was already absolute, just normalize file separator and we're done + result = file.getPath(); + } + else if ( file.getPath().startsWith( File.separator ) ) + { + // drive-relative Windows path, don't align with project directory but with drive root + result = file.getAbsolutePath(); + } + else + { + // an ordinary relative path, align with project directory + result = new File( new File( basedir, path ).toURI().normalize() ).getAbsolutePath(); + } + } + + return result; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultUrlNormalizer.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultUrlNormalizer.java new file mode 100644 index 00000000..120b02f1 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultUrlNormalizer.java @@ -0,0 +1,65 @@ +package org.apache.maven.model.path; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.codehaus.plexus.component.annotations.Component; + +/** + * Normalizes a URL. + * + * @author Benjamin Bentmann + */ +@Component( role = UrlNormalizer.class ) +public class DefaultUrlNormalizer + implements UrlNormalizer +{ + + @Override + public String normalize( String url ) + { + String result = url; + + if ( result != null ) + { + while ( true ) + { + int idx = result.indexOf( "/../" ); + if ( idx <= 0 ) + { + break; + } + int parent = idx - 1; + while ( parent >= 0 && result.charAt( parent ) == '/' ) + { + parent--; + } + parent = result.lastIndexOf( '/', parent ); + if ( parent < 0 ) + { + break; + } + result = result.substring( 0, parent ) + result.substring( idx + 3 ); + } + } + + return result; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/ModelPathTranslator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/ModelPathTranslator.java new file mode 100644 index 00000000..2bd39c55 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/ModelPathTranslator.java @@ -0,0 +1,45 @@ +package org.apache.maven.model.path; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; + +/** + * Resolves relative paths of a model against a specific base directory. + * + * @author Jason van Zyl + */ +public interface ModelPathTranslator +{ + + /** + * Resolves the well-known paths of the specified model against the given base directory. Paths within plugin + * configuration are not processed. + * + * @param model The model whose paths should be resolved, may be {@code null}. + * @param basedir The base directory to resolve relative paths against, may be {@code null}. + * @param request The model building request that holds further settings, must not be {@code null}. + */ + void alignToBaseDirectory( Model model, File basedir, ModelBuildingRequest request ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/ModelUrlNormalizer.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/ModelUrlNormalizer.java new file mode 100644 index 00000000..8325b05d --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/ModelUrlNormalizer.java @@ -0,0 +1,42 @@ +package org.apache.maven.model.path; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; + +/** + * Normalizes URLs to remove the ugly parent references "../" that got potentially inserted by URL adjustment during + * model inheritance. + * + * @author Benjamin Bentmann + */ +public interface ModelUrlNormalizer +{ + + /** + * Normalizes the well-known URLs of the specified model. + * + * @param model The model whose URLs should be normalized, may be {@code null}. + * @param request The model building request that holds further settings, must not be {@code null}. + */ + void normalize( Model model, ModelBuildingRequest request ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/PathTranslator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/PathTranslator.java new file mode 100644 index 00000000..c416e6ab --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/PathTranslator.java @@ -0,0 +1,43 @@ +package org.apache.maven.model.path; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +/** + * Resolves relative paths against a specific base directory. + * + * @author Jason van Zyl + */ +public interface PathTranslator +{ + + /** + * Resolves the specified path against the given base directory. The resolved path will be absolute and uses the + * platform-specific file separator if a base directory is given. Otherwise, the input path will be returned + * unaltered. + * + * @param path The path to resolve, may be {@code null}. + * @param basedir The base directory to resolve relative paths against, may be {@code null}. + * @return The resolved path or {@code null} if the input path was {@code null}. + */ + String alignToBaseDirectory( String path, File basedir ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/UrlNormalizer.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/UrlNormalizer.java new file mode 100644 index 00000000..b2e4a7b1 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/path/UrlNormalizer.java @@ -0,0 +1,39 @@ +package org.apache.maven.model.path; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Normalizes a URL to remove the ugly parent references "../" that got potentially inserted by URL adjustment during + * model inheritance. + * + * @author Benjamin Bentmann + */ +public interface UrlNormalizer +{ + + /** + * Normalizes the specified URL. + * + * @param url The URL to normalize, may be {@code null}. + * @return The normalized URL or {@code null} if the input was {@code null}. + */ + String normalize( String url ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultPluginConfigurationExpander.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultPluginConfigurationExpander.java new file mode 100644 index 00000000..dc7cf13b --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultPluginConfigurationExpander.java @@ -0,0 +1,83 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; + +import org.apache.maven.model.Build; +import org.apache.maven.model.Model; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginExecution; +import org.apache.maven.model.PluginManagement; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.xml.Xpp3Dom; + +/** + * Handles expansion of general build plugin configuration into individual executions. + * + * @author Benjamin Bentmann + */ +@Component( role = PluginConfigurationExpander.class ) +public class DefaultPluginConfigurationExpander + implements PluginConfigurationExpander +{ + + @Override + public void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + Build build = model.getBuild(); + + if ( build != null ) + { + expand( build.getPlugins() ); + + PluginManagement pluginManagement = build.getPluginManagement(); + + if ( pluginManagement != null ) + { + expand( pluginManagement.getPlugins() ); + } + } + } + + private void expand( List plugins ) + { + for ( Plugin plugin : plugins ) + { + Xpp3Dom pluginConfiguration = (Xpp3Dom) plugin.getConfiguration(); + + if ( pluginConfiguration != null ) + { + for ( PluginExecution execution : plugin.getExecutions() ) + { + Xpp3Dom executionConfiguration = (Xpp3Dom) execution.getConfiguration(); + + executionConfiguration = + Xpp3Dom.mergeXpp3Dom( executionConfiguration, new Xpp3Dom( pluginConfiguration ) ); + + execution.setConfiguration( executionConfiguration ); + } + } + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportConfigurationExpander.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportConfigurationExpander.java new file mode 100644 index 00000000..9c842994 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportConfigurationExpander.java @@ -0,0 +1,65 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.ReportSet; +import org.apache.maven.model.Reporting; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.xml.Xpp3Dom; + +/** + * Handles expansion of general report plugin configuration into individual report sets. + * + * @author Benjamin Bentmann + */ +@Component( role = ReportConfigurationExpander.class ) +public class DefaultReportConfigurationExpander + implements ReportConfigurationExpander +{ + + @Override + public void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + Reporting reporting = model.getReporting(); + + if ( reporting != null ) + { + for ( ReportPlugin reportPlugin : reporting.getPlugins() ) + { + Xpp3Dom parentDom = (Xpp3Dom) reportPlugin.getConfiguration(); + + if ( parentDom != null ) + { + for ( ReportSet execution : reportPlugin.getReportSets() ) + { + Xpp3Dom childDom = (Xpp3Dom) execution.getConfiguration(); + childDom = Xpp3Dom.mergeXpp3Dom( childDom, new Xpp3Dom( parentDom ) ); + execution.setConfiguration( childDom ); + } + } + } + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java new file mode 100644 index 00000000..d918d9e8 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java @@ -0,0 +1,240 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Build; +import org.apache.maven.model.Model; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginManagement; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.ReportSet; +import org.apache.maven.model.Reporting; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.xml.Xpp3Dom; + +/** + * Handles conversion of the legacy reporting section into the configuration of the new Maven Site Plugin. + * + * @author Benjamin Bentmann + */ +@Component( role = ReportingConverter.class ) +public class DefaultReportingConverter + implements ReportingConverter +{ + + @Override + public void convertReporting( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + Reporting reporting = model.getReporting(); + + if ( reporting == null ) + { + return; + } + + Build build = model.getBuild(); + + if ( build == null ) + { + build = new Build(); + model.setBuild( build ); + } + + Plugin sitePlugin = findSitePlugin( build ); + + if ( sitePlugin == null ) + { + sitePlugin = new Plugin(); + sitePlugin.setArtifactId( "maven-site-plugin" ); + PluginManagement pluginManagement = build.getPluginManagement(); + if ( pluginManagement == null ) + { + pluginManagement = new PluginManagement(); + build.setPluginManagement( pluginManagement ); + } + pluginManagement.addPlugin( sitePlugin ); + } + + Xpp3Dom configuration = (Xpp3Dom) sitePlugin.getConfiguration(); + + if ( configuration == null ) + { + configuration = new Xpp3Dom( "configuration" ); + sitePlugin.setConfiguration( configuration ); + } + + Xpp3Dom reportPlugins = configuration.getChild( "reportPlugins" ); + + if ( reportPlugins != null ) + { + // new-style report configuration already present, assume user handled entire conversion + return; + } + + if ( configuration.getChild( "outputDirectory" ) == null ) + { + addDom( configuration, "outputDirectory", reporting.getOutputDirectory() ); + } + + reportPlugins = new Xpp3Dom( "reportPlugins" ); + configuration.addChild( reportPlugins ); + + boolean hasMavenProjectInfoReportsPlugin = false; + + /* waiting for MSITE-484 before deprecating section + if ( !reporting.getPlugins().isEmpty() + && request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 ) + { + + problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V31 ) + .setMessage( "The section is deprecated, please move the reports to the " + + " section of the new Maven Site Plugin." ) + .setLocation( reporting.getLocation( "" ) ) ); + }*/ + + for ( ReportPlugin plugin : reporting.getPlugins() ) + { + Xpp3Dom reportPlugin = convert( plugin ); + reportPlugins.addChild( reportPlugin ); + + if ( !reporting.isExcludeDefaults() && !hasMavenProjectInfoReportsPlugin + && "org.apache.maven.plugins".equals( plugin.getGroupId() ) + && "maven-project-info-reports-plugin".equals( plugin.getArtifactId() ) ) + { + hasMavenProjectInfoReportsPlugin = true; + } + } + + if ( !reporting.isExcludeDefaults() && !hasMavenProjectInfoReportsPlugin ) + { + Xpp3Dom dom = new Xpp3Dom( "reportPlugin" ); + + addDom( dom, "groupId", "org.apache.maven.plugins" ); + addDom( dom, "artifactId", "maven-project-info-reports-plugin" ); + + reportPlugins.addChild( dom ); + } + } + + private Plugin findSitePlugin( Build build ) + { + for ( Plugin plugin : build.getPlugins() ) + { + if ( isSitePlugin( plugin ) ) + { + return plugin; + } + } + + PluginManagement pluginManagement = build.getPluginManagement(); + if ( pluginManagement != null ) + { + for ( Plugin plugin : pluginManagement.getPlugins() ) + { + if ( isSitePlugin( plugin ) ) + { + return plugin; + } + } + } + + return null; + } + + private boolean isSitePlugin( Plugin plugin ) + { + return "maven-site-plugin".equals( plugin.getArtifactId() ) + && "org.apache.maven.plugins".equals( plugin.getGroupId() ); + } + + private Xpp3Dom convert( ReportPlugin plugin ) + { + Xpp3Dom dom = new Xpp3Dom( "reportPlugin" ); + + addDom( dom, "groupId", plugin.getGroupId() ); + addDom( dom, "artifactId", plugin.getArtifactId() ); + addDom( dom, "version", plugin.getVersion() ); + + Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration(); + if ( configuration != null ) + { + configuration = new Xpp3Dom( configuration ); + dom.addChild( configuration ); + } + + if ( !plugin.getReportSets().isEmpty() ) + { + Xpp3Dom reportSets = new Xpp3Dom( "reportSets" ); + for ( ReportSet reportSet : plugin.getReportSets() ) + { + Xpp3Dom rs = convert( reportSet ); + reportSets.addChild( rs ); + } + dom.addChild( reportSets ); + } + + return dom; + } + + private Xpp3Dom convert( ReportSet reportSet ) + { + Xpp3Dom dom = new Xpp3Dom( "reportSet" ); + + addDom( dom, "id", reportSet.getId() ); + + Xpp3Dom configuration = (Xpp3Dom) reportSet.getConfiguration(); + if ( configuration != null ) + { + configuration = new Xpp3Dom( configuration ); + dom.addChild( configuration ); + } + + if ( !reportSet.getReports().isEmpty() ) + { + Xpp3Dom reports = new Xpp3Dom( "reports" ); + for ( String report : reportSet.getReports() ) + { + addDom( reports, "report", report ); + } + dom.addChild( reports ); + } + + return dom; + } + + private void addDom( Xpp3Dom parent, String childName, String childValue ) + { + if ( StringUtils.isNotEmpty( childValue ) ) + { + parent.addChild( newDom( childName, childValue ) ); + } + } + + private Xpp3Dom newDom( String name, String value ) + { + Xpp3Dom dom = new Xpp3Dom( name ); + dom.setValue( value ); + return dom; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/LifecycleBindingsInjector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/LifecycleBindingsInjector.java new file mode 100644 index 00000000..9c0f06de --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/LifecycleBindingsInjector.java @@ -0,0 +1,46 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles injection of plugin executions induced by the lifecycle bindings for a packaging. + * + * @author Benjamin Bentmann + */ +public interface LifecycleBindingsInjector +{ + + /** + * Injects plugin executions induced by lifecycle bindings into the specified model. The model has already undergone + * injection of plugin management so any plugins that are injected by lifecycle bindings and are not already present + * in the model's plugin section need to be subjected to the model's plugin management. + * + * @param model The model into which to inject the default plugin executions for its packaging, must not be + * null. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void injectLifecycleBindings( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/PluginConfigurationExpander.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/PluginConfigurationExpander.java new file mode 100644 index 00000000..23994aa6 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/PluginConfigurationExpander.java @@ -0,0 +1,43 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles expansion of general build plugin configuration into individual executions. + * + * @author Benjamin Bentmann + */ +public interface PluginConfigurationExpander +{ + + /** + * Merges values from general build plugin configuration into the individual plugin executions of the given model. + * + * @param model The model whose build plugin configuration should be expanded, must not be null. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportConfigurationExpander.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportConfigurationExpander.java new file mode 100644 index 00000000..28ad5962 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportConfigurationExpander.java @@ -0,0 +1,43 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles expansion of general report plugin configuration into individual report sets. + * + * @author Benjamin Bentmann + */ +public interface ReportConfigurationExpander +{ + + /** + * Merges values from general report plugin configuration into the individual reports sets of the given model. + * + * @param model The model whose report plugin configuration should be expanded, must not be null. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java new file mode 100644 index 00000000..c5ea338c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java @@ -0,0 +1,43 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles conversion of the legacy reporting section into the configuration of the new Maven Site Plugin. + * + * @author Benjamin Bentmann + */ +public interface ReportingConverter +{ + + /** + * Converts values from model's reporting section into the configuration for the new Maven Site Plugin. + * + * @param model The model whose reporting section should be converted, must not be null. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void convertReporting( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java new file mode 100644 index 00000000..bb38a2e0 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java @@ -0,0 +1,259 @@ +package org.apache.maven.model.profile; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * Describes the environmental context used to determine the activation status of profiles. + * + * @author Benjamin Bentmann + */ +public class DefaultProfileActivationContext + implements ProfileActivationContext +{ + + private List activeProfileIds = Collections.emptyList(); + + private List inactiveProfileIds = Collections.emptyList(); + + private Map systemProperties = Collections.emptyMap(); + + private Map userProperties = Collections.emptyMap(); + + private Map projectProperties = Collections.emptyMap(); + + private File projectDirectory; + + @Override + public List getActiveProfileIds() + { + return activeProfileIds; + } + + /** + * Sets the identifiers of those profiles that should be activated by explicit demand. + * + * @param activeProfileIds The identifiers of those profiles to activate, may be {@code null}. + * @return This context, never {@code null}. + */ + public DefaultProfileActivationContext setActiveProfileIds( List activeProfileIds ) + { + if ( activeProfileIds != null ) + { + this.activeProfileIds = Collections.unmodifiableList( activeProfileIds ); + } + else + { + this.activeProfileIds = Collections.emptyList(); + } + + return this; + } + + @Override + public List getInactiveProfileIds() + { + return inactiveProfileIds; + } + + /** + * Sets the identifiers of those profiles that should be deactivated by explicit demand. + * + * @param inactiveProfileIds The identifiers of those profiles to deactivate, may be {@code null}. + * @return This context, never {@code null}. + */ + public DefaultProfileActivationContext setInactiveProfileIds( List inactiveProfileIds ) + { + if ( inactiveProfileIds != null ) + { + this.inactiveProfileIds = Collections.unmodifiableList( inactiveProfileIds ); + } + else + { + this.inactiveProfileIds = Collections.emptyList(); + } + + return this; + } + + @Override + public Map getSystemProperties() + { + return systemProperties; + } + + /** + * Sets the system properties to use for interpolation and profile activation. The system properties are collected + * from the runtime environment like {@link System#getProperties()} and environment variables. + * + * @param systemProperties The system properties, may be {@code null}. + * @return This context, never {@code null}. + */ + @SuppressWarnings( "unchecked" ) + public DefaultProfileActivationContext setSystemProperties( Properties systemProperties ) + { + if ( systemProperties != null ) + { + this.systemProperties = Collections.unmodifiableMap( (Map) systemProperties ); + } + else + { + this.systemProperties = Collections.emptyMap(); + } + + return this; + } + + /** + * Sets the system properties to use for interpolation and profile activation. The system properties are collected + * from the runtime environment like {@link System#getProperties()} and environment variables. + * + * @param systemProperties The system properties, may be {@code null}. + * @return This context, never {@code null}. + */ + public DefaultProfileActivationContext setSystemProperties( Map systemProperties ) + { + if ( systemProperties != null ) + { + this.systemProperties = Collections.unmodifiableMap( systemProperties ); + } + else + { + this.systemProperties = Collections.emptyMap(); + } + + return this; + } + + @Override + public Map getUserProperties() + { + return userProperties; + } + + /** + * Sets the user properties to use for interpolation and profile activation. The user properties have been + * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command + * line. + * + * @param userProperties The user properties, may be {@code null}. + * @return This context, never {@code null}. + */ + @SuppressWarnings( "unchecked" ) + public DefaultProfileActivationContext setUserProperties( Properties userProperties ) + { + if ( userProperties != null ) + { + this.userProperties = Collections.unmodifiableMap( (Map) userProperties ); + } + else + { + this.userProperties = Collections.emptyMap(); + } + + return this; + } + + /** + * Sets the user properties to use for interpolation and profile activation. The user properties have been + * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command + * line. + * + * @param userProperties The user properties, may be {@code null}. + * @return This context, never {@code null}. + */ + public DefaultProfileActivationContext setUserProperties( Map userProperties ) + { + if ( userProperties != null ) + { + this.userProperties = Collections.unmodifiableMap( userProperties ); + } + else + { + this.userProperties = Collections.emptyMap(); + } + + return this; + } + + @Override + public File getProjectDirectory() + { + return projectDirectory; + } + + /** + * Sets the base directory of the current project. + * + * @param projectDirectory The base directory of the current project, may be {@code null} if profile activation + * happens in the context of metadata retrieval rather than project building. + * @return This context, never {@code null}. + */ + public DefaultProfileActivationContext setProjectDirectory( File projectDirectory ) + { + this.projectDirectory = projectDirectory; + + return this; + } + + @Override + public Map getProjectProperties() + { + return projectProperties; + } + + public DefaultProfileActivationContext setProjectProperties( Properties projectProperties ) + { + if ( projectProperties != null ) + { + + this.projectProperties = Collections.unmodifiableMap( toMap( projectProperties ) ); + } + else + { + this.projectProperties = Collections.emptyMap(); + } + + return this; + } + + private Map toMap( Properties properties ) + { + if ( properties == null ) + { + return Collections.emptyMap(); + } + Map map = new HashMap(); + Enumeration keys = properties.keys(); + while ( keys.hasMoreElements() ) + { + String key = (String) keys.nextElement(); + map.put( key, properties.getProperty( key ) ); + } + return map; + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java new file mode 100644 index 00000000..aeed0235 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java @@ -0,0 +1,249 @@ +package org.apache.maven.model.profile; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.maven.model.Build; +import org.apache.maven.model.BuildBase; +import org.apache.maven.model.Model; +import org.apache.maven.model.ModelBase; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginContainer; +import org.apache.maven.model.PluginExecution; +import org.apache.maven.model.Profile; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.ReportSet; +import org.apache.maven.model.Reporting; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.merge.MavenModelMerger; +import org.codehaus.plexus.component.annotations.Component; + +/** + * Handles profile injection into the model. + * + * @author Benjamin Bentmann + */ +@Component( role = ProfileInjector.class ) +public class DefaultProfileInjector + implements ProfileInjector +{ + + private ProfileModelMerger merger = new ProfileModelMerger(); + + @Override + public void injectProfile( Model model, Profile profile, ModelBuildingRequest request, + ModelProblemCollector problems ) + { + if ( profile != null ) + { + merger.mergeModelBase( model, profile ); + + if ( profile.getBuild() != null ) + { + if ( model.getBuild() == null ) + { + model.setBuild( new Build() ); + } + merger.mergeBuildBase( model.getBuild(), profile.getBuild() ); + } + } + } + + protected static class ProfileModelMerger + extends MavenModelMerger + { + + public void mergeModelBase( ModelBase target, ModelBase source ) + { + mergeModelBase( target, source, true, Collections.emptyMap() ); + } + + public void mergeBuildBase( BuildBase target, BuildBase source ) + { + mergeBuildBase( target, source, true, Collections.emptyMap() ); + } + + @Override + protected void mergePluginContainer_Plugins( PluginContainer target, PluginContainer source, + boolean sourceDominant, Map context ) + { + List src = source.getPlugins(); + if ( !src.isEmpty() ) + { + List tgt = target.getPlugins(); + Map master = new LinkedHashMap( tgt.size() * 2 ); + + for ( Plugin element : tgt ) + { + Object key = getPluginKey( element ); + master.put( key, element ); + } + + Map> predecessors = new LinkedHashMap>(); + List pending = new ArrayList(); + for ( Plugin element : src ) + { + Object key = getPluginKey( element ); + Plugin existing = master.get( key ); + if ( existing != null ) + { + mergePlugin( existing, element, sourceDominant, context ); + + if ( !pending.isEmpty() ) + { + predecessors.put( key, pending ); + pending = new ArrayList(); + } + } + else + { + pending.add( element ); + } + } + + List result = new ArrayList( src.size() + tgt.size() ); + for ( Map.Entry entry : master.entrySet() ) + { + List pre = predecessors.get( entry.getKey() ); + if ( pre != null ) + { + result.addAll( pre ); + } + result.add( entry.getValue() ); + } + result.addAll( pending ); + + target.setPlugins( result ); + } + } + + @Override + protected void mergePlugin_Executions( Plugin target, Plugin source, boolean sourceDominant, + Map context ) + { + List src = source.getExecutions(); + if ( !src.isEmpty() ) + { + List tgt = target.getExecutions(); + Map merged = + new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); + + for ( PluginExecution element : tgt ) + { + Object key = getPluginExecutionKey( element ); + merged.put( key, element ); + } + + for ( PluginExecution element : src ) + { + Object key = getPluginExecutionKey( element ); + PluginExecution existing = merged.get( key ); + if ( existing != null ) + { + mergePluginExecution( existing, element, sourceDominant, context ); + } + else + { + merged.put( key, element ); + } + } + + target.setExecutions( new ArrayList( merged.values() ) ); + } + } + + @Override + protected void mergeReporting_Plugins( Reporting target, Reporting source, boolean sourceDominant, + Map context ) + { + List src = source.getPlugins(); + if ( !src.isEmpty() ) + { + List tgt = target.getPlugins(); + Map merged = + new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); + + for ( ReportPlugin element : tgt ) + { + Object key = getReportPluginKey( element ); + merged.put( key, element ); + } + + for ( ReportPlugin element : src ) + { + Object key = getReportPluginKey( element ); + ReportPlugin existing = merged.get( key ); + if ( existing == null ) + { + merged.put( key, element ); + } + else + { + mergeReportPlugin( existing, element, sourceDominant, context ); + } + } + + target.setPlugins( new ArrayList( merged.values() ) ); + } + } + + @Override + protected void mergeReportPlugin_ReportSets( ReportPlugin target, ReportPlugin source, boolean sourceDominant, + Map context ) + { + List src = source.getReportSets(); + if ( !src.isEmpty() ) + { + List tgt = target.getReportSets(); + Map merged = new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); + + for ( ReportSet element : tgt ) + { + Object key = getReportSetKey( element ); + merged.put( key, element ); + } + + for ( ReportSet element : src ) + { + Object key = getReportSetKey( element ); + ReportSet existing = merged.get( key ); + if ( existing != null ) + { + mergeReportSet( existing, element, sourceDominant, context ); + } + else + { + merged.put( key, element ); + } + } + + target.setReportSets( new ArrayList( merged.values() ) ); + } + } + + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java new file mode 100644 index 00000000..512476a1 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java @@ -0,0 +1,143 @@ +package org.apache.maven.model.profile; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; + +import org.apache.maven.model.Activation; +import org.apache.maven.model.Profile; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.building.ModelProblem.Severity; +import org.apache.maven.model.building.ModelProblem.Version; +import org.apache.maven.model.building.ModelProblemCollectorRequest; +import org.apache.maven.model.profile.activation.ProfileActivator; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; + +/** + * Calculates the active profiles among a given collection of profiles. + * + * @author Benjamin Bentmann + */ +@Component( role = ProfileSelector.class ) +public class DefaultProfileSelector + implements ProfileSelector +{ + + @Requirement( role = ProfileActivator.class ) + private List activators = new ArrayList(); + + public DefaultProfileSelector addProfileActivator( ProfileActivator profileActivator ) + { + if ( profileActivator != null ) + { + activators.add( profileActivator ); + } + return this; + } + + @Override + public List getActiveProfiles( Collection profiles, ProfileActivationContext context, + ModelProblemCollector problems ) + { + Collection activatedIds = new HashSet( context.getActiveProfileIds() ); + Collection deactivatedIds = new HashSet( context.getInactiveProfileIds() ); + + List activeProfiles = new ArrayList( profiles.size() ); + List activePomProfilesByDefault = new ArrayList(); + boolean activatedPomProfileNotByDefault = false; + + for ( Profile profile : profiles ) + { + if ( !deactivatedIds.contains( profile.getId() ) ) + { + if ( activatedIds.contains( profile.getId() ) || isActive( profile, context, problems ) ) + { + activeProfiles.add( profile ); + + if ( Profile.SOURCE_POM.equals( profile.getSource() ) ) + { + activatedPomProfileNotByDefault = true; + } + } + else if ( isActiveByDefault( profile ) ) + { + if ( Profile.SOURCE_POM.equals( profile.getSource() ) ) + { + activePomProfilesByDefault.add( profile ); + } + else + { + activeProfiles.add( profile ); + } + } + + } + } + + if ( !activatedPomProfileNotByDefault ) + { + activeProfiles.addAll( activePomProfilesByDefault ); + } + + return activeProfiles; + } + + private boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) + { + boolean isActive = false; + for ( ProfileActivator activator : activators ) + { + if ( activator.presentInConfig( profile, context, problems ) ) + { + isActive = true; + } + } + for ( ProfileActivator activator : activators ) + { + try + { + if ( activator.presentInConfig( profile, context, problems ) ) + { + isActive &= activator.isActive( profile, context, problems ); + } + } + catch ( RuntimeException e ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "Failed to determine activation for profile " + profile.getId() ) + .setLocation( profile.getLocation( "" ) ) + .setException( e ) ); + return false; + } + } + return isActive; + } + + private boolean isActiveByDefault( Profile profile ) + { + Activation activation = profile.getActivation(); + return activation != null && activation.isActiveByDefault(); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java new file mode 100644 index 00000000..d501e660 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java @@ -0,0 +1,79 @@ +package org.apache.maven.model.profile; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.List; +import java.util.Map; + +/** + * Describes the environmental context used to determine the activation status of profiles. + * + * @author Benjamin Bentmann + */ +public interface ProfileActivationContext +{ + + /** + * Gets the identifiers of those profiles that should be activated by explicit demand. + * + * @return The identifiers of those profiles to activate, never {@code null}. + */ + List getActiveProfileIds(); + + /** + * Gets the identifiers of those profiles that should be deactivated by explicit demand. + * + * @return The identifiers of those profiles to deactivate, never {@code null}. + */ + List getInactiveProfileIds(); + + /** + * Gets the system properties to use for interpolation and profile activation. The system properties are collected + * from the runtime environment like {@link System#getProperties()} and environment variables. + * + * @return The execution properties, never {@code null}. + */ + Map getSystemProperties(); + + /** + * Gets the user properties to use for interpolation and profile activation. The user properties have been + * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command + * line. + * + * @return The user properties, never {@code null}. + */ + Map getUserProperties(); + + /** + * Gets the base directory of the current project (if any). + * + * @return The base directory of the current project or {@code null} if none. + */ + File getProjectDirectory(); + + /** + * Gets current calculated project properties + * + * @return The project properties, never {@code null}. + */ + Map getProjectProperties(); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileInjector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileInjector.java new file mode 100644 index 00000000..fbd7ddf0 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileInjector.java @@ -0,0 +1,46 @@ +package org.apache.maven.model.profile; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.Profile; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles profile injection into the model. + * + * @author Benjamin Bentmann + */ +public interface ProfileInjector +{ + + /** + * Merges values from the specified profile into the given model. Implementations are expected to keep the profile + * and model completely decoupled by injecting deep copies rather than the original objects from the profile. + * + * @param model The model into which to merge the values defined by the profile, must not be null. + * @param profile The (read-only) profile whose values should be injected, may be null. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void injectProfile( Model model, Profile profile, ModelBuildingRequest request, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileSelector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileSelector.java new file mode 100644 index 00000000..53ea8d9c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileSelector.java @@ -0,0 +1,49 @@ +package org.apache.maven.model.profile; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Collection; +import java.util.List; + +import org.apache.maven.model.Profile; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Calculates the active profiles among a given collection of profiles. + * + * @author Benjamin Bentmann + */ +public interface ProfileSelector +{ + + /** + * Determines the profiles which are active in the specified activation context. Active profiles will eventually be + * injected into the model. + * + * @param profiles The profiles whose activation status should be determined, must not be {@code null}. + * @param context The environmental context used to determine the activation status of a profile, must not be + * {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + * @return The profiles that have been activated, never {@code null}. + */ + List getActiveProfiles( Collection profiles, ProfileActivationContext context, + ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java new file mode 100644 index 00000000..c0dcce23 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java @@ -0,0 +1,192 @@ +package org.apache.maven.model.profile.activation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +import org.apache.maven.model.Activation; +import org.apache.maven.model.ActivationFile; +import org.apache.maven.model.Profile; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.building.ModelProblem.Severity; +import org.apache.maven.model.building.ModelProblem.Version; +import org.apache.maven.model.building.ModelProblemCollectorRequest; +import org.apache.maven.model.path.PathTranslator; +import org.apache.maven.model.profile.ProfileActivationContext; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.interpolation.AbstractValueSource; +import org.codehaus.plexus.interpolation.MapBasedValueSource; +import org.codehaus.plexus.interpolation.RegexBasedInterpolator; +import org.codehaus.plexus.util.StringUtils; + +/** + * Determines profile activation based on the existence/absence of some file. + * File name interpolation support is limited to ${basedir} (since Maven 3, + * see MNG-2363), + * System properties and request properties. + * ${project.basedir} is intentionally not supported as this form would suggest that other + * ${project.*} expressions can be used, which is however beyond the design. + * + * @author Benjamin Bentmann + * @see ActivationFile + * @see org.apache.maven.model.validation.DefaultModelValidator#validateRawModel + */ +@Component( role = ProfileActivator.class, hint = "file" ) +public class FileProfileActivator + implements ProfileActivator +{ + + @Requirement + private PathTranslator pathTranslator; + + public FileProfileActivator setPathTranslator( PathTranslator pathTranslator ) + { + this.pathTranslator = pathTranslator; + return this; + } + + @Override + public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) + { + Activation activation = profile.getActivation(); + + if ( activation == null ) + { + return false; + } + + ActivationFile file = activation.getFile(); + + if ( file == null ) + { + return false; + } + + String path; + boolean missing; + + if ( StringUtils.isNotEmpty( file.getExists() ) ) + { + path = file.getExists(); + missing = false; + } + else if ( StringUtils.isNotEmpty( file.getMissing() ) ) + { + path = file.getMissing(); + missing = true; + } + else + { + return false; + } + + RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); + + final File basedir = context.getProjectDirectory(); + + if ( basedir != null ) + { + interpolator.addValueSource( new AbstractValueSource( false ) + { + @Override + public Object getValue( String expression ) + { + /* + * NOTE: We intentionally only support ${basedir} and not ${project.basedir} as the latter form + * would suggest that other project.* expressions can be used which is however beyond the design. + */ + if ( "basedir".equals( expression ) ) + { + return basedir.getAbsolutePath(); + } + return null; + } + } ); + } + else if ( path.contains( "${basedir}" ) ) + { + return false; + } + + interpolator.addValueSource( new MapBasedValueSource( context.getProjectProperties() ) ); + + interpolator.addValueSource( new MapBasedValueSource( context.getUserProperties() ) ); + + interpolator.addValueSource( new MapBasedValueSource( context.getSystemProperties() ) ); + + try + { + path = interpolator.interpolate( path, "" ); + } + catch ( Exception e ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "Failed to interpolate file location " + path + " for profile " + profile.getId() + + ": " + e.getMessage() ) + .setLocation( file.getLocation( missing ? "missing" : "exists" ) ) + .setException( e ) ); + return false; + } + + path = pathTranslator.alignToBaseDirectory( path, basedir ); + + // replace activation value with interpolated value + if ( missing ) + { + file.setMissing( path ); + } + else + { + file.setExists( path ); + } + + File f = new File( path ); + + if ( !f.isAbsolute() ) + { + return false; + } + + boolean fileExists = f.exists(); + + return missing ? !fileExists : fileExists; + } + + @Override + public boolean presentInConfig( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) + { + Activation activation = profile.getActivation(); + + if ( activation == null ) + { + return false; + } + + ActivationFile file = activation.getFile(); + + if ( file == null ) + { + return false; + } + return true; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java new file mode 100644 index 00000000..e981bfd3 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java @@ -0,0 +1,224 @@ +package org.apache.maven.model.profile.activation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.maven.model.Activation; +import org.apache.maven.model.Profile; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.building.ModelProblem.Severity; +import org.apache.maven.model.building.ModelProblem.Version; +import org.apache.maven.model.building.ModelProblemCollectorRequest; +import org.apache.maven.model.profile.ProfileActivationContext; +import org.codehaus.plexus.component.annotations.Component; + +/** + * Determines profile activation based on the version of the current Java runtime. + * + * @author Benjamin Bentmann + * @see Activation#getJdk() + */ +@Component( role = ProfileActivator.class, hint = "jdk-version" ) +public class JdkVersionProfileActivator + implements ProfileActivator +{ + + @Override + public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) + { + Activation activation = profile.getActivation(); + + if ( activation == null ) + { + return false; + } + + String jdk = activation.getJdk(); + + if ( jdk == null ) + { + return false; + } + + String version = context.getSystemProperties().get( "java.version" ); + + if ( version == null || version.length() <= 0 ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "Failed to determine Java version for profile " + profile.getId() ) + .setLocation( activation.getLocation( "jdk" ) ) ); + return false; + } + + if ( jdk.startsWith( "!" ) ) + { + return !version.startsWith( jdk.substring( 1 ) ); + } + else if ( isRange( jdk ) ) + { + return isInRange( version, getRange( jdk ) ); + } + else + { + return version.startsWith( jdk ); + } + } + + @Override + public boolean presentInConfig( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) + { + Activation activation = profile.getActivation(); + + if ( activation == null ) + { + return false; + } + + String jdk = activation.getJdk(); + + if ( jdk == null ) + { + return false; + } + return true; + } + + private static boolean isInRange( String value, List range ) + { + int leftRelation = getRelationOrder( value, range.get( 0 ), true ); + + if ( leftRelation == 0 ) + { + return true; + } + + if ( leftRelation < 0 ) + { + return false; + } + + return getRelationOrder( value, range.get( 1 ), false ) <= 0; + } + + private static int getRelationOrder( String value, RangeValue rangeValue, boolean isLeft ) + { + if ( rangeValue.value.length() <= 0 ) + { + return isLeft ? 1 : -1; + } + + value = value.replaceAll( "[^0-9\\.\\-\\_]", "" ); + + List valueTokens = new ArrayList( Arrays.asList( value.split( "[\\.\\-\\_]" ) ) ); + List rangeValueTokens = new ArrayList( Arrays.asList( rangeValue.value.split( "\\." ) ) ); + + addZeroTokens( valueTokens, 3 ); + addZeroTokens( rangeValueTokens, 3 ); + + for ( int i = 0; i < 3; i++ ) + { + int x = Integer.parseInt( valueTokens.get( i ) ); + int y = Integer.parseInt( rangeValueTokens.get( i ) ); + if ( x < y ) + { + return -1; + } + else if ( x > y ) + { + return 1; + } + } + if ( !rangeValue.closed ) + { + return isLeft ? -1 : 1; + } + return 0; + } + + private static void addZeroTokens( List tokens, int max ) + { + while ( tokens.size() < max ) + { + tokens.add( "0" ); + } + } + + private static boolean isRange( String value ) + { + return value.startsWith( "[" ) || value.startsWith( "(" ); + } + + private static List getRange( String range ) + { + List ranges = new ArrayList(); + + for ( String token : range.split( "," ) ) + { + if ( token.startsWith( "[" ) ) + { + ranges.add( new RangeValue( token.replace( "[", "" ), true ) ); + } + else if ( token.startsWith( "(" ) ) + { + ranges.add( new RangeValue( token.replace( "(", "" ), false ) ); + } + else if ( token.endsWith( "]" ) ) + { + ranges.add( new RangeValue( token.replace( "]", "" ), true ) ); + } + else if ( token.endsWith( ")" ) ) + { + ranges.add( new RangeValue( token.replace( ")", "" ), false ) ); + } + else if ( token.length() <= 0 ) + { + ranges.add( new RangeValue( "", false ) ); + } + } + if ( ranges.size() < 2 ) + { + ranges.add( new RangeValue( "99999999", false ) ); + } + return ranges; + } + + private static class RangeValue + { + private String value; + + private boolean closed; + + RangeValue( String value, boolean closed ) + { + this.value = value.trim(); + this.closed = closed; + } + + @Override + public String toString() + { + return value; + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java new file mode 100644 index 00000000..30abb1fa --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java @@ -0,0 +1,168 @@ +package org.apache.maven.model.profile.activation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Activation; +import org.apache.maven.model.ActivationOS; +import org.apache.maven.model.Profile; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.profile.ProfileActivationContext; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.Os; + +/** + * Determines profile activation based on the operating system of the current runtime platform. + * + * @author Benjamin Bentmann + * @see ActivationOS + */ +@Component( role = ProfileActivator.class, hint = "os" ) +public class OperatingSystemProfileActivator + implements ProfileActivator +{ + + @Override + public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) + { + Activation activation = profile.getActivation(); + + if ( activation == null ) + { + return false; + } + + ActivationOS os = activation.getOs(); + + if ( os == null ) + { + return false; + } + + boolean active = ensureAtLeastOneNonNull( os ); + + if ( active && os.getFamily() != null ) + { + active = determineFamilyMatch( os.getFamily() ); + } + if ( active && os.getName() != null ) + { + active = determineNameMatch( os.getName() ); + } + if ( active && os.getArch() != null ) + { + active = determineArchMatch( os.getArch() ); + } + if ( active && os.getVersion() != null ) + { + active = determineVersionMatch( os.getVersion() ); + } + + return active; + } + + @Override + public boolean presentInConfig( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) + { + Activation activation = profile.getActivation(); + + if ( activation == null ) + { + return false; + } + + ActivationOS os = activation.getOs(); + + if ( os == null ) + { + return false; + } + return true; + } + + private boolean ensureAtLeastOneNonNull( ActivationOS os ) + { + return os.getArch() != null || os.getFamily() != null || os.getName() != null || os.getVersion() != null; + } + + private boolean determineVersionMatch( String version ) + { + String test = version; + boolean reverse = false; + + if ( test.startsWith( "!" ) ) + { + reverse = true; + test = test.substring( 1 ); + } + + boolean result = Os.isVersion( test ); + + return reverse ? !result : result; + } + + private boolean determineArchMatch( String arch ) + { + String test = arch; + boolean reverse = false; + + if ( test.startsWith( "!" ) ) + { + reverse = true; + test = test.substring( 1 ); + } + + boolean result = Os.isArch( test ); + + return reverse ? !result : result; + } + + private boolean determineNameMatch( String name ) + { + String test = name; + boolean reverse = false; + + if ( test.startsWith( "!" ) ) + { + reverse = true; + test = test.substring( 1 ); + } + + boolean result = Os.isName( test ); + + return reverse ? !result : result; + } + + private boolean determineFamilyMatch( String family ) + { + String test = family; + boolean reverse = false; + + if ( test.startsWith( "!" ) ) + { + reverse = true; + test = test.substring( 1 ); + } + + boolean result = Os.isFamily( test ); + + return reverse ? !result : result; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java new file mode 100644 index 00000000..0547e742 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java @@ -0,0 +1,59 @@ +package org.apache.maven.model.profile.activation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Profile; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.profile.ProfileActivationContext; + +/** + * Determines whether a profile should be activated. + * + * @author Benjamin Bentmann + */ +public interface ProfileActivator +{ + + /** + * Determines whether the specified profile is active in the given activator context. + * + * @param profile The profile whose activation status should be determined, must not be {@code null}. + * @param context The environmental context used to determine the activation status of the profile, must not be + * {@code null}. + * @param problems The container used to collect problems (e.g. bad syntax) that were encountered, must not be + * {@code null}. + * @return {@code true} if the profile is active, {@code false} otherwise. + */ + boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ); + + /** + * Determines whether specified activation method is present in configuration or not. It should help to have AND + * between activation conditions + * Need for solving http://jira.codehaus.org/browse/MNG-4565 + * @param profile The profile whose activation status should be determined, must not be {@code null}. + * @param context The environmental context used to determine the activation status of the profile, must not be + * {@code null}. + * @param problems The container used to collect problems (e.g. bad syntax) that were encountered, must not be + * {@code null}. + * @return {@code true} if the profile is active, {@code false} otherwise. + */ + boolean presentInConfig( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java new file mode 100644 index 00000000..ba7886f0 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java @@ -0,0 +1,126 @@ +package org.apache.maven.model.profile.activation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Activation; +import org.apache.maven.model.ActivationProperty; +import org.apache.maven.model.Profile; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.building.ModelProblem.Severity; +import org.apache.maven.model.building.ModelProblem.Version; +import org.apache.maven.model.building.ModelProblemCollectorRequest; +import org.apache.maven.model.profile.ProfileActivationContext; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.StringUtils; + +/** + * Determines profile activation based on the existence or value of some execution property. + * + * @author Benjamin Bentmann + * @see ActivationProperty + */ +@Component( role = ProfileActivator.class, hint = "property" ) +public class PropertyProfileActivator + implements ProfileActivator +{ + + @Override + public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) + { + Activation activation = profile.getActivation(); + + if ( activation == null ) + { + return false; + } + + ActivationProperty property = activation.getProperty(); + + if ( property == null ) + { + return false; + } + + String name = property.getName(); + boolean reverseName = false; + + if ( name != null && name.startsWith( "!" ) ) + { + reverseName = true; + name = name.substring( 1 ); + } + + if ( name == null || name.length() <= 0 ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "The property name is required to activate the profile " + profile.getId() ) + .setLocation( property.getLocation( "" ) ) ); + return false; + } + + String sysValue = context.getUserProperties().get( name ); + if ( sysValue == null ) + { + sysValue = context.getSystemProperties().get( name ); + } + + String propValue = property.getValue(); + if ( StringUtils.isNotEmpty( propValue ) ) + { + boolean reverseValue = false; + if ( propValue.startsWith( "!" ) ) + { + reverseValue = true; + propValue = propValue.substring( 1 ); + } + + // we have a value, so it has to match the system value... + boolean result = propValue.equals( sysValue ); + + return reverseValue ? !result : result; + } + else + { + boolean result = StringUtils.isNotEmpty( sysValue ); + + return reverseName ? !result : result; + } + } + + @Override + public boolean presentInConfig( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) + { + Activation activation = profile.getActivation(); + + if ( activation == null ) + { + return false; + } + + ActivationProperty property = activation.getProperty(); + + if ( property == null ) + { + return false; + } + return true; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/InvalidRepositoryException.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/InvalidRepositoryException.java new file mode 100644 index 00000000..303aff08 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/InvalidRepositoryException.java @@ -0,0 +1,73 @@ +package org.apache.maven.model.resolution; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Repository; + +/** + * Signals an error when adding a repository to the model resolver. + * + * @author Benjamin Bentmann + */ +public class InvalidRepositoryException + extends Exception +{ + + /** + * The repository that raised this error, can be {@code null}. + */ + private Repository repository; + + /** + * Creates a new exception with specified detail message and cause for the given repository. + * + * @param message The detail message, may be {@code null}. + * @param repository The repository that caused the error, may be {@code null}. + * @param cause The cause, may be {@code null}. + */ + public InvalidRepositoryException( String message, Repository repository, Throwable cause ) + { + super( message, cause ); + this.repository = repository; + } + + /** + * Creates a new exception with specified detail message for the given repository. + * + * @param message The detail message, may be {@code null}. + * @param repository The repository that caused the error, may be {@code null}. + */ + public InvalidRepositoryException( String message, Repository repository ) + { + super( message ); + this.repository = repository; + } + + /** + * Gets the repository that causes this error (if any). + * + * @return The repository that causes this error or {@code null} if not known. + */ + public Repository getRepository() + { + return repository; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java new file mode 100644 index 00000000..c81a5369 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java @@ -0,0 +1,93 @@ +package org.apache.maven.model.resolution; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Parent; +import org.apache.maven.model.Repository; +import org.apache.maven.model.building.ModelSource; + +/** + * Resolves a POM from its coordinates. During the build process, the + * {@link org.apache.maven.model.building.ModelBuilder} will add any relevant repositories to the model resolver. In + * other words, the model resolver is stateful and should not be reused across multiple model building requests. + * + * @author Benjamin Bentmann + */ +public interface ModelResolver +{ + + /** + * Tries to resolve the POM for the specified coordinates. + * + * @param groupId The group identifier of the POM, must not be {@code null}. + * @param artifactId The artifact identifier of the POM, must not be {@code null}. + * @param version The version of the POM, must not be {@code null}. + * @return The source of the requested POM, never {@code null}. + * @throws UnresolvableModelException If the POM could not be resolved from any configured repository. + */ + ModelSource resolveModel( String groupId, String artifactId, String version ) + throws UnresolvableModelException; + + /** + * Tries to resolve the POM for the specified parent coordinates possibly updating {@code parent}. + * + * @param parent The parent coordinates to resolve, must not be {@code null}. + * @return The source of the requested POM, never {@code null}. + * @throws UnresolvableModelException If the POM could not be resolved from any configured repository. + * @since 3.2.2 + */ + ModelSource resolveModel( Parent parent ) + throws UnresolvableModelException; + + /** + * Adds a repository to use for subsequent resolution requests. The order in which repositories are added matters, + * repositories that were added first should also be searched first. When multiple repositories with the same + * identifier are added, only the first repository being added will be used. + * + * @param repository The repository to add to the internal search chain, must not be {@code null}. + * @throws InvalidRepositoryException If the repository could not be added (e.g. due to invalid URL or layout). + */ + void addRepository( Repository repository ) + throws InvalidRepositoryException; + + /** + * Adds a repository to use for subsequent resolution requests. The order in which repositories are added matters, + * repositories that were added first should also be searched first. When multiple repositories with the same + * identifier are added, then the value of the replace argument is determines the behaviour. + * + * If replace is false than any existing repository with the same Id will remain in use. If replace + * is true the new repository replaces the original. + * + * @param repository The repository to add to the internal search chain, must not be {@code null}. + * @throws InvalidRepositoryException If the repository could not be added (e.g. due to invalid URL or layout). + */ + void addRepository( Repository repository, boolean replace ) + throws InvalidRepositoryException; + + /** + * Clones this resolver for usage in a forked resolution process. In general, implementors need not provide a deep + * clone. The only requirement is that invocations of {@link #addRepository(Repository)} on the clone do not affect + * the state of the original resolver and vice versa. + * + * @return The cloned resolver, never {@code null}. + */ + ModelResolver newCopy(); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java new file mode 100644 index 00000000..bdb623ac --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java @@ -0,0 +1,126 @@ +package org.apache.maven.model.resolution; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Signals an error when resolving the path to an external model. + * + * @author Benjamin Bentmann + */ +public class UnresolvableModelException + extends Exception +{ + + /** + * The group id of the unresolvable model. + */ + private final String groupId; + + /** + * The artifact id of the unresolvable model. + */ + private final String artifactId; + + /** + * The version of the unresolvable model. + */ + private final String version; + + /** + * Creates a new exception with specified detail message and cause. + * + * @param message The detail message, may be {@code null}. + * @param groupId The group id of the unresolvable model, may be {@code null}. + * @param artifactId The artifact id of the unresolvable model, may be {@code null}. + * @param version The version of the unresolvable model, may be {@code null}. + * @param cause The cause, may be {@code null}. + */ + public UnresolvableModelException( String message, String groupId, String artifactId, String version, + Throwable cause ) + { + super( message, cause ); + this.groupId = ( groupId != null ) ? groupId : ""; + this.artifactId = ( artifactId != null ) ? artifactId : ""; + this.version = ( version != null ) ? version : ""; + } + + /** + * Creates a new exception with specified detail message. + * + * @param message The detail message, may be {@code null}. + * @param groupId The group id of the unresolvable model, may be {@code null}. + * @param artifactId The artifact id of the unresolvable model, may be {@code null}. + * @param version The version of the unresolvable model, may be {@code null}. + */ + public UnresolvableModelException( String message, String groupId, String artifactId, String version ) + { + super( message ); + this.groupId = ( groupId != null ) ? groupId : ""; + this.artifactId = ( artifactId != null ) ? artifactId : ""; + this.version = ( version != null ) ? version : ""; + } + + /** + * Creates a new exception with specified cause + * + * @param cause + * @param groupId + * @param artifactId + * @param version + */ + public UnresolvableModelException( Throwable cause, String groupId, String artifactId, String version ) + { + super( cause ); + this.groupId = groupId; + this.artifactId = artifactId; + this.version = version; + } + + /** + * Gets the group id of the unresolvable model. + * + * @return The group id of the unresolvable model, can be empty but never {@code null}. + */ + public String getGroupId() + { + return groupId; + } + + /** + * Gets the artifact id of the unresolvable model. + * + * @return The artifact id of the unresolvable model, can be empty but never {@code null}. + */ + public String getArtifactId() + { + return artifactId; + } + + /** + * Gets the version of the unresolvable model. + * + * @return The version of the unresolvable model, can be empty but never {@code null}. + */ + public String getVersion() + { + return version; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/WorkspaceModelResolver.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/WorkspaceModelResolver.java new file mode 100644 index 00000000..d12edea7 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/resolution/WorkspaceModelResolver.java @@ -0,0 +1,33 @@ +package org.apache.maven.model.resolution; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; + +public interface WorkspaceModelResolver +{ + + Model resolveRawModel( String groupId, String artifactId, String versionConstraint ) + throws UnresolvableModelException; + + Model resolveEffectiveModel( String groupId, String artifactId, String versionConstraint ) + throws UnresolvableModelException; + +} \ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/superpom/DefaultSuperPomProvider.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/superpom/DefaultSuperPomProvider.java new file mode 100644 index 00000000..7d4f66a8 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/superpom/DefaultSuperPomProvider.java @@ -0,0 +1,87 @@ +package org.apache.maven.model.superpom; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelProcessor; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; + +/** + * Provides the super POM that all models implicitly inherit from. + * + * @author Benjamin Bentmann + */ +@Component( role = SuperPomProvider.class ) +public class DefaultSuperPomProvider + implements SuperPomProvider +{ + + /** + * The cached super POM, lazily created. + */ + private Model superModel; + + @Requirement + private ModelProcessor modelProcessor; + + public DefaultSuperPomProvider setModelProcessor( ModelProcessor modelProcessor ) + { + this.modelProcessor = modelProcessor; + return this; + } + + @Override + public Model getSuperModel( String version ) + { + if ( superModel == null ) + { + String resource = "/org/apache/maven/model/pom-" + version + ".xml"; + + InputStream is = getClass().getResourceAsStream( resource ); + + if ( is == null ) + { + throw new IllegalStateException( "The super POM " + resource + " was not found" + + ", please verify the integrity of your Maven installation" ); + } + + try + { + Map options = new HashMap(); + options.put( "xml:4.0.0", "xml:4.0.0" ); + superModel = modelProcessor.read( is, options ); + } + catch ( IOException e ) + { + throw new IllegalStateException( "The super POM " + resource + " is damaged" + + ", please verify the integrity of your Maven installation", e ); + } + } + + return superModel; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/superpom/SuperPomProvider.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/superpom/SuperPomProvider.java new file mode 100644 index 00000000..3f44fb7e --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/superpom/SuperPomProvider.java @@ -0,0 +1,42 @@ +package org.apache.maven.model.superpom; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; + +/** + * Provides the super POM that all models implicitly inherit from. + * + * @author Benjamin Bentmann + */ +public interface SuperPomProvider +{ + + /** + * Gets the super POM for the specified model version. The returned model is supposed to be read-only, i.e. if the + * caller intends to make updates to the model the return value must be cloned before updating to ensure the + * modifications don't affect future retrievals of the super POM. + * + * @param version The model version to retrieve the super POM for (e.g. "4.0.0"), must not be {@code null}. + * @return The super POM, never {@code null}. + */ + Model getSuperModel( String version ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java new file mode 100644 index 00000000..dd7bd4e2 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java @@ -0,0 +1,1076 @@ +package org.apache.maven.model.validation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; + +import org.apache.maven.model.Activation; +import org.apache.maven.model.ActivationFile; +import org.apache.maven.model.Build; +import org.apache.maven.model.BuildBase; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.DistributionManagement; +import org.apache.maven.model.Exclusion; +import org.apache.maven.model.InputLocation; +import org.apache.maven.model.InputLocationTracker; +import org.apache.maven.model.Model; +import org.apache.maven.model.Parent; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginExecution; +import org.apache.maven.model.PluginManagement; +import org.apache.maven.model.Profile; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.Reporting; +import org.apache.maven.model.Repository; +import org.apache.maven.model.Resource; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblem.Severity; +import org.apache.maven.model.building.ModelProblem.Version; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.building.ModelProblemCollectorRequest; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.StringUtils; + +/** + * @author Trygve Laugstøl + */ +@Component( role = ModelValidator.class ) +public class DefaultModelValidator + implements ModelValidator +{ + + private static final Pattern ID_REGEX = Pattern.compile( "[A-Za-z0-9_\\-.]+" ); + + private static final Pattern ID_WITH_WILDCARDS_REGEX = Pattern.compile( "[A-Za-z0-9_\\-.?*]+" ); + + private static final String ILLEGAL_FS_CHARS = "\\/:\"<>|?*"; + + private static final String ILLEGAL_VERSION_CHARS = ILLEGAL_FS_CHARS; + + private static final String ILLEGAL_REPO_ID_CHARS = ILLEGAL_FS_CHARS; + + @Override + public void validateRawModel( Model m, ModelBuildingRequest request, ModelProblemCollector problems ) + { + Parent parent = m.getParent(); + if ( parent != null ) + { + validateStringNotEmpty( "parent.groupId", problems, Severity.FATAL, Version.BASE, parent.getGroupId(), + parent ); + + validateStringNotEmpty( "parent.artifactId", problems, Severity.FATAL, Version.BASE, + parent.getArtifactId(), parent ); + + validateStringNotEmpty( "parent.version", problems, Severity.FATAL, Version.BASE, parent.getVersion(), + parent ); + + if ( equals( parent.getGroupId(), m.getGroupId() ) + && equals( parent.getArtifactId(), m.getArtifactId() ) ) + { + addViolation( problems, Severity.FATAL, Version.BASE, "parent.artifactId", null, "must be changed" + + ", the parent element cannot have the same groupId:artifactId as the project.", parent ); + } + } + + if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ) + { + Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 ); + + validateEnum( "modelVersion", problems, Severity.ERROR, Version.V20, m.getModelVersion(), null, m, + "4.0.0" ); + + validateStringNoExpression( "groupId", problems, Severity.WARNING, Version.V20, m.getGroupId(), m ); + if ( parent == null ) + { + validateStringNotEmpty( "groupId", problems, Severity.FATAL, Version.V20, m.getGroupId(), m ); + } + + validateStringNoExpression( "artifactId", problems, Severity.WARNING, Version.V20, m.getArtifactId(), m ); + validateStringNotEmpty( "artifactId", problems, Severity.FATAL, Version.V20, m.getArtifactId(), m ); + + validateVersionNoExpression( "version", problems, Severity.WARNING, Version.V20, m.getVersion(), m ); + if ( parent == null ) + { + validateStringNotEmpty( "version", problems, Severity.FATAL, Version.V20, m.getVersion(), m ); + } + + validate20RawDependencies( problems, m.getDependencies(), "dependencies.dependency", request ); + + if ( m.getDependencyManagement() != null ) + { + validate20RawDependencies( problems, m.getDependencyManagement().getDependencies(), + "dependencyManagement.dependencies.dependency", request ); + } + + validateRawRepositories( problems, m.getRepositories(), "repositories.repository", request ); + + validateRawRepositories( problems, m.getPluginRepositories(), "pluginRepositories.pluginRepository", + request ); + + Build build = m.getBuild(); + if ( build != null ) + { + validate20RawPlugins( problems, build.getPlugins(), "build.plugins.plugin", request ); + + PluginManagement mngt = build.getPluginManagement(); + if ( mngt != null ) + { + validate20RawPlugins( problems, mngt.getPlugins(), "build.pluginManagement.plugins.plugin", + request ); + } + } + + Set profileIds = new HashSet(); + + for ( Profile profile : m.getProfiles() ) + { + String prefix = "profiles.profile[" + profile.getId() + "]"; + + if ( !profileIds.add( profile.getId() ) ) + { + addViolation( problems, errOn30, Version.V20, "profiles.profile.id", null, + "must be unique but found duplicate profile with id " + profile.getId(), profile ); + } + + validate30RawProfileActivation( problems, profile.getActivation(), profile.getId(), prefix + + ".activation", request ); + + validate20RawDependencies( problems, profile.getDependencies(), prefix + ".dependencies.dependency", + request ); + + if ( profile.getDependencyManagement() != null ) + { + validate20RawDependencies( problems, profile.getDependencyManagement().getDependencies(), prefix + + ".dependencyManagement.dependencies.dependency", request ); + } + + validateRawRepositories( problems, profile.getRepositories(), prefix + ".repositories.repository", + request ); + + validateRawRepositories( problems, profile.getPluginRepositories(), prefix + + ".pluginRepositories.pluginRepository", request ); + + BuildBase buildBase = profile.getBuild(); + if ( buildBase != null ) + { + validate20RawPlugins( problems, buildBase.getPlugins(), prefix + ".plugins.plugin", request ); + + PluginManagement mngt = buildBase.getPluginManagement(); + if ( mngt != null ) + { + validate20RawPlugins( problems, mngt.getPlugins(), prefix + ".pluginManagement.plugins.plugin", + request ); + } + } + } + } + } + + private void validate30RawProfileActivation( ModelProblemCollector problems, Activation activation, + String sourceHint, String prefix, ModelBuildingRequest request ) + { + if ( activation == null ) + { + return; + } + + ActivationFile file = activation.getFile(); + + if ( file != null ) + { + String path; + boolean missing; + + if ( StringUtils.isNotEmpty( file.getExists() ) ) + { + path = file.getExists(); + missing = false; + } + else if ( StringUtils.isNotEmpty( file.getMissing() ) ) + { + path = file.getMissing(); + missing = true; + } + else + { + return; + } + + if ( path.contains( "${project.basedir}" ) ) + { + addViolation( problems, + Severity.WARNING, + Version.V30, + prefix + ( missing ? ".file.missing" : ".file.exists" ), + null, + "Failed to interpolate file location " + path + " for profile " + sourceHint + + ": ${project.basedir} expression not supported during profile activation, " + + "use ${basedir} instead", + file.getLocation( missing ? "missing" : "exists" ) ); + } + else if ( hasProjectExpression( path ) ) + { + addViolation( problems, + Severity.WARNING, + Version.V30, + prefix + ( missing ? ".file.missing" : ".file.exists" ), + null, + "Failed to interpolate file location " + + path + + " for profile " + + sourceHint + + ": ${project.*} expressions are not supported during profile activation", + file.getLocation( missing ? "missing" : "exists" ) ); + } + } + } + + private void validate20RawPlugins( ModelProblemCollector problems, List plugins, String prefix, + ModelBuildingRequest request ) + { + Severity errOn31 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 ); + + Map index = new HashMap(); + + for ( Plugin plugin : plugins ) + { + String key = plugin.getKey(); + + Plugin existing = index.get( key ); + + if ( existing != null ) + { + addViolation( problems, errOn31, Version.V20, prefix + ".(groupId:artifactId)", null, + "must be unique but found duplicate declaration of plugin " + key, plugin ); + } + else + { + index.put( key, plugin ); + } + + Set executionIds = new HashSet(); + + for ( PluginExecution exec : plugin.getExecutions() ) + { + if ( !executionIds.add( exec.getId() ) ) + { + addViolation( problems, Severity.ERROR, Version.V20, prefix + "[" + plugin.getKey() + + "].executions.execution.id", null, "must be unique but found duplicate execution with id " + + exec.getId(), exec ); + } + } + } + } + + @Override + public void validateEffectiveModel( Model m, ModelBuildingRequest request, ModelProblemCollector problems ) + { + validateStringNotEmpty( "modelVersion", problems, Severity.ERROR, Version.BASE, m.getModelVersion(), m ); + + validateId( "groupId", problems, m.getGroupId(), m ); + + validateId( "artifactId", problems, m.getArtifactId(), m ); + + validateStringNotEmpty( "packaging", problems, Severity.ERROR, Version.BASE, m.getPackaging(), m ); + + if ( !m.getModules().isEmpty() ) + { + if ( !"pom".equals( m.getPackaging() ) ) + { + addViolation( problems, Severity.ERROR, Version.BASE, "packaging", null, + "with value '" + m.getPackaging() + "' is invalid. Aggregator projects " + + "require 'pom' as packaging.", m ); + } + + for ( int i = 0, n = m.getModules().size(); i < n; i++ ) + { + String module = m.getModules().get( i ); + if ( StringUtils.isBlank( module ) ) + { + addViolation( problems, Severity.ERROR, Version.BASE, "modules.module[" + i + "]", null, + "has been specified without a path to the project directory.", + m.getLocation( "modules" ) ); + } + } + } + + validateStringNotEmpty( "version", problems, Severity.ERROR, Version.BASE, m.getVersion(), m ); + + Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 ); + + validateEffectiveDependencies( problems, m.getDependencies(), false, request ); + + DependencyManagement mgmt = m.getDependencyManagement(); + if ( mgmt != null ) + { + validateEffectiveDependencies( problems, mgmt.getDependencies(), true, request ); + } + + if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ) + { + Set modules = new HashSet(); + for ( int i = 0, n = m.getModules().size(); i < n; i++ ) + { + String module = m.getModules().get( i ); + if ( !modules.add( module ) ) + { + addViolation( problems, Severity.ERROR, Version.V20, "modules.module[" + i + "]", null, + "specifies duplicate child module " + module, m.getLocation( "modules" ) ); + } + } + + Severity errOn31 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 ); + + validateBannedCharacters( "version", problems, errOn31, Version.V20, m.getVersion(), null, m, + ILLEGAL_VERSION_CHARS ); + validate20ProperSnapshotVersion( "version", problems, errOn31, Version.V20, m.getVersion(), null, m ); + + Build build = m.getBuild(); + if ( build != null ) + { + for ( Plugin p : build.getPlugins() ) + { + validateStringNotEmpty( "build.plugins.plugin.artifactId", problems, Severity.ERROR, Version.V20, + p.getArtifactId(), p ); + + validateStringNotEmpty( "build.plugins.plugin.groupId", problems, Severity.ERROR, Version.V20, + p.getGroupId(), p ); + + validate20PluginVersion( "build.plugins.plugin.version", problems, p.getVersion(), p.getKey(), p, + request ); + + validateBoolean( "build.plugins.plugin.inherited", problems, errOn30, Version.V20, + p.getInherited(), p.getKey(), p ); + + validateBoolean( "build.plugins.plugin.extensions", problems, errOn30, Version.V20, + p.getExtensions(), p.getKey(), p ); + + validate20EffectivePluginDependencies( problems, p, request ); + } + + validate20RawResources( problems, build.getResources(), "build.resources.resource", request ); + + validate20RawResources( problems, build.getTestResources(), "build.testResources.testResource", + request ); + } + + Reporting reporting = m.getReporting(); + if ( reporting != null ) + { + for ( ReportPlugin p : reporting.getPlugins() ) + { + validateStringNotEmpty( "reporting.plugins.plugin.artifactId", problems, Severity.ERROR, + Version.V20, p.getArtifactId(), p ); + + validateStringNotEmpty( "reporting.plugins.plugin.groupId", problems, Severity.ERROR, Version.V20, + p.getGroupId(), p ); + } + } + + for ( Repository repository : m.getRepositories() ) + { + validate20EffectiveRepository( problems, repository, "repositories.repository", request ); + } + + for ( Repository repository : m.getPluginRepositories() ) + { + validate20EffectiveRepository( problems, repository, "pluginRepositories.pluginRepository", request ); + } + + DistributionManagement distMgmt = m.getDistributionManagement(); + if ( distMgmt != null ) + { + if ( distMgmt.getStatus() != null ) + { + addViolation( problems, Severity.ERROR, Version.V20, "distributionManagement.status", null, + "must not be specified.", distMgmt ); + } + + validate20EffectiveRepository( problems, distMgmt.getRepository(), "distributionManagement.repository", + request ); + validate20EffectiveRepository( problems, distMgmt.getSnapshotRepository(), + "distributionManagement.snapshotRepository", request ); + } + } + } + + private void validate20RawDependencies( ModelProblemCollector problems, List dependencies, + String prefix, ModelBuildingRequest request ) + { + Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 ); + Severity errOn31 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 ); + + Map index = new HashMap(); + + for ( Dependency dependency : dependencies ) + { + String key = dependency.getManagementKey(); + + if ( "import".equals( dependency.getScope() ) ) + { + if ( !"pom".equals( dependency.getType() ) ) + { + addViolation( problems, Severity.WARNING, Version.V20, prefix + ".type", key, + "must be 'pom' to import the managed dependencies.", dependency ); + } + else if ( StringUtils.isNotEmpty( dependency.getClassifier() ) ) + { + addViolation( problems, errOn30, Version.V20, prefix + ".classifier", key, + "must be empty, imported POM cannot have a classifier.", dependency ); + } + } + else if ( "system".equals( dependency.getScope() ) ) + { + String sysPath = dependency.getSystemPath(); + if ( StringUtils.isNotEmpty( sysPath ) ) + { + if ( !hasExpression( sysPath ) ) + { + addViolation( problems, Severity.WARNING, Version.V20, prefix + ".systemPath", key, + "should use a variable instead of a hard-coded path " + sysPath, dependency ); + } + else if ( sysPath.contains( "${basedir}" ) || sysPath.contains( "${project.basedir}" ) ) + { + addViolation( problems, Severity.WARNING, Version.V20, prefix + ".systemPath", key, + "should not point at files within the project directory, " + sysPath + + " will be unresolvable by dependent projects", dependency ); + } + } + } + + Dependency existing = index.get( key ); + + if ( existing != null ) + { + String msg; + if ( equals( existing.getVersion(), dependency.getVersion() ) ) + { + msg = + "duplicate declaration of version " + + StringUtils.defaultString( dependency.getVersion(), "(?)" ); + } + else + { + msg = + "version " + StringUtils.defaultString( existing.getVersion(), "(?)" ) + " vs " + + StringUtils.defaultString( dependency.getVersion(), "(?)" ); + } + + addViolation( problems, errOn31, Version.V20, prefix + ".(groupId:artifactId:type:classifier)", null, + "must be unique: " + key + " -> " + msg, dependency ); + } + else + { + index.put( key, dependency ); + } + } + } + + private void validateEffectiveDependencies( ModelProblemCollector problems, List dependencies, + boolean management, ModelBuildingRequest request ) + { + Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 ); + + String prefix = management ? "dependencyManagement.dependencies.dependency." : "dependencies.dependency."; + + for ( Dependency d : dependencies ) + { + validateEffectiveDependency( problems, d, management, prefix, request ); + + if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ) + { + validateBoolean( prefix + "optional", problems, errOn30, Version.V20, d.getOptional(), + d.getManagementKey(), d ); + + if ( !management ) + { + validateVersion( prefix + "version", problems, errOn30, Version.V20, d.getVersion(), + d.getManagementKey(), d ); + + /* + * TODO: Extensions like Flex Mojos use custom scopes like "merged", "internal", "external", etc. + * In order to don't break backward-compat with those, only warn but don't error out. + */ + validateEnum( prefix + "scope", problems, Severity.WARNING, Version.V20, d.getScope(), + d.getManagementKey(), d, "provided", "compile", "runtime", "test", "system" ); + } + } + } + } + + private void validate20EffectivePluginDependencies( ModelProblemCollector problems, Plugin plugin, + ModelBuildingRequest request ) + { + List dependencies = plugin.getDependencies(); + + if ( !dependencies.isEmpty() ) + { + String prefix = "build.plugins.plugin[" + plugin.getKey() + "].dependencies.dependency."; + + Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 ); + + for ( Dependency d : dependencies ) + { + validateEffectiveDependency( problems, d, false, prefix, request ); + + validateVersion( prefix + "version", problems, errOn30, Version.BASE, d.getVersion(), + d.getManagementKey(), d ); + + validateEnum( prefix + "scope", problems, errOn30, Version.BASE, d.getScope(), d.getManagementKey(), d, + "compile", "runtime", "system" ); + } + } + } + + private void validateEffectiveDependency( ModelProblemCollector problems, Dependency d, boolean management, + String prefix, ModelBuildingRequest request ) + { + validateId( prefix + "artifactId", problems, Severity.ERROR, Version.BASE, d.getArtifactId(), + d.getManagementKey(), d ); + + validateId( prefix + "groupId", problems, Severity.ERROR, Version.BASE, d.getGroupId(), d.getManagementKey(), + d ); + + if ( !management ) + { + validateStringNotEmpty( prefix + "type", problems, Severity.ERROR, Version.BASE, d.getType(), + d.getManagementKey(), d ); + + validateDependencyVersion( problems, d, prefix ); + } + + if ( "system".equals( d.getScope() ) ) + { + String systemPath = d.getSystemPath(); + + if ( StringUtils.isEmpty( systemPath ) ) + { + addViolation( problems, Severity.ERROR, Version.BASE, prefix + "systemPath", d.getManagementKey(), + "is missing.", d ); + } + else + { + File sysFile = new File( systemPath ); + if ( !sysFile.isAbsolute() ) + { + addViolation( problems, Severity.ERROR, Version.BASE, prefix + "systemPath", d.getManagementKey(), + "must specify an absolute path but is " + systemPath, d ); + } + else if ( !sysFile.isFile() ) + { + String msg = "refers to a non-existing file " + sysFile.getAbsolutePath(); + systemPath = systemPath.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ); + String jdkHome = + request.getSystemProperties().getProperty( "java.home", "" ) + File.separator + ".."; + if ( systemPath.startsWith( jdkHome ) ) + { + msg += ". Please verify that you run Maven using a JDK and not just a JRE."; + } + addViolation( problems, Severity.WARNING, Version.BASE, prefix + "systemPath", + d.getManagementKey(), msg, d ); + } + } + } + else if ( StringUtils.isNotEmpty( d.getSystemPath() ) ) + { + addViolation( problems, Severity.ERROR, Version.BASE, prefix + "systemPath", d.getManagementKey(), + "must be omitted." + " This field may only be specified for a dependency with system scope.", + d ); + } + + if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ) + { + for ( Exclusion exclusion : d.getExclusions() ) + { + if ( request.getValidationLevel() < ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 ) + { + validateId( prefix + "exclusions.exclusion.groupId", problems, Severity.WARNING, Version.V20, + exclusion.getGroupId(), d.getManagementKey(), exclusion ); + + validateId( prefix + "exclusions.exclusion.artifactId", problems, Severity.WARNING, Version.V20, + exclusion.getArtifactId(), d.getManagementKey(), exclusion ); + } + else + { + validateIdWithWildcards( prefix + "exclusions.exclusion.groupId", problems, Severity.WARNING, + Version.V30, exclusion.getGroupId(), d.getManagementKey(), exclusion ); + + validateIdWithWildcards( prefix + "exclusions.exclusion.artifactId", problems, Severity.WARNING, + Version.V30, exclusion.getArtifactId(), d.getManagementKey(), exclusion ); + } + } + } + } + + /** + * @since 3.2.4 + */ + protected void validateDependencyVersion( ModelProblemCollector problems, Dependency d, String prefix ) + { + validateStringNotEmpty( prefix + "version", problems, Severity.ERROR, Version.BASE, d.getVersion(), + d.getManagementKey(), d ); + } + + private void validateRawRepositories( ModelProblemCollector problems, List repositories, String prefix, + ModelBuildingRequest request ) + { + Map index = new HashMap(); + + for ( Repository repository : repositories ) + { + validateStringNotEmpty( prefix + ".id", problems, Severity.ERROR, Version.V20, repository.getId(), + repository ); + + validateStringNotEmpty( prefix + "[" + repository.getId() + "].url", problems, Severity.ERROR, Version.V20, + repository.getUrl(), repository ); + + String key = repository.getId(); + + Repository existing = index.get( key ); + + if ( existing != null ) + { + Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 ); + + addViolation( problems, errOn30, Version.V20, prefix + ".id", null, + "must be unique: " + repository.getId() + " -> " + existing.getUrl() + " vs " + + repository.getUrl(), repository ); + } + else + { + index.put( key, repository ); + } + } + } + + private void validate20EffectiveRepository( ModelProblemCollector problems, Repository repository, String prefix, + ModelBuildingRequest request ) + { + if ( repository != null ) + { + Severity errOn31 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 ); + + validateBannedCharacters( prefix + ".id", problems, errOn31, Version.V20, repository.getId(), null, + repository, ILLEGAL_REPO_ID_CHARS ); + + if ( "local".equals( repository.getId() ) ) + { + addViolation( problems, errOn31, Version.V20, prefix + ".id", null, "must not be 'local'" + + ", this identifier is reserved for the local repository" + + ", using it for other repositories will corrupt your repository metadata.", repository ); + } + + if ( "legacy".equals( repository.getLayout() ) ) + { + addViolation( problems, Severity.WARNING, Version.V20, prefix + ".layout", repository.getId(), + "uses the unsupported value 'legacy', artifact resolution might fail.", repository ); + } + } + } + + private void validate20RawResources( ModelProblemCollector problems, List resources, String prefix, + ModelBuildingRequest request ) + { + Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 ); + + for ( Resource resource : resources ) + { + validateStringNotEmpty( prefix + ".directory", problems, Severity.ERROR, Version.V20, + resource.getDirectory(), resource ); + + validateBoolean( prefix + ".filtering", problems, errOn30, Version.V20, resource.getFiltering(), + resource.getDirectory(), resource ); + } + } + + // ---------------------------------------------------------------------- + // Field validation + // ---------------------------------------------------------------------- + + private boolean validateId( String fieldName, ModelProblemCollector problems, String id, + InputLocationTracker tracker ) + { + return validateId( fieldName, problems, Severity.ERROR, Version.BASE, id, null, tracker ); + } + + private boolean validateId( String fieldName, ModelProblemCollector problems, Severity severity, Version version, + String id, String sourceHint, InputLocationTracker tracker ) + { + if ( !validateStringNotEmpty( fieldName, problems, severity, version, id, sourceHint, tracker ) ) + { + return false; + } + else + { + boolean match = ID_REGEX.matcher( id ).matches(); + if ( !match ) + { + addViolation( problems, severity, version, fieldName, sourceHint, "with value '" + id + + "' does not match a valid id pattern.", tracker ); + } + return match; + } + } + + private boolean validateIdWithWildcards( String fieldName, ModelProblemCollector problems, Severity severity, + Version version, String id, String sourceHint, + InputLocationTracker tracker ) + { + if ( !validateStringNotEmpty( fieldName, problems, severity, version, id, sourceHint, tracker ) ) + { + return false; + } + else + { + boolean match = ID_WITH_WILDCARDS_REGEX.matcher( id ).matches(); + if ( !match ) + { + addViolation( problems, severity, version, fieldName, sourceHint, "with value '" + id + + "' does not match a valid id pattern.", tracker ); + } + return match; + } + } + + + private boolean validateStringNoExpression( String fieldName, ModelProblemCollector problems, Severity severity, + Version version, String string, InputLocationTracker tracker ) + { + if ( !hasExpression( string ) ) + { + return true; + } + + addViolation( problems, severity, version, fieldName, null, "contains an expression but should be a constant.", + tracker ); + + return false; + } + + private boolean validateVersionNoExpression( String fieldName, ModelProblemCollector problems, Severity severity, + Version version, String string, InputLocationTracker tracker ) + { + + if ( !hasExpression( string ) ) + { + return true; + } + + // + // Acceptable versions for continuous delivery + // + // changelist + // revision + // sha1 + // + if ( string.trim().contains( "${changelist}" ) || string.trim().contains( "${revision}" ) + || string.trim().contains( "${sha1}" ) ) + { + return true; + } + + addViolation( problems, severity, version, fieldName, null, "contains an expression but should be a constant.", + tracker ); + + return false; + } + + private boolean hasExpression( String value ) + { + return value != null && value.contains( "${" ); + } + + private boolean hasProjectExpression( String value ) + { + return value != null && value.contains( "${project." ); + } + + private boolean validateStringNotEmpty( String fieldName, ModelProblemCollector problems, Severity severity, + Version version, String string, InputLocationTracker tracker ) + { + return validateStringNotEmpty( fieldName, problems, severity, version, string, null, tracker ); + } + + /** + * Asserts: + *

+ *

    + *
  • string != null + *
  • string.length > 0 + *
+ */ + private boolean validateStringNotEmpty( String fieldName, ModelProblemCollector problems, Severity severity, + Version version, String string, String sourceHint, + InputLocationTracker tracker ) + { + if ( !validateNotNull( fieldName, problems, severity, version, string, sourceHint, tracker ) ) + { + return false; + } + + if ( string.length() > 0 ) + { + return true; + } + + addViolation( problems, severity, version, fieldName, sourceHint, "is missing.", tracker ); + + return false; + } + + /** + * Asserts: + *

+ *

    + *
  • string != null + *
+ */ + private boolean validateNotNull( String fieldName, ModelProblemCollector problems, Severity severity, + Version version, Object object, String sourceHint, InputLocationTracker tracker ) + { + if ( object != null ) + { + return true; + } + + addViolation( problems, severity, version, fieldName, sourceHint, "is missing.", tracker ); + + return false; + } + + private boolean validateBoolean( String fieldName, ModelProblemCollector problems, Severity severity, + Version version, String string, String sourceHint, InputLocationTracker tracker ) + { + if ( string == null || string.length() <= 0 ) + { + return true; + } + + if ( "true".equalsIgnoreCase( string ) || "false".equalsIgnoreCase( string ) ) + { + return true; + } + + addViolation( problems, severity, version, fieldName, sourceHint, "must be 'true' or 'false' but is '" + string + + "'.", tracker ); + + return false; + } + + private boolean validateEnum( String fieldName, ModelProblemCollector problems, Severity severity, Version version, + String string, String sourceHint, InputLocationTracker tracker, + String... validValues ) + { + if ( string == null || string.length() <= 0 ) + { + return true; + } + + List values = Arrays.asList( validValues ); + + if ( values.contains( string ) ) + { + return true; + } + + addViolation( problems, severity, version, fieldName, sourceHint, "must be one of " + values + " but is '" + + string + "'.", tracker ); + + return false; + } + + private boolean validateBannedCharacters( String fieldName, ModelProblemCollector problems, Severity severity, + Version version, String string, String sourceHint, + InputLocationTracker tracker, String banned ) + { + if ( string != null ) + { + for ( int i = string.length() - 1; i >= 0; i-- ) + { + if ( banned.indexOf( string.charAt( i ) ) >= 0 ) + { + addViolation( problems, severity, version, fieldName, sourceHint, + "must not contain any of these characters " + banned + " but found " + + string.charAt( i ), tracker ); + return false; + } + } + } + + return true; + } + + private boolean validateVersion( String fieldName, ModelProblemCollector problems, Severity severity, + Version version, String string, String sourceHint, InputLocationTracker tracker ) + { + if ( string == null || string.length() <= 0 ) + { + return true; + } + + if ( hasExpression( string ) ) + { + addViolation( problems, severity, version, fieldName, sourceHint, + "must be a valid version but is '" + string + "'.", tracker ); + return false; + } + + return validateBannedCharacters( fieldName, problems, severity, version, string, sourceHint, tracker, + ILLEGAL_VERSION_CHARS ); + + } + + private boolean validate20ProperSnapshotVersion( String fieldName, ModelProblemCollector problems, + Severity severity, Version version, String string, + String sourceHint, InputLocationTracker tracker ) + { + if ( string == null || string.length() <= 0 ) + { + return true; + } + + if ( string.endsWith( "SNAPSHOT" ) && !string.endsWith( "-SNAPSHOT" ) ) + { + addViolation( problems, severity, version, fieldName, sourceHint, + "uses an unsupported snapshot version format, should be '*-SNAPSHOT' instead.", tracker ); + return false; + } + + return true; + } + + private boolean validate20PluginVersion( String fieldName, ModelProblemCollector problems, String string, + String sourceHint, InputLocationTracker tracker, + ModelBuildingRequest request ) + { + if ( string == null ) + { + // NOTE: The check for missing plugin versions is handled directly by the model builder + return true; + } + + Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 ); + + if ( !validateVersion( fieldName, problems, errOn30, Version.V20, string, sourceHint, tracker ) ) + { + return false; + } + + if ( string.length() <= 0 || "RELEASE".equals( string ) || "LATEST".equals( string ) ) + { + addViolation( problems, errOn30, Version.V20, fieldName, sourceHint, "must be a valid version but is '" + + string + "'.", tracker ); + return false; + } + + return true; + } + + private static void addViolation( ModelProblemCollector problems, Severity severity, Version version, + String fieldName, String sourceHint, String message, + InputLocationTracker tracker ) + { + StringBuilder buffer = new StringBuilder( 256 ); + buffer.append( '\'' ).append( fieldName ).append( '\'' ); + + if ( sourceHint != null ) + { + buffer.append( " for " ).append( sourceHint ); + } + + buffer.append( ' ' ).append( message ); + + problems.add( new ModelProblemCollectorRequest( severity, version ) + .setMessage( buffer.toString() ).setLocation( getLocation( fieldName, tracker ) ) ); + } + + private static InputLocation getLocation( String fieldName, InputLocationTracker tracker ) + { + InputLocation location = null; + + if ( tracker != null ) + { + if ( fieldName != null ) + { + Object key = fieldName; + + int idx = fieldName.lastIndexOf( '.' ); + if ( idx >= 0 ) + { + fieldName = fieldName.substring( idx + 1 ); + key = fieldName; + } + + if ( fieldName.endsWith( "]" ) ) + { + key = fieldName.substring( fieldName.lastIndexOf( '[' ) + 1, fieldName.length() - 1 ); + try + { + key = Integer.valueOf( key.toString() ); + } + catch ( NumberFormatException e ) + { + // use key as is + } + } + + location = tracker.getLocation( key ); + } + + if ( location == null ) + { + location = tracker.getLocation( "" ); + } + } + + return location; + } + + private static boolean equals( String s1, String s2 ) + { + return StringUtils.clean( s1 ).equals( StringUtils.clean( s2 ) ); + } + + private static Severity getSeverity( ModelBuildingRequest request, int errorThreshold ) + { + return getSeverity( request.getValidationLevel(), errorThreshold ); + } + + private static Severity getSeverity( int validationLevel, int errorThreshold ) + { + if ( validationLevel < errorThreshold ) + { + return Severity.WARNING; + } + else + { + return Severity.ERROR; + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/validation/ModelValidator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/validation/ModelValidator.java new file mode 100644 index 00000000..84e3fadd --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/validation/ModelValidator.java @@ -0,0 +1,54 @@ +package org.apache.maven.model.validation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Checks the model for missing or invalid values. + * + * @author Trygve Laugstøl + */ +public interface ModelValidator +{ + + /** + * Checks the specified (raw) model for missing or invalid values. The raw model is directly created from the POM + * file and has not been subjected to inheritance, interpolation or profile/default injection. + * + * @param model The model to validate, must not be {@code null}. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void validateRawModel( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + + /** + * Checks the specified (effective) model for missing or invalid values. The effective model is fully assembled and + * has undergone inheritance, interpolation and other model operations. + * + * @param model The model to validate, must not be {@code null}. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void validateEffectiveModel( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/mdo/profiles.mdo b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/mdo/profiles.mdo new file mode 100644 index 00000000..26f0d122 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/mdo/profiles.mdo @@ -0,0 +1,399 @@ + + + + profiles + Profiles + + + + package + org.apache.maven.profiles + + + + + ProfilesRoot + 1.0.0 + Root element of the profiles.xml file. + + + profiles + 1.0.0 + + + Profile + * + + + + activeProfiles + 1.0.0 + + + String + * + + + + + + Profile + 1.0.0 + + + + id + true + 1.0.0 + String + default + The ID of this build profile, for activation + purposes. + + + activation + 1.0.0 + + + Activation + + + + properties + Extended configuration specific to this profile goes + here. + Properties + + String + * + + + + repositories + 1.0.0 + + + + Repository + * + + + + pluginRepositories + 1.0.0 + + + Repository + * + + + + + + + Activation + 1.0.0 + + + + activeByDefault + 1.0.0 + boolean + Flag specifying whether this profile is active as a default. + + + jdk + 1.0.0 + String + + + + os + 1.0.0 + + + ActivationOS + + + + property + 1.0.0 + + + ActivationProperty + + + + file + 1.0.0 + + + ActivationFile + + + + + + + + RepositoryBase + 1.0.0 + + + + id + 1.0.0 + + String + + + name + 1.0.0 + + String + + + url + 1.0.0 + + String + + + layout + 1.0.0 + The type of layout this repository uses for locating and storing artifacts - can be "legacy" or + "default". + String + default + + + + + 1.0.0 + + + + + + Repository + RepositoryBase + 1.0.0 + + Repository contains the information needed for establishing connections with remote repoistory + + + + releases + 1.0.0 + How to handle downloading of releases from this repository + + RepositoryPolicy + + + + snapshots + 1.0.0 + How to handle downloading of snapshots from this repository + + RepositoryPolicy + + + + + + + 1.0.0 + + + + + + + RepositoryPolicy + 1.0.0 + Download policy + + + enabled + 1.0.0 + Whether to use this repository for downloading this type of artifact + boolean + true + + + updatePolicy + 1.0.0 + + The frequency for downloading updates - can be "always", "daily" (default), "interval:XXX" (in minutes) or + "never" (only if it doesn't exist locally). + + String + + + checksumPolicy + 1.0.0 + What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are + "fail" or "warn" + String + + + + + ActivationProperty + 1.0.0 + + + + name + 1.0.0 + String + true + The name of the property to be used to activate a profile + + + value + 1.0.0 + String + The value of the property to be used to activate a profile + + + + + ActivationFile + 1.0.0 + + + + missing + 1.0.0 + String + The name of the file that should be missing to activate a profile + + + exists + 1.0.0 + String + The name of the file that should exist to activate a profile + + + + + ActivationOS + 1.0.0 + + + + name + 1.0.0 + String + The name of the OS to be used to activate a profile + + + family + 1.0.0 + String + The general family of the OS to be used to activate a profile (e.g. 'windows') + + + arch + 1.0.0 + String + The architecture of the OS to be used to activate a profile + + + version + 1.0.0 + String + The version of the OS to be used to activate a profile + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.0.0.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.0.0.xml new file mode 100644 index 00000000..91492a92 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.0.0.xml @@ -0,0 +1,150 @@ + + + + + + + 4.0.0 + + + + central + Central Repository + https://repo.maven.apache.org/maven2 + default + + false + + + + + + + central + Central Repository + https://repo.maven.apache.org/maven2 + default + + false + + + never + + + + + + ${project.basedir}/target + ${project.build.directory}/classes + ${project.artifactId}-${project.version} + ${project.build.directory}/test-classes + ${project.basedir}/src/main/java + ${project.basedir}/src/main/scripts + ${project.basedir}/src/test/java + + + ${project.basedir}/src/main/resources + + + + + ${project.basedir}/src/test/resources + + + + + + + + maven-antrun-plugin + 1.3 + + + maven-assembly-plugin + 2.2-beta-5 + + + maven-dependency-plugin + 2.8 + + + maven-release-plugin + 2.3.2 + + + + + + + ${project.build.directory}/site + + + + + + release-profile + + + + performRelease + true + + + + + + + true + maven-source-plugin + + + attach-sources + + jar + + + + + + true + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + + true + maven-deploy-plugin + + true + + + + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/site/apt/index.apt b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/site/apt/index.apt new file mode 100644 index 00000000..64cb805c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/site/apt/index.apt @@ -0,0 +1,187 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one +~~ or more contributor license agreements. See the NOTICE file +~~ distributed with this work for additional information +~~ regarding copyright ownership. The ASF licenses this file +~~ to you under the Apache License, Version 2.0 (the +~~ "License"); you may not use this file except in compliance +~~ with the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, +~~ software distributed under the License is distributed on an +~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +~~ KIND, either express or implied. See the License for the +~~ specific language governing permissions and limitations +~~ under the License. + + ----- + Introduction + ----- + Hervé Boutemy + ----- + 2013-03-19 + ----- + +Maven Model Builder + + The effective model builder, with profile activation, inheritance, interpolation, ... + + The main component is <<>> + ({{{./apidocs/org/apache/maven/model/building/ModelBuilder.html}javadoc}}, + {{{./xref/org/apache/maven/model/building/ModelBuilder.html}source}}), + with its <<>> implementation + ({{{./apidocs/org/apache/maven/model/building/DefaultModelBuilder.html}javadoc}}, + {{{./xref/org/apache/maven/model/building/DefaultModelBuilder.html}source}}) + that manages the steps sequence. + + The sequence is divided into 2 phases: + + * phase 1 + + ** profile activation: see {{{./apidocs/org/apache/maven/model/profile/activation/package-summary.html}available activators}}. + Notice that model interpolation hasn't happened yet, then interpolation for file-based activation is limited to + <<<$\{basedir}>>> (since Maven 3), System properties and request properties + + ** raw model validation: <<>> ({{{./apidocs/org/apache/maven/model/validation/ModelValidator.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/validation/DefaultModelValidator.html}source}}) + + ** model normalization - merge duplicates: <<>> ({{{./apidocs/org/apache/maven/model/normalization/ModelNormalizer.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/normalization/DefaultModelNormalizer.html}source}}) + + ** profile injection: <<>> ({{{./apidocs/org/apache/maven/model/profile/ProfileInjector.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/profile/DefaultProfileInjector.html}source}}) + + ** parent resolution until {{{./super-pom.html}super-pom}} + + ** inheritance assembly: <<>> ({{{./apidocs/org/apache/maven/model/inheritance/InheritanceAssembler.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.html}source}}) + + ** model interpolation (see below) + + ** url normalization: <<>> ({{{./apidocs/org/apache/maven/model/path/UrlNormalizer.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/path/DefaultUrlNormalizer.html}source}}) + + [] + + * phase 2, with optional plugin processing + + ** model path translation: <<>> ({{{./apidocs/org/apache/maven/model/path/ModelPathTranslator.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/path/DefaultModelPathTranslator.html}source}}) + + ** plugin management injection: <<>> ({{{./apidocs/org/apache/maven/model/management/PluginManagementInjector.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/management/DefaultPluginManagementInjector.html}source}}) + + ** <(optional)> lifecycle bindings injection: <<>> ({{{./apidocs/org/apache/maven/model/plugin/LifecycleBindingsInjector.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.html}source}}) + + ** dependency management import (for dependencies of type <<>> in the <<<\>>> section) + + ** dependency management injection: <<>> ({{{./apidocs/org/apache/maven/model/management/DependencyManagementInjector.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/management/DefaultDependencyManagementInjector.html}source}}) + + ** model normalization - inject default values: <<>> ({{{./apidocs/org/apache/maven/model/normalization/ModelNormalizer.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/normalization/DefaultModelNormalizer.html}source}}) + + ** <(optional)> reports configuration: <<>> ({{{./apidocs/org/apache/maven/model/plugin/ReportConfigurationExpander.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/plugin/DefaultReportConfigurationExpander.html}source}}) + + ** <(optional)> reports conversion to decoupled site plugin: <<>> ({{{./apidocs/org/apache/maven/model/plugin/ReportingConverter.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/plugin/DefaultReportingConverter.html}source}}) + + ** <(optional)> plugins configuration: <<>> ({{{./apidocs/org/apache/maven/model/plugin/PluginConfigurationExpander.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/plugin/DefaultPluginConfigurationExpander.html}source}}) + + ** effective model validation: <<>> ({{{./apidocs/org/apache/maven/model/validation/ModelValidator.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/validation/DefaultModelValidator.html}source}}) + + [] + + [] + + +* Model Interpolation + + Model Interpolation consists in replacing <<<$\{...\}>>> with calculated value. It is done in <<>> + ({{{./apidocs/org/apache/maven/model/interpolation/StringSearchModelInterpolator.html}javadoc}}, + {{{./xref/org/apache/maven/model/interpolation/StringSearchModelInterpolator.html}source}}). + + Notice that model interpolation happens profile activation, then profile activation doesn't benefit from every values: + interpolation for file-based activation is limited to <<<$\{basedir}>>> (which was introduced in Maven 3 and is not deprecated + in this context), System properties and request properties. + + Values are evaluated in sequence from different syntaxes: + +*----+------+------+ +|| value || evaluation result || common examples || +*----+------+------+ +| <<>>\ +<<>> ()\ +<<<*>>> () | POM content (see {{{../maven-model/maven.html}POM reference}}) | <<<$\{project.version\}>>>\ + | | <<<$\{project.build.finalName\}>>>\ + | | <<<$\{project.artifactId\}>>>\ + | | <<<$\{project.build.directory\}>>> | +*----+------+------+ +| <<>>\ +<<>> ()\ +<<>> () | the directory containing the <<>> file | <<<$\{project.basedir\}>>> | +*----+------+------+ +| <<>>\ +<<>> () | the directory containing the <<>> file as URI | <<<$\{project.baseUri\}>>> | +*----+------+------+ +| <<>>\ +<<>> | the UTC timestamp of build start, in <<>> default format, which can be overridden with <<>> POM property | <<<$\{maven.build.timestamp\}>>> | +*----+------+------+ +| <<<*>>> | user properties, set from CLI with <<<-Dproperty=value>>> | <<<$\{skipTests\}>>> | +*----+------+------+ +| <<<*>>> | model properties, such as project properties set in the pom | <<<$\{any.key\}>>> | +*----+------+------+ +| <<>> | The path to the current Maven home. | <<<$\{maven.home\}>>> | +*----+------+------+ +| <<>> | The version number of the current Maven execution <(since 3.0.4)>. For example, "<<<3.0.5>>>". | <<<$\{maven.version\}>>> | +*----+------+------+ +| <<>> | The full build version of the current Maven execution <(since 3.0.4)>. For example, "<<>>". | <<<$\{maven.build.version\}>>> | +*----+------+------+ +| <<<*>>> | Java system properties (see {{{http://download.oracle.com/javase/6/docs/api/java/lang/System.html#getProperties()}JDK reference}}) | <<<$\{user.home\}>>>\ + | | <<<$\{java.home\}>>> | +*----+------+------+ +| <<>>\ +<<<*>>> | environment variables | <<<$\{env.PATH\}>>> | +*----+------+------+ +| <<>> | Local user settings (see {{{../maven-settings/settings.xml/settings.html}settings reference}}) | <<<$\{settings.localRepository\}>>> | +*----+------+------+ + +** Notice + + * after model interpolation, <<<$\{...\}>>> content can remain in the model that will be evaluated later + when setting plugin parameters. This happens in particular with <<>> values for + {{{../maven-settings/settings.html}Settings Model}}, + + * encoding configuration have been defined as POM properties looking like POM content but not added to POM model to maintain + compatibility with previous Maven versions: + + * <<<$\{project.build.sourceEncoding\}>>> for + {{{http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding}source files encoding}} + (defaults to platform encoding) + + * <<<$\{project.reporting.outputEncoding\}>>> for + {{{https://cwiki.apache.org/confluence/display/MAVENOLD/Reporting+Encoding+Configuration}reporting output files encoding}} + (defaults to <<>>) + + [] + + [] diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/site/apt/super-pom.apt.vm b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/site/apt/super-pom.apt.vm new file mode 100644 index 00000000..df86d70e --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/site/apt/super-pom.apt.vm @@ -0,0 +1,30 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one +~~ or more contributor license agreements. See the NOTICE file +~~ distributed with this work for additional information +~~ regarding copyright ownership. The ASF licenses this file +~~ to you under the Apache License, Version 2.0 (the +~~ "License"); you may not use this file except in compliance +~~ with the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, +~~ software distributed under the License is distributed on an +~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +~~ KIND, either express or implied. See the License for the +~~ specific language governing permissions and limitations +~~ under the License. + + ----- + Super POM + ----- + Hervé Boutemy + ----- + 2011-09-12 + ----- + +Super POM + + All models implicitly inherit from a super-POM: + +%{snippet|id=superpom|file=${project.build.sourceDirectory}/../resources/org/apache/maven/model/pom-4.0.0.xml} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/site/site.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/site/site.xml new file mode 100644 index 00000000..04f54455 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/site/site.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/building/ComplexActivationTest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/building/ComplexActivationTest.java new file mode 100644 index 00000000..9ef31b3d --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/building/ComplexActivationTest.java @@ -0,0 +1,60 @@ +package org.apache.maven.model.building; + + /* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.TestCase; + +import java.io.File; +import java.util.Properties; + +/** + * @author Konstantin Perikov + */ +public class ComplexActivationTest + extends TestCase +{ + + private File getPom( String name ) + { + return new File( "src/test/resources/poms/factory/" + name + ".xml" ).getAbsoluteFile(); + } + + public void testAndConditionInActivation() + throws Exception + { + Properties sysProperties = new Properties(); + sysProperties.setProperty( "myproperty", "test" ); + + ModelBuilder builder = new DefaultModelBuilderFactory().newInstance(); + assertNotNull( builder ); + + DefaultModelBuildingRequest request = new DefaultModelBuildingRequest(); + request.setProcessPlugins( true ); + request.setPomFile( getPom( "complex" ) ); + request.setSystemProperties( sysProperties ); + + ModelBuildingResult result = builder.build( request ); + assertNotNull( result ); + assertNotNull( result.getEffectiveModel() ); + assertEquals( "activated-1", result.getEffectiveModel().getProperties().get( "profile.file" ) ); + assertNull( result.getEffectiveModel().getProperties().get( "profile.miss" ) ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/building/DefaultModelBuilderFactoryTest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/building/DefaultModelBuilderFactoryTest.java new file mode 100644 index 00000000..90b65a4c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/building/DefaultModelBuilderFactoryTest.java @@ -0,0 +1,59 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +import org.codehaus.plexus.util.xml.Xpp3Dom; + +import junit.framework.TestCase; + +/** + * @author Benjamin Bentmann + */ +public class DefaultModelBuilderFactoryTest + extends TestCase +{ + + private File getPom( String name ) + { + return new File( "src/test/resources/poms/factory/" + name + ".xml" ).getAbsoluteFile(); + } + + public void testCompleteWiring() + throws Exception + { + ModelBuilder builder = new DefaultModelBuilderFactory().newInstance(); + assertNotNull( builder ); + + DefaultModelBuildingRequest request = new DefaultModelBuildingRequest(); + request.setProcessPlugins( true ); + request.setPomFile( getPom( "simple" ) ); + + ModelBuildingResult result = builder.build( request ); + assertNotNull( result ); + assertNotNull( result.getEffectiveModel() ); + assertEquals( "activated", result.getEffectiveModel().getProperties().get( "profile.file" ) ); + Xpp3Dom conf = (Xpp3Dom) result.getEffectiveModel().getBuild().getPlugins().get( 0 ).getConfiguration(); + assertEquals( "1.5", conf.getChild( "source" ).getValue() ); + assertEquals( " 1.5 ", conf.getChild( "target" ).getValue() ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java new file mode 100644 index 00000000..bb0ccff9 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java @@ -0,0 +1,89 @@ +package org.apache.maven.model.building; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.List; + +import org.apache.maven.model.Model; + + +/** + * A simple model problem collector for testing the model building components. + * + * @author Benjamin Bentmann + */ +public class SimpleProblemCollector + implements ModelProblemCollector +{ + private Model model; + + private List warnings = new ArrayList(); + + private List errors = new ArrayList(); + + private List fatals = new ArrayList(); + + public SimpleProblemCollector() + { + } + + public SimpleProblemCollector( Model model ) + { + this.model = model; + } + + public Model getModel() + { + return model; + } + + public List getWarnings() + { + return warnings; + } + + public List getErrors() + { + return errors; + } + + public List getFatals() + { + return fatals; + } + + public void add( ModelProblemCollectorRequest req ) + { + switch ( req.getSeverity() ) + { + case FATAL: + fatals.add( req.getMessage() ); + break; + case ERROR: + errors.add( req.getMessage() ); + break; + case WARNING: + warnings.add( req.getMessage() ); + break; + } + + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java new file mode 100644 index 00000000..1aef12ec --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java @@ -0,0 +1,108 @@ +package org.apache.maven.model.inheritance; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.SimpleProblemCollector; +import org.apache.maven.model.io.ModelParseException; +import org.apache.maven.model.io.ModelReader; +import org.apache.maven.model.io.ModelWriter; +import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.util.IOUtil; +import org.custommonkey.xmlunit.XMLAssert; +import org.custommonkey.xmlunit.XMLUnit; + +/** + * @author Hervé Boutemy + */ +public class DefaultInheritanceAssemblerTest + extends PlexusTestCase +{ + private ModelReader reader; + + private ModelWriter writer; + + private InheritanceAssembler assembler; + + @Override + protected void setUp() + throws Exception + { + super.setUp(); + + reader = lookup( ModelReader.class ); + writer = lookup( ModelWriter.class ); + assembler = lookup( InheritanceAssembler.class ); + } + + private File getPom( String name ) + { + return getTestFile( "src/test/resources/poms/inheritance/" + name + ".xml" ); + } + + private Model getModel( String name ) + throws ModelParseException, IOException + { + return reader.read( getPom( name ), null ); + } + + public void testPluginConfiguration() + throws Exception + { + Model parent = getModel( "plugin-configuration-parent" ); + + Model child = getModel( "plugin-configuration-child" ); + + SimpleProblemCollector problems = new SimpleProblemCollector(); + + assembler.assembleModelInheritance( child, parent, null, problems ); + + File actual = getTestFile( "target/test-classes/poms/inheritance/plugin-configuration-actual.xml" ); + + writer.write( actual, null, child ); + + // check with getPom( "plugin-configuration-effective" ) + Reader control = null; + Reader test = null; + try + { + File expected = getPom( "plugin-configuration-expected" ); + control = new InputStreamReader( new FileInputStream( expected ), "UTF-8" ); + + test = new InputStreamReader( new FileInputStream( actual ), "UTF-8" ); + + XMLUnit.setIgnoreComments( true ); + XMLUnit.setIgnoreWhitespace( true ); + XMLAssert.assertXMLEqual( control, test ); + } + catch ( IOException ioe ) + { + IOUtil.close( control ); + IOUtil.close( test ); + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/AbstractModelInterpolatorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/AbstractModelInterpolatorTest.java new file mode 100644 index 00000000..99842dfe --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/AbstractModelInterpolatorTest.java @@ -0,0 +1,494 @@ +package org.apache.maven.model.interpolation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Build; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Model; +import org.apache.maven.model.Organization; +import org.apache.maven.model.Repository; +import org.apache.maven.model.Resource; +import org.apache.maven.model.Scm; +import org.apache.maven.model.building.DefaultModelBuildingRequest; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.SimpleProblemCollector; +import org.apache.maven.model.path.PathTranslator; +import org.codehaus.plexus.PlexusTestCase; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; +import java.util.TimeZone; + +/** + * @author jdcasey + */ +public abstract class AbstractModelInterpolatorTest + extends PlexusTestCase +{ + private Properties context; + + protected void setUp() + throws Exception + { + super.setUp(); + + context = new Properties(); + context.put( "basedir", "myBasedir" ); + context.put( "project.baseUri", "myBaseUri" ); + } + + + protected void assertProblemFree( SimpleProblemCollector collector ) + { + assertEquals( "Expected no errors", 0, collector.getErrors().size() ); + assertEquals( "Expected no warnings", 0, collector.getWarnings().size() ); + assertEquals( "Expected no fatals", 0, collector.getFatals().size() ); + } + + protected void assertColllectorState( int numFatals, int numErrors, int numWarnings, + SimpleProblemCollector collector ) + { + assertEquals( "Errors", numErrors, collector.getErrors().size() ); + assertEquals( "Warnings", numWarnings, collector.getWarnings().size() ); + assertEquals( "Fatals", numFatals, collector.getFatals().size() ); + } + + private ModelBuildingRequest createModelBuildingRequest( Properties p ) + { + ModelBuildingRequest config = new DefaultModelBuildingRequest(); + if ( p != null ) + { + config.setSystemProperties( p ); + } + return config; + } + + public void testDefaultBuildTimestampFormatShouldFormatTimeIn24HourFormat() + { + Calendar cal = Calendar.getInstance(); + cal.setTimeZone(TimeZone.getTimeZone("UTC")); + cal.set( Calendar.HOUR, 12 ); + cal.set( Calendar.AM_PM, Calendar.AM ); + + // just to make sure all the bases are covered... + cal.set( Calendar.HOUR_OF_DAY, 0 ); + cal.set( Calendar.MINUTE, 16 ); + cal.set( Calendar.SECOND, 0 ); + cal.set( Calendar.YEAR, 1976 ); + cal.set( Calendar.MONTH, Calendar.NOVEMBER ); + cal.set( Calendar.DATE, 11 ); + + Date firstTestDate = cal.getTime(); + + cal.set( Calendar.HOUR, 11 ); + cal.set( Calendar.AM_PM, Calendar.PM ); + + // just to make sure all the bases are covered... + cal.set( Calendar.HOUR_OF_DAY, 23 ); + + Date secondTestDate = cal.getTime(); + + SimpleDateFormat format = + new SimpleDateFormat( MavenBuildTimestamp.DEFAULT_BUILD_TIMESTAMP_FORMAT ); + format.setTimeZone(TimeZone.getTimeZone("UTC")); + assertEquals( "1976-11-11T00:16:00Z", format.format( firstTestDate ) ); + assertEquals( "1976-11-11T23:16:00Z", format.format( secondTestDate ) ); + } + + public void testDefaultBuildTimestampFormatWithLocalTimeZoneMidnightRollover() + { + Calendar cal = Calendar.getInstance(); + cal.setTimeZone(TimeZone.getTimeZone("Europe/Berlin")); + + cal.set( Calendar.HOUR_OF_DAY, 1 ); + cal.set( Calendar.MINUTE, 16 ); + cal.set( Calendar.SECOND, 0 ); + cal.set( Calendar.YEAR, 2014 ); + cal.set( Calendar.MONTH, Calendar.JUNE ); + cal.set( Calendar.DATE, 16 ); + + Date firstTestDate = cal.getTime(); + + cal.set( Calendar.MONTH, Calendar.NOVEMBER ); + + Date secondTestDate = cal.getTime(); + + SimpleDateFormat format = + new SimpleDateFormat( MavenBuildTimestamp.DEFAULT_BUILD_TIMESTAMP_FORMAT ); + format.setTimeZone(TimeZone.getTimeZone("UTC")); + assertEquals( "2014-06-15T23:16:00Z", format.format( firstTestDate ) ); + assertEquals( "2014-11-16T00:16:00Z", format.format( secondTestDate ) ); + } + + public void testShouldNotThrowExceptionOnReferenceToNonExistentValue() + throws Exception + { + Model model = new Model(); + + Scm scm = new Scm(); + scm.setConnection( "${test}/somepath" ); + + model.setScm( scm ); + + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); + + assertProblemFree( collector ); + assertEquals( "${test}/somepath", out.getScm().getConnection() ); + } + + public void testShouldThrowExceptionOnRecursiveScmConnectionReference() + throws Exception + { + Model model = new Model(); + + Scm scm = new Scm(); + scm.setConnection( "${project.scm.connection}/somepath" ); + + model.setScm( scm ); + + try + { + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector ); + assertColllectorState( 0, 1, 0, collector ); + } + catch ( Exception e ) + { + + } + } + + public void testShouldNotThrowExceptionOnReferenceToValueContainingNakedExpression() + throws Exception + { + Model model = new Model(); + + Scm scm = new Scm(); + scm.setConnection( "${test}/somepath" ); + + model.setScm( scm ); + + model.addProperty( "test", "test" ); + + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); + + assertProblemFree( collector ); + + assertEquals( "test/somepath", out.getScm().getConnection() ); + } + + public void testShouldInterpolateOrganizationNameCorrectly() + throws Exception + { + String orgName = "MyCo"; + + Model model = new Model(); + model.setName( "${pom.organization.name} Tools" ); + + Organization org = new Organization(); + org.setName( orgName ); + + model.setOrganization( org ); + + ModelInterpolator interpolator = createInterpolator(); + + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), + new SimpleProblemCollector() ); + + assertEquals( orgName + " Tools", out.getName() ); + } + + public void testShouldInterpolateDependencyVersionToSetSameAsProjectVersion() + throws Exception + { + Model model = new Model(); + model.setVersion( "3.8.1" ); + + Dependency dep = new Dependency(); + dep.setVersion( "${version}" ); + + model.addDependency( dep ); + + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); + assertColllectorState(0, 0, 1, collector ); + + assertEquals( "3.8.1", ( out.getDependencies().get( 0 ) ).getVersion() ); + } + + public void testShouldNotInterpolateDependencyVersionWithInvalidReference() + throws Exception + { + Model model = new Model(); + model.setVersion( "3.8.1" ); + + Dependency dep = new Dependency(); + dep.setVersion( "${something}" ); + + model.addDependency( dep ); + + /* + // This is the desired behaviour, however there are too many crappy poms in the repo and an issue with the + // timing of executing the interpolation + + try + { + new RegexBasedModelInterpolator().interpolate( model, context ); + fail( "Should have failed to interpolate with invalid reference" ); + } + catch ( ModelInterpolationException expected ) + { + assertTrue( true ); + } + */ + + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); + + assertEquals( "${something}", ( out.getDependencies().get( 0 ) ).getVersion() ); + } + + public void testTwoReferences() + throws Exception + { + Model model = new Model(); + model.setVersion( "3.8.1" ); + model.setArtifactId( "foo" ); + + Dependency dep = new Dependency(); + dep.setVersion( "${artifactId}-${version}" ); + + model.addDependency( dep ); + + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); + assertColllectorState( 0, 0, 2, collector ); + + assertEquals( "foo-3.8.1", ( out.getDependencies().get( 0 ) ).getVersion() ); + } + + public void testBasedir() + throws Exception + { + Model model = new Model(); + model.setVersion( "3.8.1" ); + model.setArtifactId( "foo" ); + + Repository repository = new Repository(); + + repository.setUrl( "file://localhost/${basedir}/temp-repo" ); + + model.addRepository( repository ); + + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); + + assertEquals( "file://localhost/myBasedir/temp-repo", ( out.getRepositories().get( 0 ) ).getUrl() ); + } + + public void testBaseUri() + throws Exception + { + Model model = new Model(); + model.setVersion( "3.8.1" ); + model.setArtifactId( "foo" ); + + Repository repository = new Repository(); + + repository.setUrl( "${project.baseUri}/temp-repo" ); + + model.addRepository( repository ); + + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); + + assertEquals( "myBaseUri/temp-repo", ( out.getRepositories().get( 0 ) ).getUrl() ); + } + + public void testEnvars() + throws Exception + { + Properties context = new Properties(); + + context.put( "env.HOME", "/path/to/home" ); + + Model model = new Model(); + + Properties modelProperties = new Properties(); + + modelProperties.setProperty( "outputDirectory", "${env.HOME}" ); + + model.setProperties( modelProperties ); + + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); + + assertEquals( "/path/to/home", out.getProperties().getProperty( "outputDirectory" ) ); + } + + public void testEnvarExpressionThatEvaluatesToNullReturnsTheLiteralString() + throws Exception + { + Model model = new Model(); + + Properties modelProperties = new Properties(); + + modelProperties.setProperty( "outputDirectory", "${env.DOES_NOT_EXIST}" ); + + model.setProperties( modelProperties ); + + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); + + assertEquals( out.getProperties().getProperty( "outputDirectory" ), "${env.DOES_NOT_EXIST}" ); + } + + public void testExpressionThatEvaluatesToNullReturnsTheLiteralString() + throws Exception + { + Model model = new Model(); + + Properties modelProperties = new Properties(); + + modelProperties.setProperty( "outputDirectory", "${DOES_NOT_EXIST}" ); + + model.setProperties( modelProperties ); + + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); + + assertEquals( out.getProperties().getProperty( "outputDirectory" ), "${DOES_NOT_EXIST}" ); + } + + public void testShouldInterpolateSourceDirectoryReferencedFromResourceDirectoryCorrectly() + throws Exception + { + Model model = new Model(); + + Build build = new Build(); + build.setSourceDirectory( "correct" ); + + Resource res = new Resource(); + res.setDirectory( "${project.build.sourceDirectory}" ); + + build.addResource( res ); + + Resource res2 = new Resource(); + res2.setDirectory( "${pom.build.sourceDirectory}" ); + + build.addResource( res2 ); + + Resource res3 = new Resource(); + res3.setDirectory( "${build.sourceDirectory}" ); + + build.addResource( res3 ); + + model.setBuild( build ); + + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector ); + assertColllectorState( 0, 0, 2, collector ); + + + List outResources = out.getBuild().getResources(); + Iterator resIt = outResources.iterator(); + + assertEquals( build.getSourceDirectory(), resIt.next().getDirectory() ); + assertEquals( build.getSourceDirectory(), resIt.next().getDirectory() ); + assertEquals( build.getSourceDirectory(), resIt.next().getDirectory() ); + } + + public void testShouldInterpolateUnprefixedBasedirExpression() + throws Exception + { + File basedir = new File( "/test/path" ); + Model model = new Model(); + Dependency dep = new Dependency(); + dep.setSystemPath( "${basedir}/artifact.jar" ); + + model.addDependency( dep ); + + ModelInterpolator interpolator = createInterpolator(); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + Model result = interpolator.interpolateModel( model, basedir, createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); + + + List rDeps = result.getDependencies(); + assertNotNull( rDeps ); + assertEquals( 1, rDeps.size() ); + assertEquals( new File( basedir, "artifact.jar" ).getAbsolutePath(), + new File( rDeps.get( 0 ).getSystemPath() ).getAbsolutePath() ); + } + + protected abstract ModelInterpolator createInterpolator( PathTranslator translator ) + throws Exception; + + protected abstract ModelInterpolator createInterpolator() + throws Exception; + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/MavenBuildTimestampTest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/MavenBuildTimestampTest.java new file mode 100644 index 00000000..8af32fc5 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/MavenBuildTimestampTest.java @@ -0,0 +1,38 @@ +package org.apache.maven.model.interpolation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Date; +import java.util.Properties; + +import junit.framework.TestCase; + +public class MavenBuildTimestampTest + extends TestCase +{ + public void testMavenBuildTimestampUsesUTC() + { + Properties interpolationProperties = new Properties(); + interpolationProperties.setProperty( "maven.build.timestamp.format", "yyyyMMdd'T'HHmm'Z'" ); + MavenBuildTimestamp timestamp = new MavenBuildTimestamp( new Date(), interpolationProperties ); + String formattedTimestamp = timestamp.formattedTimestamp(); + assertTrue( "We expect the UTC marker at the end of the timestamp.", formattedTimestamp.endsWith( "Z" ) ); + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java new file mode 100644 index 00000000..c4cae3d4 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java @@ -0,0 +1,505 @@ +package org.apache.maven.model.interpolation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.InputLocation; +import org.apache.maven.model.InputSource; +import org.apache.maven.model.Model; +import org.apache.maven.model.building.DefaultModelBuildingRequest; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.SimpleProblemCollector; + +import java.io.File; +import java.util.*; +import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Future; +import java.util.concurrent.FutureTask; + +/** + * @author jdcasey + * @author Benjamin Bentmann + */ +public class StringSearchModelInterpolatorTest + extends AbstractModelInterpolatorTest +{ + + protected ModelInterpolator interpolator; + + @Override + protected void setUp() + throws Exception + { + super.setUp(); + interpolator = lookup( ModelInterpolator.class ); + } + + + protected ModelInterpolator createInterpolator( org.apache.maven.model.path.PathTranslator translator ) + throws Exception + { + return this.interpolator; + } + + protected ModelInterpolator createInterpolator() + throws Exception + { + return this.interpolator; + } + + public void testInterpolateStringArray() + throws Exception + { + Model model = new Model(); + + Properties p = new Properties(); + p.setProperty( "key", "value" ); + p.setProperty( "key2", "value2" ); + + String[] values = { "${key}", "${key2}" }; + + StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); + + ModelBuildingRequest config = createModelBuildingRequest(p); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + interpolator.interpolateObject( values, model, new File( "." ), config, collector ); + assertProblemFree( collector ); + + assertEquals( "value", values[0] ); + assertEquals( "value2", values[1] ); + } + + private ModelBuildingRequest createModelBuildingRequest( Properties p ) + { + ModelBuildingRequest config = new DefaultModelBuildingRequest(); + config.setSystemProperties( p ); + return config; + } + + public void testInterpolateObjectWithStringArrayField() + throws Exception + { + Model model = new Model(); + + Properties p = new Properties(); + p.setProperty( "key", "value" ); + p.setProperty( "key2", "value2" ); + + String[] values = { "${key}", "${key2}" }; + + ObjectWithStringArrayField obj = new ObjectWithStringArrayField( values ); + + StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); + + ModelBuildingRequest config = createModelBuildingRequest( p ); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + interpolator.interpolateObject( obj, model, new File( "." ), config, collector ); + assertProblemFree( collector ); + + assertEquals( "value", obj.values[0] ); + assertEquals( "value2", obj.values[1] ); + } + + public void testInterpolateObjectWithStringListField() + throws Exception + { + Model model = new Model(); + + Properties p = new Properties(); + p.setProperty( "key", "value" ); + p.setProperty( "key2", "value2" ); + + List values = new ArrayList(); + values.add( "${key}" ); + values.add( "${key2}" ); + + ObjectWithListField obj = new ObjectWithListField( values ); + + StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); + + ModelBuildingRequest config = createModelBuildingRequest( p ); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + interpolator.interpolateObject( obj, model, new File( "." ), config, collector ); + assertProblemFree( collector ); + + assertEquals( "value", obj.values.get( 0 ) ); + assertEquals( "value2", obj.values.get( 1 ) ); + } + + public void testInterpolateObjectWithStringListFieldAndOneLiteralValue() + throws Exception + { + Model model = new Model(); + + Properties p = new Properties(); + p.setProperty( "key", "value" ); + p.setProperty( "key2", "value2" ); + + List values = new ArrayList(); + values.add( "key" ); + values.add( "${key2}" ); + + ObjectWithListField obj = new ObjectWithListField( values ); + + StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); + + ModelBuildingRequest config = createModelBuildingRequest( p ); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + interpolator.interpolateObject( obj, model, new File( "." ), config, collector ); + assertProblemFree( collector ); + + assertEquals( "key", obj.values.get( 0 ) ); + assertEquals( "value2", obj.values.get( 1 ) ); + } + + public void testInterpolateObjectWithUnmodifiableStringListField() + throws Exception + { + Model model = new Model(); + + Properties p = new Properties(); + p.setProperty( "key", "value" ); + p.setProperty( "key2", "value2" ); + + List values = Collections.unmodifiableList( Collections.singletonList( "${key}" ) ); + + ObjectWithListField obj = new ObjectWithListField( values ); + + StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); + + ModelBuildingRequest config = createModelBuildingRequest( p ); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + interpolator.interpolateObject( obj, model, new File( "." ), config, collector ); + assertProblemFree( collector ); + + assertEquals( "${key}", obj.values.get( 0 ) ); + } + + public void testInterpolateObjectWithStringArrayListField() + throws Exception + { + Model model = new Model(); + + Properties p = new Properties(); + p.setProperty( "key", "value" ); + p.setProperty( "key2", "value2" ); + p.setProperty( "key3", "value3" ); + p.setProperty( "key4", "value4" ); + + List values = new ArrayList(); + values.add( new String[] { "${key}", "${key2}" } ); + values.add( new String[] { "${key3}", "${key4}" } ); + + ObjectWithListField obj = new ObjectWithListField( values ); + + StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); + + ModelBuildingRequest config = createModelBuildingRequest( p ); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + interpolator.interpolateObject( obj, model, new File( "." ), config, collector ); + assertProblemFree( collector ); + + assertEquals( "value", ( (String[]) obj.values.get( 0 ) )[0] ); + assertEquals( "value2", ( (String[]) obj.values.get( 0 ) )[1] ); + assertEquals( "value3", ( (String[]) obj.values.get( 1 ) )[0] ); + assertEquals( "value4", ( (String[]) obj.values.get( 1 ) )[1] ); + } + + public void testInterpolateObjectWithStringToStringMapField() + throws Exception + { + Model model = new Model(); + + Properties p = new Properties(); + p.setProperty( "key", "value" ); + p.setProperty( "key2", "value2" ); + + Map values = new HashMap(); + values.put( "key", "${key}" ); + values.put( "key2", "${key2}" ); + + ObjectWithMapField obj = new ObjectWithMapField( values ); + + StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); + + ModelBuildingRequest config = createModelBuildingRequest( p ); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + interpolator.interpolateObject( obj, model, new File( "." ), config, collector ); + assertProblemFree( collector ); + + assertEquals( "value", obj.values.get( "key" ) ); + assertEquals( "value2", obj.values.get( "key2" ) ); + } + + public void testInterpolateObjectWithStringToStringMapFieldAndOneLiteralValue() + throws Exception + { + Model model = new Model(); + + Properties p = new Properties(); + p.setProperty( "key", "value" ); + p.setProperty( "key2", "value2" ); + + Map values = new HashMap(); + values.put( "key", "val" ); + values.put( "key2", "${key2}" ); + + ObjectWithMapField obj = new ObjectWithMapField( values ); + + StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); + + ModelBuildingRequest config = createModelBuildingRequest( p ); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + interpolator.interpolateObject( obj, model, new File( "." ), config, collector ); + assertProblemFree( collector ); + + assertEquals( "val", obj.values.get( "key" ) ); + assertEquals( "value2", obj.values.get( "key2" ) ); + } + + public void testInterpolateObjectWithUnmodifiableStringToStringMapField() + throws Exception + { + Model model = new Model(); + + Properties p = new Properties(); + p.setProperty( "key", "value" ); + p.setProperty( "key2", "value2" ); + + Map values = Collections.unmodifiableMap( Collections.singletonMap( "key", "${key}" ) ); + + ObjectWithMapField obj = new ObjectWithMapField( values ); + + StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); + + ModelBuildingRequest config = createModelBuildingRequest( p ); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + interpolator.interpolateObject( obj, model, new File( "." ), config, collector ); + assertProblemFree( collector ); + + assertEquals( "${key}", obj.values.get( "key" ) ); + } + + public void testInterpolateObjectWithStringToStringArrayMapField() + throws Exception + { + Model model = new Model(); + + Properties p = new Properties(); + p.setProperty( "key", "value" ); + p.setProperty( "key2", "value2" ); + p.setProperty( "key3", "value3" ); + p.setProperty( "key4", "value4" ); + + Map values = new HashMap(); + values.put( "key", new String[] { "${key}", "${key2}" } ); + values.put( "key2", new String[] { "${key3}", "${key4}" } ); + + ObjectWithMapField obj = new ObjectWithMapField( values ); + + StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); + + ModelBuildingRequest config = createModelBuildingRequest( p ); + + final SimpleProblemCollector collector = new SimpleProblemCollector(); + interpolator.interpolateObject( obj, model, new File( "." ), config, collector ); + assertProblemFree( collector ); + + assertEquals( "value", ( (String[]) obj.values.get( "key" ) )[0] ); + assertEquals( "value2", ( (String[]) obj.values.get( "key" ) )[1] ); + assertEquals( "value3", ( (String[]) obj.values.get( "key2" ) )[0] ); + assertEquals( "value4", ( (String[]) obj.values.get( "key2" ) )[1] ); + } + + + public void testConcurrentInterpolation() + throws Exception + { + final Model model = new Model(); + + final Properties p = new Properties(); + p.setProperty( "key", "value" ); + p.setProperty( "key2", "value2" ); + p.setProperty( "key3", "value3" ); + p.setProperty( "key4", "value4" ); + p.setProperty( "key5", "value5" ); + + final StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); + + + int numItems = 100; + final CountDownLatch countDownLatch = new CountDownLatch(1); + + List> futures = new ArrayList>(); + for ( int i = 0; i < numItems; i++ ) + { + Callable future = new Callable() + { + public SimpleProblemCollector call() + throws Exception + { + final ObjectWithMixedProtection obj = getValueList(); + final ModelBuildingRequest config = createModelBuildingRequest( p ); + + countDownLatch.await(); + final SimpleProblemCollector collector = new SimpleProblemCollector(); + interpolator.interpolateObject( obj, model, new File( "." ), config, collector ); + return collector; + } + }; + FutureTask task = new FutureTask( future ); + futures.add( task ); + new Thread( task ).start(); + } + countDownLatch.countDown(); // Start all the threads + for ( Future result : futures ) + { + SimpleProblemCollector problemCollector = result.get(); // ArrayIndexOutOfBoundsException are typical indication of threading issues + assertProblemFree( problemCollector ); + } + } + + private ObjectWithMixedProtection getValueList() + { + List values = new ArrayList(); + + values.add( new String[] { "${key}", "${key2}" } ); + values.add( new String[] { "${key3}", "${key4}" } ); + List values2 = new ArrayList(); + values.add( new String[] { "${key}", "${key2}" } ); + values.add( new String[] { "${key3}", "${key4}" } ); + List values3 = new ArrayList(); + values.add( new String[] { "${key}", "${key2}" } ); + values.add( new String[] { "${key3}", "${key4}" } ); + + return new ObjectWithMixedProtection( values, values2, values3, "${key5}" ); + } + + + private static final class ObjectWithStringArrayField + { + private final String[] values; + + public ObjectWithStringArrayField( String[] values ) + { + this.values = values; + } + } + + private static final class ObjectWithListField + { + private final List values; + + public ObjectWithListField( List values ) + { + this.values = values; + } + } + + private static final class ObjectWithMapField + { + private final Map values; + + public ObjectWithMapField( Map values ) + { + this.values = values; + } + } + + @SuppressWarnings( "unused" ) + private static final class ObjectWithMixedProtection + { + private List values1; + protected List values2; + List values3; + private String fooBar; + + private ObjectWithMixedProtection( List values1, List values2, List values3 ) + { + this.values1 = values1; + this.values2 = values2; + this.values3 = values3; + } + + private ObjectWithMixedProtection( List values1, List values2, List values3, String fooBar ) + { + this.values1 = values1; + this.values2 = values2; + this.values3 = values3; + this.fooBar = fooBar; + } + + public String getFooBar() + { + return fooBar; + } + } + + public void testFinalFieldsExcludedFromInterpolation() + { + Properties props = new Properties(); + props.setProperty( "expression", "value" ); + DefaultModelBuildingRequest request = new DefaultModelBuildingRequest(); + request.setUserProperties( props ); + + SimpleProblemCollector problems = new SimpleProblemCollector(); + StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator(); + interpolator.interpolateObject( new ClassWithFinalField(), new Model(), null, request, problems ); + + assertProblemFree( problems ); + } + + static class ClassWithFinalField + { + public static final String CONSTANT = "${expression}"; + } + + public void testLocationTrackerShouldBeExcludedFromInterpolation() + { + Properties props = new Properties(); + props.setProperty( "expression", "value" ); + DefaultModelBuildingRequest request = new DefaultModelBuildingRequest(); + request.setUserProperties( props ); + + InputSource source = new InputSource(); + source.setLocation( "${expression}" ); + source.setModelId( "${expression}" ); + Model model = new Model(); + model.setLocation( "", new InputLocation( 1, 1, source ) ); + + SimpleProblemCollector problems = new SimpleProblemCollector(); + StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator(); + interpolator.interpolateObject( model, model, null, request, problems ); + + assertProblemFree( problems ); + assertEquals( "${expression}", source.getLocation() ); + assertEquals( "${expression}", source.getModelId() ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/path/DefaultUrlNormalizerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/path/DefaultUrlNormalizerTest.java new file mode 100644 index 00000000..88fdc9cf --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/path/DefaultUrlNormalizerTest.java @@ -0,0 +1,85 @@ +package org.apache.maven.model.path; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.TestCase; + +/** + * @author Benjamin Bentmann + */ +public class DefaultUrlNormalizerTest + extends TestCase +{ + + private UrlNormalizer normalizer; + + @Override + protected void setUp() + throws Exception + { + super.setUp(); + + normalizer = new DefaultUrlNormalizer(); + } + + @Override + protected void tearDown() + throws Exception + { + normalizer = null; + + super.tearDown(); + } + + private String normalize( String url ) + { + return normalizer.normalize( url ); + } + + public void testNullSafe() + { + assertNull( normalize( null ) ); + } + + public void testTrailingSlash() + { + assertEquals( "", normalize( "" ) ); + assertEquals( "http://server.org/dir", normalize( "http://server.org/dir" ) ); + assertEquals( "http://server.org/dir/", normalize( "http://server.org/dir/" ) ); + } + + public void testRemovalOfParentRefs() + { + assertEquals( "http://server.org/child", normalize( "http://server.org/parent/../child" ) ); + assertEquals( "http://server.org/child", normalize( "http://server.org/grand/parent/../../child" ) ); + + assertEquals( "http://server.org//child", normalize( "http://server.org/parent/..//child" ) ); + assertEquals( "http://server.org/child", normalize( "http://server.org/parent//../child" ) ); + } + + public void testPreservationOfDoubleSlashes() + { + assertEquals( "scm:hg:ssh://localhost//home/user", normalize( "scm:hg:ssh://localhost//home/user" ) ); + assertEquals( "file:////UNC/server", normalize( "file:////UNC/server" ) ); + assertEquals( "[fetch=]http://server.org/[push=]ssh://server.org/", + normalize( "[fetch=]http://server.org/[push=]ssh://server.org/" ) ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java new file mode 100644 index 00000000..0ec3b326 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java @@ -0,0 +1,92 @@ +package org.apache.maven.model.profile.activation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Properties; + +import org.apache.maven.model.Profile; +import org.apache.maven.model.building.SimpleProblemCollector; +import org.apache.maven.model.profile.DefaultProfileActivationContext; +import org.apache.maven.model.profile.ProfileActivationContext; +import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.component.annotations.Component; + +/** + * Provides common services to test {@link ProfileActivator} implementations. + * + * @author Benjamin Bentmann + */ +public abstract class AbstractProfileActivatorTest + extends PlexusTestCase +{ + + private Class activatorClass; + + private String roleHint; + + protected T activator; + + public AbstractProfileActivatorTest( Class activatorClass ) + { + if ( activatorClass == null ) + { + throw new IllegalArgumentException( "class of profile activator to test is not specified" ); + } + + this.activatorClass = activatorClass; + + roleHint = activatorClass.getAnnotation( Component.class ).hint(); + } + + @Override + protected void setUp() + throws Exception + { + super.setUp(); + + activator = activatorClass.cast( lookup( ProfileActivator.class, roleHint ) ); + } + + @Override + protected void tearDown() + throws Exception + { + activator = null; + + super.tearDown(); + } + + protected ProfileActivationContext newContext( final Properties userProperties, final Properties systemProperties ) + { + DefaultProfileActivationContext context = new DefaultProfileActivationContext(); + return context.setUserProperties( userProperties ).setSystemProperties( systemProperties ); + } + + protected void assertActivation( boolean active, Profile profile, ProfileActivationContext context ) + { + SimpleProblemCollector problems = new SimpleProblemCollector(); + + assertEquals( active, activator.isActive( profile, context, problems ) ); + + assertEquals( problems.getErrors().toString(), 0, problems.getErrors().size() ); + assertEquals( problems.getWarnings().toString(), 0, problems.getWarnings().size() ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java new file mode 100644 index 00000000..440f120b --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java @@ -0,0 +1,185 @@ +package org.apache.maven.model.profile.activation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Properties; + +import org.apache.maven.model.Activation; +import org.apache.maven.model.Profile; + +/** + * Tests {@link JdkVersionProfileActivator}. + * + * @author Benjamin Bentmann + */ +public class JdkVersionProfileActivatorTest + extends AbstractProfileActivatorTest +{ + + public JdkVersionProfileActivatorTest() + { + super( JdkVersionProfileActivator.class ); + } + + private Profile newProfile( String jdkVersion ) + { + Activation a = new Activation(); + a.setJdk( jdkVersion ); + + Profile p = new Profile(); + p.setActivation( a ); + + return p; + } + + private Properties newProperties( String javaVersion ) + { + Properties props = new Properties(); + props.setProperty( "java.version", javaVersion ); + return props; + } + + public void testNullSafe() + throws Exception + { + Profile p = new Profile(); + + assertActivation( false, p, newContext( null, null ) ); + + p.setActivation( new Activation() ); + + assertActivation( false, p, newContext( null, null ) ); + } + + public void testPrefix() + throws Exception + { + Profile profile = newProfile( "1.4" ); + + assertActivation( true, profile, newContext( null, newProperties( "1.4" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.4.2" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.4.2_09" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.4.2_09-b03" ) ) ); + + assertActivation( false, profile, newContext( null, newProperties( "1.3" ) ) ); + + assertActivation( false, profile, newContext( null, newProperties( "1.5" ) ) ); + } + + public void testPrefixNegated() + throws Exception + { + Profile profile = newProfile( "!1.4" ); + + assertActivation( false, profile, newContext( null, newProperties( "1.4" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.4.2" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.4.2_09" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.4.2_09-b03" ) ) ); + + assertActivation( true, profile, newContext( null, newProperties( "1.3" ) ) ); + + assertActivation( true, profile, newContext( null, newProperties( "1.5" ) ) ); + } + + public void testVersionRangeInclusiveBounds() + throws Exception + { + Profile profile = newProfile( "[1.5,1.6]" ); + + assertActivation( false, profile, newContext( null, newProperties( "1.4" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.4.2" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.4.2_09" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.4.2_09-b03" ) ) ); + + assertActivation( true, profile, newContext( null, newProperties( "1.5" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.0" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09-b03" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.1" ) ) ); + + assertActivation( true, profile, newContext( null, newProperties( "1.6" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.6.0" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.6.0_09" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.6.0_09-b03" ) ) ); + } + + public void testVersionRangeExclusiveBounds() + throws Exception + { + Profile profile = newProfile( "(1.3,1.6)" ); + + assertActivation( false, profile, newContext( null, newProperties( "1.3" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.3.0" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.3.0_09" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.3.0_09-b03" ) ) ); + + assertActivation( true, profile, newContext( null, newProperties( "1.3.1" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.3.1_09" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.3.1_09-b03" ) ) ); + + assertActivation( true, profile, newContext( null, newProperties( "1.5" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.0" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09-b03" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.1" ) ) ); + + assertActivation( false, profile, newContext( null, newProperties( "1.6" ) ) ); + } + + public void testVersionRangeInclusiveLowerBound() + throws Exception + { + Profile profile = newProfile( "[1.5,)" ); + + assertActivation( false, profile, newContext( null, newProperties( "1.4" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.4.2" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.4.2_09" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.4.2_09-b03" ) ) ); + + assertActivation( true, profile, newContext( null, newProperties( "1.5" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.0" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09-b03" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.1" ) ) ); + + assertActivation( true, profile, newContext( null, newProperties( "1.6" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.6.0" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.6.0_09" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.6.0_09-b03" ) ) ); + } + + public void testVersionRangeExclusiveUpperBound() + throws Exception + { + Profile profile = newProfile( "(,1.6)" ); + + assertActivation( true, profile, newContext( null, newProperties( "1.5" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.0" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09-b03" ) ) ); + assertActivation( true, profile, newContext( null, newProperties( "1.5.1" ) ) ); + + assertActivation( false, profile, newContext( null, newProperties( "1.6" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.6.0" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.6.0_09" ) ) ); + assertActivation( false, profile, newContext( null, newProperties( "1.6.0_09-b03" ) ) ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java new file mode 100644 index 00000000..73ab967e --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java @@ -0,0 +1,185 @@ +package org.apache.maven.model.profile.activation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Properties; + +import org.apache.maven.model.Activation; +import org.apache.maven.model.ActivationProperty; +import org.apache.maven.model.Profile; + +/** + * Tests {@link PropertyProfileActivator}. + * + * @author Benjamin Bentmann + */ +public class PropertyProfileActivatorTest + extends AbstractProfileActivatorTest +{ + + public PropertyProfileActivatorTest() + { + super( PropertyProfileActivator.class ); + } + + private Profile newProfile( String key, String value ) + { + ActivationProperty ap = new ActivationProperty(); + ap.setName( key ); + ap.setValue( value ); + + Activation a = new Activation(); + a.setProperty( ap ); + + Profile p = new Profile(); + p.setActivation( a ); + + return p; + } + + private Properties newProperties( String key, String value ) + { + Properties props = new Properties(); + props.setProperty( key, value ); + return props; + } + + public void testNullSafe() + throws Exception + { + Profile p = new Profile(); + + assertActivation( false, p, newContext( null, null ) ); + + p.setActivation( new Activation() ); + + assertActivation( false, p, newContext( null, null ) ); + } + + public void testWithNameOnly_UserProperty() + throws Exception + { + Profile profile = newProfile( "prop", null ); + + assertActivation( true, profile, newContext( newProperties( "prop", "value" ), null ) ); + + assertActivation( false, profile, newContext( newProperties( "prop", "" ), null ) ); + + assertActivation( false, profile, newContext( newProperties( "other", "value" ), null ) ); + } + + public void testWithNameOnly_SystemProperty() + throws Exception + { + Profile profile = newProfile( "prop", null ); + + assertActivation( true, profile, newContext( null, newProperties( "prop", "value" ) ) ); + + assertActivation( false, profile, newContext( null, newProperties( "prop", "" ) ) ); + + assertActivation( false, profile, newContext( null, newProperties( "other", "value" ) ) ); + } + + public void testWithNegatedNameOnly_UserProperty() + throws Exception + { + Profile profile = newProfile( "!prop", null ); + + assertActivation( false, profile, newContext( newProperties( "prop", "value" ), null ) ); + + assertActivation( true, profile, newContext( newProperties( "prop", "" ), null ) ); + + assertActivation( true, profile, newContext( newProperties( "other", "value" ), null ) ); + } + + public void testWithNegatedNameOnly_SystemProperty() + throws Exception + { + Profile profile = newProfile( "!prop", null ); + + assertActivation( false, profile, newContext( null, newProperties( "prop", "value" ) ) ); + + assertActivation( true, profile, newContext( null, newProperties( "prop", "" ) ) ); + + assertActivation( true, profile, newContext( null, newProperties( "other", "value" ) ) ); + } + + public void testWithValue_UserProperty() + throws Exception + { + Profile profile = newProfile( "prop", "value" ); + + assertActivation( true, profile, newContext( newProperties( "prop", "value" ), null ) ); + + assertActivation( false, profile, newContext( newProperties( "prop", "other" ), null ) ); + + assertActivation( false, profile, newContext( newProperties( "prop", "" ), null ) ); + } + + public void testWithValue_SystemProperty() + throws Exception + { + Profile profile = newProfile( "prop", "value" ); + + assertActivation( true, profile, newContext( null, newProperties( "prop", "value" ) ) ); + + assertActivation( false, profile, newContext( null, newProperties( "prop", "other" ) ) ); + + assertActivation( false, profile, newContext( null, newProperties( "other", "" ) ) ); + } + + public void testWithNegatedValue_UserProperty() + throws Exception + { + Profile profile = newProfile( "prop", "!value" ); + + assertActivation( false, profile, newContext( newProperties( "prop", "value" ), null ) ); + + assertActivation( true, profile, newContext( newProperties( "prop", "other" ), null ) ); + + assertActivation( true, profile, newContext( newProperties( "prop", "" ), null ) ); + } + + public void testWithNegatedValue_SystemProperty() + throws Exception + { + Profile profile = newProfile( "prop", "!value" ); + + assertActivation( false, profile, newContext( null, newProperties( "prop", "value" ) ) ); + + assertActivation( true, profile, newContext( null, newProperties( "prop", "other" ) ) ); + + assertActivation( true, profile, newContext( null, newProperties( "other", "" ) ) ); + } + + public void testWithValue_UserPropertyDominantOverSystemProperty() + throws Exception + { + Profile profile = newProfile( "prop", "value" ); + + Properties props1 = newProperties( "prop", "value" ); + Properties props2 = newProperties( "prop", "other" ); + + assertActivation( true, profile, newContext( props1, props2 ) ); + + assertActivation( false, profile, newContext( props2, props1 ) ); + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java new file mode 100644 index 00000000..dde532d8 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java @@ -0,0 +1,630 @@ +package org.apache.maven.model.validation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.InputStream; +import java.util.List; + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.DefaultModelBuildingRequest; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.SimpleProblemCollector; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.codehaus.plexus.PlexusTestCase; + +/** + * @author Trygve Laugstøl + */ +public class DefaultModelValidatorTest + extends PlexusTestCase +{ + + private ModelValidator validator; + + private Model read( String pom ) + throws Exception + { + String resource = "/poms/validation/" + pom; + InputStream is = getClass().getResourceAsStream( resource ); + assertNotNull( "missing resource: " + resource, is ); + return new MavenXpp3Reader().read( is ); + } + + private SimpleProblemCollector validate( String pom ) + throws Exception + { + return validateEffective( pom, ModelBuildingRequest.VALIDATION_LEVEL_STRICT ); + } + + private SimpleProblemCollector validateRaw( String pom ) + throws Exception + { + return validateRaw( pom, ModelBuildingRequest.VALIDATION_LEVEL_STRICT ); + } + + private SimpleProblemCollector validateEffective( String pom, int level ) + throws Exception + { + ModelBuildingRequest request = new DefaultModelBuildingRequest().setValidationLevel( level ); + + SimpleProblemCollector problems = new SimpleProblemCollector( read( pom ) ); + + validator.validateEffectiveModel( problems.getModel(), request, problems ); + + return problems; + } + + private SimpleProblemCollector validateRaw( String pom, int level ) + throws Exception + { + ModelBuildingRequest request = new DefaultModelBuildingRequest().setValidationLevel( level ); + + SimpleProblemCollector problems = new SimpleProblemCollector( read( pom ) ); + + validator.validateRawModel( problems.getModel(), request, problems ); + + return problems; + } + + private void assertContains( String msg, String substring ) + { + assertTrue( "\"" + substring + "\" was not found in: " + msg, msg.contains( substring ) ); + } + + @Override + protected void setUp() + throws Exception + { + super.setUp(); + + validator = lookup( ModelValidator.class ); + } + + @Override + protected void tearDown() + throws Exception + { + this.validator = null; + + super.tearDown(); + } + + private void assertViolations( SimpleProblemCollector result, int fatals, int errors, int warnings ) + { + assertEquals( String.valueOf( result.getFatals() ), fatals, result.getFatals().size() ); + assertEquals( String.valueOf( result.getErrors() ), errors, result.getErrors().size() ); + assertEquals( String.valueOf( result.getWarnings() ), warnings, result.getWarnings().size() ); + } + + public void testMissingModelVersion() + throws Exception + { + SimpleProblemCollector result = validate( "missing-modelVersion-pom.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertEquals( "'modelVersion' is missing.", result.getErrors().get( 0 ) ); + } + + public void testBadModelVersion() + throws Exception + { + SimpleProblemCollector result = + validateRaw( "bad-modelVersion.xml", ModelBuildingRequest.VALIDATION_LEVEL_STRICT ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( "modelVersion" ) ); + } + + public void testMissingArtifactId() + throws Exception + { + SimpleProblemCollector result = validate( "missing-artifactId-pom.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertEquals( "'artifactId' is missing.", result.getErrors().get( 0 ) ); + } + + public void testMissingGroupId() + throws Exception + { + SimpleProblemCollector result = validate( "missing-groupId-pom.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertEquals( "'groupId' is missing.", result.getErrors().get( 0 ) ); + } + + public void testInvalidIds() + throws Exception + { + SimpleProblemCollector result = validate( "invalid-ids-pom.xml" ); + + assertViolations( result, 0, 2, 0 ); + + assertEquals( "'groupId' with value 'o/a/m' does not match a valid id pattern.", result.getErrors().get( 0 ) ); + + assertEquals( "'artifactId' with value 'm$-do$' does not match a valid id pattern.", result.getErrors().get( 1 ) ); + } + + public void testMissingType() + throws Exception + { + SimpleProblemCollector result = validate( "missing-type-pom.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertEquals( "'packaging' is missing.", result.getErrors().get( 0 ) ); + } + + public void testMissingVersion() + throws Exception + { + SimpleProblemCollector result = validate( "missing-version-pom.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertEquals( "'version' is missing.", result.getErrors().get( 0 ) ); + } + + public void testInvalidAggregatorPackaging() + throws Exception + { + SimpleProblemCollector result = validate( "invalid-aggregator-packaging-pom.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( "Aggregator projects require 'pom' as packaging." ) ); + } + + public void testMissingDependencyArtifactId() + throws Exception + { + SimpleProblemCollector result = validate( "missing-dependency-artifactId-pom.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( + "'dependencies.dependency.artifactId' for groupId:null:jar is missing" ) ); + } + + public void testMissingDependencyGroupId() + throws Exception + { + SimpleProblemCollector result = validate( "missing-dependency-groupId-pom.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( + "'dependencies.dependency.groupId' for null:artifactId:jar is missing" ) ); + } + + public void testMissingDependencyVersion() + throws Exception + { + SimpleProblemCollector result = validate( "missing-dependency-version-pom.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( + "'dependencies.dependency.version' for groupId:artifactId:jar is missing" ) ); + } + + public void testMissingDependencyManagementArtifactId() + throws Exception + { + SimpleProblemCollector result = validate( "missing-dependency-mgmt-artifactId-pom.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( + "'dependencyManagement.dependencies.dependency.artifactId' for groupId:null:jar is missing" ) ); + } + + public void testMissingDependencyManagementGroupId() + throws Exception + { + SimpleProblemCollector result = validate( "missing-dependency-mgmt-groupId-pom.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( + "'dependencyManagement.dependencies.dependency.groupId' for null:artifactId:jar is missing" ) ); + } + + public void testMissingAll() + throws Exception + { + SimpleProblemCollector result = validate( "missing-1-pom.xml" ); + + assertViolations( result, 0, 4, 0 ); + + List messages = result.getErrors(); + + assertTrue( messages.contains( "\'modelVersion\' is missing." ) ); + assertTrue( messages.contains( "\'groupId\' is missing." ) ); + assertTrue( messages.contains( "\'artifactId\' is missing." ) ); + assertTrue( messages.contains( "\'version\' is missing." ) ); + // type is inherited from the super pom + } + + public void testMissingPluginArtifactId() + throws Exception + { + SimpleProblemCollector result = validate( "missing-plugin-artifactId-pom.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertEquals( "'build.plugins.plugin.artifactId' is missing.", result.getErrors().get( 0 ) ); + } + + public void testEmptyPluginVersion() + throws Exception + { + SimpleProblemCollector result = validate( "empty-plugin-version.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertEquals( "'build.plugins.plugin.version' for org.apache.maven.plugins:maven-it-plugin" + + " must be a valid version but is ''.", result.getErrors().get( 0 ) ); + } + + public void testMissingRepositoryId() + throws Exception + { + SimpleProblemCollector result = + validateRaw( "missing-repository-id-pom.xml", ModelBuildingRequest.VALIDATION_LEVEL_STRICT ); + + assertViolations( result, 0, 4, 0 ); + + assertEquals( "'repositories.repository.id' is missing.", result.getErrors().get( 0 ) ); + + assertEquals( "'repositories.repository[null].url' is missing.", result.getErrors().get( 1 ) ); + + assertEquals( "'pluginRepositories.pluginRepository.id' is missing.", result.getErrors().get( 2 ) ); + + assertEquals( "'pluginRepositories.pluginRepository[null].url' is missing.", result.getErrors().get( 3 ) ); + } + + public void testMissingResourceDirectory() + throws Exception + { + SimpleProblemCollector result = validate( "missing-resource-directory-pom.xml" ); + + assertViolations( result, 0, 2, 0 ); + + assertEquals( "'build.resources.resource.directory' is missing.", result.getErrors().get( 0 ) ); + + assertEquals( "'build.testResources.testResource.directory' is missing.", result.getErrors().get( 1 ) ); + } + + public void testBadPluginDependencyScope() + throws Exception + { + SimpleProblemCollector result = validate( "bad-plugin-dependency-scope.xml" ); + + assertViolations( result, 0, 3, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( "test:d" ) ); + + assertTrue( result.getErrors().get( 1 ).contains( "test:e" ) ); + + assertTrue( result.getErrors().get( 2 ).contains( "test:f" ) ); + } + + public void testBadDependencyScope() + throws Exception + { + SimpleProblemCollector result = validate( "bad-dependency-scope.xml" ); + + assertViolations( result, 0, 0, 2 ); + + assertTrue( result.getWarnings().get( 0 ).contains( "test:f" ) ); + + assertTrue( result.getWarnings().get( 1 ).contains( "test:g" ) ); + } + + public void testBadDependencyVersion() + throws Exception + { + SimpleProblemCollector result = validate( "bad-dependency-version.xml" ); + + assertViolations( result, 0, 2, 0 ); + + assertContains( result.getErrors().get( 0 ), + "'dependencies.dependency.version' for test:b:jar must be a valid version" ); + assertContains( result.getErrors().get( 1 ), + "'dependencies.dependency.version' for test:c:jar must not contain any of these characters" ); + } + + public void testDuplicateModule() + throws Exception + { + SimpleProblemCollector result = validate( "duplicate-module.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( "child" ) ); + } + + public void testDuplicateProfileId() + throws Exception + { + SimpleProblemCollector result = validateRaw( "duplicate-profile-id.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( "non-unique-id" ) ); + } + + public void testBadPluginVersion() + throws Exception + { + SimpleProblemCollector result = validate( "bad-plugin-version.xml" ); + + assertViolations( result, 0, 4, 0 ); + + assertContains( result.getErrors().get( 0 ), + "'build.plugins.plugin.version' for test:mip must be a valid version" ); + assertContains( result.getErrors().get( 1 ), + "'build.plugins.plugin.version' for test:rmv must be a valid version" ); + assertContains( result.getErrors().get( 2 ), + "'build.plugins.plugin.version' for test:lmv must be a valid version" ); + assertContains( result.getErrors().get( 3 ), + "'build.plugins.plugin.version' for test:ifsc must not contain any of these characters" ); + } + + public void testDistributionManagementStatus() + throws Exception + { + SimpleProblemCollector result = validate( "distribution-management-status.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( "distributionManagement.status" ) ); + } + + public void testIncompleteParent() + throws Exception + { + SimpleProblemCollector result = validateRaw( "incomplete-parent.xml" ); + + assertViolations( result, 3, 0, 0 ); + + assertTrue( result.getFatals().get( 0 ).contains( "parent.groupId" ) ); + assertTrue( result.getFatals().get( 1 ).contains( "parent.artifactId" ) ); + assertTrue( result.getFatals().get( 2 ).contains( "parent.version" ) ); + } + + public void testHardCodedSystemPath() + throws Exception + { + SimpleProblemCollector result = validateRaw( "hard-coded-system-path.xml" ); + + assertViolations( result, 0, 0, 1 ); + + assertTrue( result.getWarnings().get( 0 ).contains( "test:a:jar" ) ); + } + + public void testEmptyModule() + throws Exception + { + SimpleProblemCollector result = validate( "empty-module.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( "'modules.module[0]' has been specified without a path" ) ); + } + + public void testDuplicatePlugin() + throws Exception + { + SimpleProblemCollector result = validateRaw( "duplicate-plugin.xml" ); + + assertViolations( result, 0, 0, 4 ); + + assertTrue( result.getWarnings().get( 0 ).contains( "duplicate declaration of plugin test:duplicate" ) ); + assertTrue( result.getWarnings().get( 1 ).contains( "duplicate declaration of plugin test:managed-duplicate" ) ); + assertTrue( result.getWarnings().get( 2 ).contains( "duplicate declaration of plugin profile:duplicate" ) ); + assertTrue( result.getWarnings().get( 3 ).contains( "duplicate declaration of plugin profile:managed-duplicate" ) ); + } + + public void testDuplicatePluginExecution() + throws Exception + { + SimpleProblemCollector result = validateRaw( "duplicate-plugin-execution.xml" ); + + assertViolations( result, 0, 4, 0 ); + + assertContains( result.getErrors().get( 0 ), "duplicate execution with id a" ); + assertContains( result.getErrors().get( 1 ), "duplicate execution with id default" ); + assertContains( result.getErrors().get( 2 ), "duplicate execution with id c" ); + assertContains( result.getErrors().get( 3 ), "duplicate execution with id b" ); + } + + public void testReservedRepositoryId() + throws Exception + { + SimpleProblemCollector result = validate( "reserved-repository-id.xml" ); + + assertViolations( result, 0, 0, 4 ); + + assertContains( result.getWarnings().get( 0 ), "'repositories.repository.id'" + " must not be 'local'" ); + assertContains( result.getWarnings().get( 1 ), "'pluginRepositories.pluginRepository.id' must not be 'local'" ); + assertContains( result.getWarnings().get( 2 ), "'distributionManagement.repository.id' must not be 'local'" ); + assertContains( result.getWarnings().get( 3 ), + "'distributionManagement.snapshotRepository.id' must not be 'local'" ); + } + + public void testMissingPluginDependencyGroupId() + throws Exception + { + SimpleProblemCollector result = validate( "missing-plugin-dependency-groupId.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( ":a:" ) ); + } + + public void testMissingPluginDependencyArtifactId() + throws Exception + { + SimpleProblemCollector result = validate( "missing-plugin-dependency-artifactId.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( "test:" ) ); + } + + public void testMissingPluginDependencyVersion() + throws Exception + { + SimpleProblemCollector result = validate( "missing-plugin-dependency-version.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( "test:a" ) ); + } + + public void testBadPluginDependencyVersion() + throws Exception + { + SimpleProblemCollector result = validate( "bad-plugin-dependency-version.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertTrue( result.getErrors().get( 0 ).contains( "test:b" ) ); + } + + public void testBadVersion() + throws Exception + { + SimpleProblemCollector result = validate( "bad-version.xml" ); + + assertViolations( result, 0, 0, 1 ); + + assertContains( result.getWarnings().get( 0 ), "'version' must not contain any of these characters" ); + } + + public void testBadSnapshotVersion() + throws Exception + { + SimpleProblemCollector result = validate( "bad-snapshot-version.xml" ); + + assertViolations( result, 0, 0, 1 ); + + assertContains( result.getWarnings().get( 0 ), "'version' uses an unsupported snapshot version format" ); + } + + public void testBadRepositoryId() + throws Exception + { + SimpleProblemCollector result = validate( "bad-repository-id.xml" ); + + assertViolations( result, 0, 0, 4 ); + + assertContains( result.getWarnings().get( 0 ), + "'repositories.repository.id' must not contain any of these characters" ); + assertContains( result.getWarnings().get( 1 ), + "'pluginRepositories.pluginRepository.id' must not contain any of these characters" ); + assertContains( result.getWarnings().get( 2 ), + "'distributionManagement.repository.id' must not contain any of these characters" ); + assertContains( result.getWarnings().get( 3 ), + "'distributionManagement.snapshotRepository.id' must not contain any of these characters" ); + } + + public void testBadDependencyExclusionId() + throws Exception + { + SimpleProblemCollector result = validateEffective( "bad-dependency-exclusion-id.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ); + + assertViolations( result, 0, 0, 2 ); + + assertContains( result.getWarnings().get( 0 ), + "'dependencies.dependency.exclusions.exclusion.groupId' for gid:aid:jar" ); + assertContains( result.getWarnings().get( 1 ), + "'dependencies.dependency.exclusions.exclusion.artifactId' for gid:aid:jar" ); + + // MNG-3832: Aether (part of M3+) supports wildcard expressions for exclusions + + SimpleProblemCollector result_30 = validate( "bad-dependency-exclusion-id.xml" ); + + assertViolations( result_30, 0, 0, 0 ); + + } + + public void testMissingDependencyExclusionId() + throws Exception + { + SimpleProblemCollector result = validate( "missing-dependency-exclusion-id.xml" ); + + assertViolations( result, 0, 0, 2 ); + + assertContains( result.getWarnings().get( 0 ), + "'dependencies.dependency.exclusions.exclusion.groupId' for gid:aid:jar is missing" ); + assertContains( result.getWarnings().get( 1 ), + "'dependencies.dependency.exclusions.exclusion.artifactId' for gid:aid:jar is missing" ); + } + + public void testBadImportScopeType() + throws Exception + { + SimpleProblemCollector result = validateRaw( "bad-import-scope-type.xml" ); + + assertViolations( result, 0, 0, 1 ); + + assertContains( result.getWarnings().get( 0 ), + "'dependencyManagement.dependencies.dependency.type' for test:a:jar must be 'pom'" ); + } + + public void testBadImportScopeClassifier() + throws Exception + { + SimpleProblemCollector result = validateRaw( "bad-import-scope-classifier.xml" ); + + assertViolations( result, 0, 1, 0 ); + + assertContains( result.getErrors().get( 0 ), + "'dependencyManagement.dependencies.dependency.classifier' for test:a:pom:cls must be empty" ); + } + + public void testSystemPathRefersToProjectBasedir() + throws Exception + { + SimpleProblemCollector result = validateRaw( "basedir-system-path.xml" ); + + assertViolations( result, 0, 0, 2 ); + + assertContains( result.getWarnings().get( 0 ), "'dependencies.dependency.systemPath' for test:a:jar " + + "should not point at files within the project directory" ); + assertContains( result.getWarnings().get( 1 ), "'dependencies.dependency.systemPath' for test:b:jar " + + "should not point at files within the project directory" ); + } + + public void testMissingReportPluginVersion() + throws Exception + { + SimpleProblemCollector result = validate( "missing-report-version-pom.xml" ); + + assertViolations( result, 0, 0, 0 ); + } +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/factory/complex.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/factory/complex.xml new file mode 100644 index 00000000..80060ffb --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/factory/complex.xml @@ -0,0 +1,49 @@ + + + + 4.0.0 + + test + test + 0.1-SNAPSHOT + pom + + + hello + + + + + two-conditions + + + simple.xml + + + myproperty + test + + + + activated-1 + + + + another-two-conditions + + + myproperty + test + + + simple.xml + + + + activated-2 + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/factory/simple.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/factory/simple.xml new file mode 100644 index 00000000..71900731 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/factory/simple.xml @@ -0,0 +1,81 @@ + + + + + + 4.0.0 + + test + test + 0.1-SNAPSHOT + pom + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.1 + + 1.5 + 1.5 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + test + + + + + + + + + default + + true + + + UTF-8 + + + + file + + + simple.xml + + + + activated + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-child.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-child.xml new file mode 100644 index 00000000..feb3cb89 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-child.xml @@ -0,0 +1,61 @@ + + + + + + 4.0.0 + + child + 12-SNAPSHOT + + + + + + + + + inheritance.configuration + default + 3.0 + + + child + child + + + child + child + + + child + child + + + + + + \ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-expected.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-expected.xml new file mode 100644 index 00000000..00a21f3d --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-expected.xml @@ -0,0 +1,87 @@ + + + + + + 4.0.0 + + inheritance + child + 12-SNAPSHOT + + + Model inheritance description + http://www.apache.org/child/ + + + + parent + post@mailing.list.com + subscribe@mailing.list.com + unsubscribe@mailing.list.com + + + + + + + inheritance.configuration + default + 3.0 + + + + child + child + parent + + + parent + parent + child + child + + + child + child + + + + + + + + + + MNG-5115 + + + default-inherited + + to-be-inherited + + + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-parent.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-parent.xml new file mode 100644 index 00000000..2b973a15 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-parent.xml @@ -0,0 +1,89 @@ + + + + + + 4.0.0 + + inheritance + parent + 11-SNAPSHOT + + Model inheritance test + Model inheritance description + http://www.apache.org/ + + + + parent + post@mailing.list.com + subscribe@mailing.list.com + unsubscribe@mailing.list.com + + + + + + + inheritance.configuration + default + 2.0 + + + parent + parent + + + parent + parent + + + parent + parent + + + + + + + + + + MNG-5115 + + + default-inherited + + to-be-inherited + + + + inherited-false + false + + not-to-be-inherited + + + + + + + \ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-dependency-exclusion-id.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-dependency-exclusion-id.xml new file mode 100644 index 00000000..1e02b154 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-dependency-exclusion-id.xml @@ -0,0 +1,40 @@ + + + + 4.0.0 + foo + foo + 99.44 + jar + + + + gid + aid + 1.0 + + + test? + * + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-dependency-scope.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-dependency-scope.xml new file mode 100644 index 00000000..0ae0b45f --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-dependency-scope.xml @@ -0,0 +1,69 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + test + a + 0.2 + + + test + b + 0.2 + compile + + + test + c + 0.2 + runtime + + + test + d + 0.2 + test + + + test + e + 0.2 + provided + + + test + f + 0.2 + import + + + test + g + 0.2 + optional + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-dependency-version.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-dependency-version.xml new file mode 100644 index 00000000..cb75e7b7 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-dependency-version.xml @@ -0,0 +1,43 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + test + a + 0.2 + + + test + b + ${missing.property} + + + test + c + 1/1 + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-classifier.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-classifier.xml new file mode 100644 index 00000000..83313451 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-classifier.xml @@ -0,0 +1,38 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + + test + a + 0.1 + import + pom + cls + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-type.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-type.xml new file mode 100644 index 00000000..fb505c54 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-type.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + + test + a + 0.1 + import + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-modelVersion.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-modelVersion.xml new file mode 100644 index 00000000..1f381b3b --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-modelVersion.xml @@ -0,0 +1,25 @@ + + + + 99.0.0 + foo + bar + 0.1 + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-plugin-dependency-scope.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-plugin-dependency-scope.xml new file mode 100644 index 00000000..3b06e620 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-plugin-dependency-scope.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + maven-it-plugin + 0.1 + + + test + a + 0.2 + + + test + b + 0.2 + compile + + + test + c + 0.2 + runtime + + + test + d + 0.2 + test + + + test + e + 0.2 + provided + + + test + f + 0.2 + import + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-plugin-dependency-version.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-plugin-dependency-version.xml new file mode 100644 index 00000000..64382529 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-plugin-dependency-version.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + + maven-it-plugin + 1.0 + + + test + a + 0.1 + + + test + b + ${missing.property} + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-plugin-version.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-plugin-version.xml new file mode 100644 index 00000000..2ca936aa --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-plugin-version.xml @@ -0,0 +1,55 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + + test + good + 1.0 + + + test + mip + ${missing.property} + + + test + rmv + RELEASE + + + test + lmv + LATEST + + + test + ifsc + 1/1 + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-repository-id.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-repository-id.xml new file mode 100644 index 00000000..70553eb3 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-repository-id.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + gid + aid + 1.0 + + + + this/is\bad + http://localhost + + + + + this/is\bad + http://localhost + + + + + + this/is\bad + http://localhost + + + this/is\bad + http://localhost + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-snapshot-version.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-snapshot-version.xml new file mode 100644 index 00000000..70b5ddcb --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-snapshot-version.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + foo + bar + 1.2.3.SNAPSHOT + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-version.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-version.xml new file mode 100644 index 00000000..bf6a1fc8 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/bad-version.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + foo + bar + this\is/bad + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/basedir-system-path.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/basedir-system-path.xml new file mode 100644 index 00000000..24d49d3d --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/basedir-system-path.xml @@ -0,0 +1,42 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + test + a + 0.2 + system + ${basedir}/lib/a.jar + + + test + b + 0.1 + system + ${project.basedir}/lib/b.jar + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/distribution-management-status.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/distribution-management-status.xml new file mode 100644 index 00000000..3a5968b0 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/distribution-management-status.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + foo + bar + 0.1 + + + generated + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-module.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-module.xml new file mode 100644 index 00000000..d3ef528f --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-module.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + child + child + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-plugin-execution.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-plugin-execution.xml new file mode 100644 index 00000000..0d4256de --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-plugin-execution.xml @@ -0,0 +1,103 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + + + + build + managed-plugin + + + test + + + test + + + + + + + + build + plugin + + + a + test + + + a + test + + + + + + + + + test + + + + + profile + managed-plugin + + + b + test + + + b + test + + + + + + + + profile + plugin + + + c + test + + + c + test + + + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-plugin.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-plugin.xml new file mode 100644 index 00000000..06a6a657 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-plugin.xml @@ -0,0 +1,81 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + + + + test + managed-duplicate + + + test + managed-duplicate + + + + + + test + duplicate + + + test + duplicate + + + + + + + test + + + + + profile + managed-duplicate + + + profile + managed-duplicate + + + + + + profile + duplicate + + + profile + duplicate + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-profile-id.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-profile-id.xml new file mode 100644 index 00000000..2379c3db --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/duplicate-profile-id.xml @@ -0,0 +1,35 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + + non-unique-id + + + non-unique-id + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/empty-module.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/empty-module.xml new file mode 100644 index 00000000..f7a91d1d --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/empty-module.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + aid + gid + 0.1 + pom + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/empty-plugin-version.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/empty-plugin-version.xml new file mode 100644 index 00000000..340efc5c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/empty-plugin-version.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + foo + bar + 1.0 + pack + + + + maven-it-plugin + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/hard-coded-system-path.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/hard-coded-system-path.xml new file mode 100644 index 00000000..b5a4dd67 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/hard-coded-system-path.xml @@ -0,0 +1,42 @@ + + + + 4.0.0 + aid + gid + 0.1 + + + + test + a + 0.2 + system + should-use-variables-and-not-hard-code-this-path + + + test + b + 0.1 + system + ${java.home}/lib/good.jar + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/incomplete-parent.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/incomplete-parent.xml new file mode 100644 index 00000000..2fc94d57 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/incomplete-parent.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + + + + + + aid + gid + 0.1 + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/invalid-aggregator-packaging-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/invalid-aggregator-packaging-pom.xml new file mode 100644 index 00000000..977f5db4 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/invalid-aggregator-packaging-pom.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + test-module + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/invalid-ids-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/invalid-ids-pom.xml new file mode 100644 index 00000000..bbb8e9c8 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/invalid-ids-pom.xml @@ -0,0 +1,26 @@ + + + + 4.0.0 + o/a/m + m$-do$ + 99.44 + bleh + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-1-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-1-pom.xml new file mode 100644 index 00000000..fe297e6e --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-1-pom.xml @@ -0,0 +1,21 @@ + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-artifactId-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-artifactId-pom.xml new file mode 100644 index 00000000..39f0d7bc --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-artifactId-pom.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + foo + 99.44 + bleh + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-artifactId-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-artifactId-pom.xml new file mode 100644 index 00000000..3a5b6479 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-artifactId-pom.xml @@ -0,0 +1,32 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + groupId + 1.0 + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-exclusion-id.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-exclusion-id.xml new file mode 100644 index 00000000..b9baada1 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-exclusion-id.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + foo + foo + 99.44 + jar + + + + gid + aid + 1.0 + + + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-groupId-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-groupId-pom.xml new file mode 100644 index 00000000..5799c572 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-groupId-pom.xml @@ -0,0 +1,32 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + artifactId + 1.0 + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-artifactId-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-artifactId-pom.xml new file mode 100644 index 00000000..e050ef43 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-artifactId-pom.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + groupId + version + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-groupId-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-groupId-pom.xml new file mode 100644 index 00000000..a012d0f5 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-groupId-pom.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + artifactId + version + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-version-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-version-pom.xml new file mode 100644 index 00000000..cc5ff5b3 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-version-pom.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + artifactId + groupId + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-version-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-version-pom.xml new file mode 100644 index 00000000..217b036d --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-dependency-version-pom.xml @@ -0,0 +1,32 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + artifactId + groupId + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-groupId-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-groupId-pom.xml new file mode 100644 index 00000000..528b8b6a --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-groupId-pom.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + bar + 99.44 + bleh + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-modelVersion-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-modelVersion-pom.xml new file mode 100644 index 00000000..f0273d9e --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-modelVersion-pom.xml @@ -0,0 +1,25 @@ + + + + foo + foo + 99.44 + bleh + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-artifactId-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-artifactId-pom.xml new file mode 100644 index 00000000..27e27d6b --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-artifactId-pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + 1.0 + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-dependency-artifactId.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-dependency-artifactId.xml new file mode 100644 index 00000000..5c21e363 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-dependency-artifactId.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + aid + gid + 1.0 + + + + + maven-it-plugin + 1.0 + + + test + + 2.0 + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-dependency-groupId.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-dependency-groupId.xml new file mode 100644 index 00000000..831c05f2 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-dependency-groupId.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + aid + gid + 1.0 + + + + + maven-it-plugin + 1.0 + + + + a + 2.0 + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-dependency-version.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-dependency-version.xml new file mode 100644 index 00000000..29e0b7e7 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-dependency-version.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + aid + gid + 1.0 + + + + + maven-it-plugin + 1.0 + + + test + a + + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-version-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-version-pom.xml new file mode 100644 index 00000000..b0ea7aa7 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-plugin-version-pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + maven-it-plugin + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-report-artifactId-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-report-artifactId-pom.xml new file mode 100644 index 00000000..4cb5649c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-report-artifactId-pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-report-version-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-report-version-pom.xml new file mode 100644 index 00000000..46a560f6 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-report-version-pom.xml @@ -0,0 +1,57 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + + + maven-from-pluginManagement-plugin + 1.0 + + + + + + maven-from-plugins-plugin + 1.0 + + + + + + + + maven-noversion-plugin + + + maven-from-plugins-plugin + + + maven-from-pluginManagement-plugin + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-repository-id-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-repository-id-pom.xml new file mode 100644 index 00000000..1d385f29 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-repository-id-pom.xml @@ -0,0 +1,36 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + + + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-resource-directory-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-resource-directory-pom.xml new file mode 100644 index 00000000..232db095 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-resource-directory-pom.xml @@ -0,0 +1,38 @@ + + + + 4.0.0 + foo + foo + 99.44 + bleh + + + + + + + + + + + + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-type-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-type-pom.xml new file mode 100644 index 00000000..663e58ad --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-type-pom.xml @@ -0,0 +1,26 @@ + + + + 4.0.0 + foo + bar + 99.44 + + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-version-pom.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-version-pom.xml new file mode 100644 index 00000000..2a111f19 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/missing-version-pom.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + foo + bar + bleh + diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/reserved-repository-id.xml b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/reserved-repository-id.xml new file mode 100644 index 00000000..90a6c88c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/test/resources/poms/validation/reserved-repository-id.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + gid + aid + 99.44 + + + + local + http://localhost + + + + + local + http://localhost + + + + + + local + http://localhost + + + local + http://localhost + + + -- cgit 1.2.3-korg