@Test public void installContainerWithDownload() throws Exception { Project project = initializeJavaProject(); MavenCoreFacet coreFacet = project.getFacet(MavenCoreFacet.class); List<Profile> profiles = coreFacet.getPOM().getProfiles(); for (Profile profile : profiles) { System.out.println(profile.getId()); } assertThat(profiles.size(), is(0)); queueInputLines("JBOSS_AS_MANAGED_4.2.X", "", "19", "10", "", "", "", "", "y", ""); getShell().execute("arquillian setup"); assertThat(coreFacet.getPOM().getProfiles().size(), is(1)); Profile profile = coreFacet.getPOM().getProfiles().get(0); assertThat( profile.getDependencies(), hasItems( new DependencyMatcher("arquillian-jbossas-managed-4.2"), new DependencyMatcher("jboss-server-manager"), new DependencyMatcher("dom4j"), new DependencyMatcher("jbossall-client"))); assertThat(profile.getBuild().getPlugins().size(), is(1)); assertThat( profile.getBuild().getPlugins().get(0).getArtifactId(), is("maven-dependency-plugin")); }
/** For each project in the current build set, reset the version if using project.version */ @Override public Set<Project> applyChanges(final List<Project> projects, final ManipulationSession session) throws ManipulationException { final ProjectVersionEnforcingState state = session.getState(ProjectVersionEnforcingState.class); if (!session.isEnabled() || !session.anyStateEnabled(State.activeByDefault) || state == null || !state.isEnabled()) { logger.debug("Project version enforcement is disabled."); return Collections.emptySet(); } final Set<Project> changed = new HashSet<Project>(); for (final Project project : projects) { final Model model = project.getModel(); if (model.getPackaging().equals("pom")) { enforceProjectVersion(project, model.getDependencies(), changed); if (model.getDependencyManagement() != null) { enforceProjectVersion( project, model.getDependencyManagement().getDependencies(), changed); } final List<Profile> profiles = model.getProfiles(); if (profiles != null) { for (final Profile profile : model.getProfiles()) { enforceProjectVersion(project, profile.getDependencies(), changed); if (profile.getDependencyManagement() != null) { enforceProjectVersion( project, profile.getDependencyManagement().getDependencies(), changed); } } } } } if (changed.size() > 0) { logger.warn( "Using ${project.version} in pom files may lead to unexpected errors with inheritance."); } return changed; }
/** * Adds information about defined profile. * * @param pomDescriptor The descriptor for the current POM. * @param model The Maven Model. * @param scannerContext The scanner context. */ private void addProfiles( MavenPomDescriptor pomDescriptor, Model model, ScannerContext scannerContext) { List<Profile> profiles = model.getProfiles(); Store store = scannerContext.getStore(); for (Profile profile : profiles) { MavenProfileDescriptor mavenProfileDescriptor = store.create(MavenProfileDescriptor.class); pomDescriptor.getProfiles().add(mavenProfileDescriptor); mavenProfileDescriptor.setId(profile.getId()); addProperties(mavenProfileDescriptor, profile.getProperties(), store); addModules(mavenProfileDescriptor, profile.getModules(), store); addPlugins(mavenProfileDescriptor, profile.getBuild(), scannerContext); addManagedPlugins(mavenProfileDescriptor, profile.getBuild(), scannerContext); addManagedDependencies( mavenProfileDescriptor, profile.getDependencyManagement(), scannerContext, ProfileManagesDependencyDescriptor.class); addProfileDependencies(mavenProfileDescriptor, profile.getDependencies(), scannerContext); addActivation(mavenProfileDescriptor, profile.getActivation(), store); } }
private void installContainer(String container, List<DependencyMatcher> dependencies) throws Exception { Project project = initializeJavaProject(); MavenCoreFacet coreFacet = project.getFacet(MavenCoreFacet.class); List<Profile> profiles = coreFacet.getPOM().getProfiles(); for (Profile profile : profiles) { System.out.println(profile.getId()); } assertThat(profiles.size(), is(0)); queueInputLines( container, "19", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); getShell().execute("arquillian setup"); assertThat(coreFacet.getPOM().getProfiles().size(), is(1)); Profile profile = coreFacet.getPOM().getProfiles().get(0); for (DependencyMatcher dependency : dependencies) { assertThat(profile.getDependencies(), hasItem(dependency)); } }