use of org.eclipse.tycho.versions.pom.PomFile in project unleash-maven-plugin by shillner.
the class AbstractTychoVersionsStep method adaptProjectMetadataWithNewVersions.
private void adaptProjectMetadataWithNewVersions() {
// this needs to be done in order to make the changes reversible
// if the metadata is not adapted reverting the changes wouldn't be possible for pom-less builds since the metadata
// is initialized only once before the build starts
this.metadataReader.getProjects().forEach(data -> {
PomFile pom = data.getMetadata(PomFile.class);
Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata.getArtifactCoordinatesByPhase(pom.getGroupId(), pom.getArtifactId());
String version = coordinatesByPhase.get(currentReleasePhase()).getVersion();
pom.setVersion(version);
});
}
use of org.eclipse.tycho.versions.pom.PomFile in project tycho by eclipse.
the class MutablePomFileTest method testCompileMessage.
@Test(expected = XMLParseException.class)
public void testCompileMessage() throws Exception {
File pomFile = null;
try {
URL url = getClass().getResource("/poms/compilemessage.xml");
pomFile = new File(url.toURI());
PomFile.read(pomFile, true);
} catch (Exception pe) {
Assert.assertEquals("This Pom " + pomFile.getAbsolutePath() + " is in the Wrong Format", pe.getMessage());
throw pe;
}
}
use of org.eclipse.tycho.versions.pom.PomFile in project tycho by eclipse.
the class VersionsEngine method addPropertyChange.
public void addPropertyChange(String artifactId, String propertyName, String propertyValue) throws IOException {
PomFile pom = getMutablePom(artifactId);
propertyChanges.add(new PropertyChange(pom, propertyName, propertyValue));
}
use of org.eclipse.tycho.versions.pom.PomFile in project tycho by eclipse.
the class PomManipulator method applyChanges.
@Override
public void applyChanges(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
PomFile pom = project.getMetadata(PomFile.class);
// e.g. not for polyglot pom files
if (!pom.isMutable()) {
return;
}
for (PomVersionChange change : versionChangeContext.getVersionChanges()) {
String version = Versions.toMavenVersion(change.getVersion());
String newVersion = Versions.toMavenVersion(change.getNewVersion());
if (isGavEquals(pom, change)) {
logger.info(" pom.xml//project/version: " + version + " => " + newVersion);
pom.setVersion(newVersion);
} else {
GAV parent = pom.getParent();
if (parent != null && isGavEquals(parent, change)) {
logger.info(" pom.xml//project/parent/version: " + version + " => " + newVersion);
parent.setVersion(newVersion);
}
}
//
// Dependencies and entries inside dependencyManagement sections are not
// OSGI related. Nevertheless it might happen that dependencies like this
// does occur inside OSGI related project. Hence we must be able to handle
// it.
//
changeDependencies(" pom.xml//project/dependencies", pom.getDependencies(), change, version, newVersion);
changeDependencyManagement(" pom.xml//project/dependencyManagement", pom.getDependencyManagement(), change, version, newVersion);
changeBuild(" pom.xml//project/build", pom.getBuild(), change, version, newVersion);
for (Profile profile : pom.getProfiles()) {
String profileId = profile.getId() != null ? profile.getId() : "<null>";
String pomPath = " pom.xml//project/profiles/profile[ " + profileId + " ]";
changeDependencies(pomPath + "/dependencies", profile.getDependencies(), change, version, newVersion);
changeDependencyManagement(pomPath + "/dependencyManagement", profile.getDependencyManagement(), change, version, newVersion);
changeBuild(pomPath + "/build", profile.getBuild(), change, version, newVersion);
}
}
}
use of org.eclipse.tycho.versions.pom.PomFile in project tycho by eclipse.
the class PomManipulator method addMoreChanges.
@Override
public boolean addMoreChanges(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
PomFile pom = project.getMetadata(PomFile.class);
GAV parent = pom.getParent();
boolean moreChanges = false;
for (PomVersionChange change : versionChangeContext.getVersionChanges()) {
if (parent != null && isGavEquals(parent, change)) {
if (isVersionEquals(pom.getVersion(), change.getVersion())) {
moreChanges |= versionChangeContext.addVersionChange(new PomVersionChange(pom, change.getVersion(), change.getNewVersion()));
}
}
}
return moreChanges;
}
Aggregations