private ArtifactRepository getLocalRepository(MavenBuildInformation mavenBuildInformation, MavenProject pom) { if (mavenBuildInformation.isMaven3OrLater()) { return pom.getProjectBuildingRequest().getLocalRepository(); } else if (mavenBuildInformation.isAtLeastMavenVersion("2.2")) { // principally this should also work with Maven 2.1, but it's not tested, so err on the safe side return getArtifactRepositoryMaven21(pom); } else if (mavenBuildInformation.isAtLeastMavenVersion("2.0")) { // Maven 2.0 has no corresponding mechanism return null; } else { LOGGER.warning("Unknown Maven version: "+mavenBuildInformation.getMavenVersion()); return null; } }
public MavenBuildInformation getMavenBuildInformation() { return new MavenBuildInformation( MavenBuild.this.getModuleSetBuild().getMavenVersionUsed()); } }
Map<String,String> systemProps, MavenBuildInformation mavenBuildInformation) { String mavenVersion = mavenBuildInformation.getMavenVersion();
MavenBuildInformation mavenBuildInformation = new MavenBuildInformation( mavenVersion ); if (mavenBuildInformation.isMaven3OrLater())
public boolean preExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener) throws InterruptedException, IOException { if (isTestMojo(mojo)) { // tell test mojo to keep going even if there was a failure, // so that we can record this as yellow. // note that because of the way Maven works, just updating system property at this point is too late // Many test plugins have - as surefire - a configuration key 'testFailureIgnore' which defaults to // ${maven.test.failure.ignore}, so just try that one and change value to true, // if it's still at that default: XmlPlexusConfiguration c = (XmlPlexusConfiguration) mojo.configuration.getChild("testFailureIgnore",false); if(c!=null && c.getValue() != null && c.getValue().equals("${maven.test.failure.ignore}") && System.getProperty("maven.test.failure.ignore")==null) { if (build.getMavenBuildInformation().isMaven3OrLater()) { String fieldName = "testFailureIgnore"; if (mojo.mojoExecution.getConfiguration().getChild( fieldName ) != null) { mojo.mojoExecution.getConfiguration().getChild( fieldName ).setValue( Boolean.TRUE.toString() ); } else { Xpp3Dom child = new Xpp3Dom( fieldName ); child.setValue( Boolean.TRUE.toString() ); mojo.mojoExecution.getConfiguration().addChild( child ); } } else { c.setValue(Boolean.TRUE.toString()); } } } return true; }
private void recordParents(MavenBuildProxy build, MavenProject pom, BuildListener listener) throws IOException, InterruptedException { Map<String,String> modelParents = build.getMavenBuildInformation().modelParents; ArtifactRepository localRepository = getLocalRepository(build.getMavenBuildInformation(), pom); if (localRepository == null) { listener.error("Could not find local repository for " + build.getMavenBuildInformation().getMavenVersion()); return; } String parent = modelParents.get(pom.getId()); while (parent != null) { String[] parts = parent.split(":"); assert parts.length == 4 : parent; // Maven 2.x lacks DefaultArtifact constructor with String version and ArtifactRepository.find: Artifact parentArtifact = new DefaultArtifact(parts[0], parts[1], VersionRange.createFromVersion(parts[3]), null, parts[2], null, new DefaultArtifactHandler(parts[2])); File parentFile = new File(localRepository.getBasedir(), localRepository.pathOf(parentArtifact)); // we need to include the artifact Id for poms as well, otherwise a project with the same groupId would override its parent's fingerprint record(parts[0] + ":" + parts[1], parentFile, used); parent = modelParents.get(parent); } }
MavenBuildInformation mavenBuildInformation = new MavenBuildInformation( mavenVersion ); boolean maven3orLater = mavenBuildInformation.isMaven3OrLater();
public boolean preExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener) throws InterruptedException, IOException { if (isSurefireTest(mojo)) { if (!mojo.is("org.apache.maven.plugins", "maven-failsafe-plugin", "integration-test")) { // tell surefire:test to keep going even if there was a failure, // so that we can record this as yellow. // note that because of the way Maven works, just updating system property at this point is too late XmlPlexusConfiguration c = (XmlPlexusConfiguration) mojo.configuration.getChild("testFailureIgnore"); if(c!=null && c.getValue().equals("${maven.test.failure.ignore}") && System.getProperty("maven.test.failure.ignore")==null) { if (maven3orLater( build.getMavenBuildInformation().getMavenVersion() )) { String fieldName = "testFailureIgnore"; if (mojo.mojoExecution.getConfiguration().getChild( fieldName ) != null) { mojo.mojoExecution.getConfiguration().getChild( fieldName ).setValue( Boolean.TRUE.toString() ); } else { Xpp3Dom child = new Xpp3Dom( fieldName ); child.setValue( Boolean.TRUE.toString() ); mojo.mojoExecution.getConfiguration().addChild( child ); } } else { c.setValue(Boolean.TRUE.toString()); } } } } return true; }
public MavenBuildInformation getMavenBuildInformation() { return new MavenBuildInformation( MavenBuild.this.getModuleSetBuild().getMavenVersionUsed()); } }
IOException { if (isCoberturaReport(mojo)) { boolean maven3orLater = maven3orLater( build.getMavenBuildInformation().getMavenVersion());
MavenBuildInformation mavenBuildInformation = new MavenBuildInformation( mavenVersion );