DefaultTargetPlatformConfigurationReader { protected void readExtraRequirements(TargetPlatformConfiguration result, Xpp3Dom resolverDom) throws BuildFailureException { Xpp3Dom requirementsDom = resolverDom.getChild("extraRequirements"); if (requirementsDom == null) { return; } for (Xpp3Dom requirementDom : requirementsDom.getChildren("requirement")) { Dependency d = new Dependency(); if (requirementDom.getChild("type") == null) { throw new BuildFailureException( "Element <type> is missing in <extraRequirements><requirement> section."); } if (requirementDom.getChild("id") == null) { throw new BuildFailureException("Element <id> is missing in <extraRequirements><requirement> section."); } if (requirementDom.getChild("versionRange") == null) { throw new BuildFailureException( "Element <versionRange> is missing in <extraRequirements><requirement> section."); } d.setType(requirementDom.getChild("type").getValue()); d.setArtifactId(requirementDom.getChild("id").getValue()); d.setVersion(requirementDom.getChild("versionRange").getValue()); result.addExtraRequirement(d); } }  TargetPlatformConfiguration getTargetPlatformConfiguration(MavenSession session, MavenProject project); static File[] listTargetFiles(File folder); static boolean isTargetFile(File file); static boolean isPrimaryTarget(MavenProject project, File targetFile, File[] otherTargetFiles); static void throwNoPrimaryTargetFound(MavenProject project, File[] targetFiles); static final String TARGET_DEFINITION_INCLUDE_SOURCE; static final String INCLUDE_PACKED_ARTIFACTS; static final String DEPENDENCY_RESOLUTION; static final String FILTERS; static final String RESOLVE_WITH_EXECUTION_ENVIRONMENT_CONSTRAINTS; static final String BREE_HEADER_SELECTION_POLICY; static final String EXECUTION_ENVIRONMENT_DEFAULT; static final String EXECUTION_ENVIRONMENT; static final String ALLOW_CONFLICTING_DEPENDENCIES; static final String POM_DEPENDENCIES; static final String TARGET; static final String RESOLVER; static final String ENVIRONMENTS; }
@Test public void testExtraRequirementMissingVersionRange() throws Exception { Xpp3Dom dom = createConfigurationDom("type", "id"); try { configurationReader.readExtraRequirements(new TargetPlatformConfiguration(), dom); fail(); } catch (BuildFailureException e) { assertTrue(e.getMessage() .contains("Element <versionRange> is missing in <extraRequirements><requirement> section.")); } }
@Test public void testExtraRequirementMissingType() throws Exception { Xpp3Dom dom = createConfigurationDom("id", "versionRange"); try { configurationReader.readExtraRequirements(new TargetPlatformConfiguration(), dom); fail(); } catch (BuildFailureException e) { assertTrue( e.getMessage().contains("Element <type> is missing in <extraRequirements><requirement> section.")); } }
@Test public void testExtraRequirementId() throws Exception { Xpp3Dom dom = createConfigurationDom("type", "versionRange"); try { configurationReader.readExtraRequirements(new TargetPlatformConfiguration(), dom); fail(); } catch (BuildFailureException e) { assertTrue(e.getMessage().contains("Element <id> is missing in <extraRequirements><requirement> section.")); } }