本文整理汇总了Java中org.codehaus.mojo.versions.change.VersionChange类的典型用法代码示例。如果您正苦于以下问题:Java VersionChange类的具体用法?Java VersionChange怎么用?Java VersionChange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VersionChange类属于org.codehaus.mojo.versions.change包,在下文中一共展示了VersionChange类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import org.codehaus.mojo.versions.change.VersionChange; //导入依赖的package包/类
void write(ModelWrapper wrapper, Versions versions, File pom) {
try {
VersionChangerFactory versionChangerFactory = new VersionChangerFactory();
StringBuilder input = PomHelper.readXmlFile(pom);
ModifiedPomXMLEventReader parsedPom = newModifiedPomXER(input);
versionChangerFactory.setPom(parsedPom);
LoggerToMavenLog loggerToMavenLog = new LoggerToMavenLog(PomWriter.log);
versionChangerFactory.setLog(loggerToMavenLog);
versionChangerFactory.setModel(wrapper.model);
log.info("Applying version / parent / plugin / project changes to the pom [{}]", pom);
VersionChanger changer = versionChangerFactory.newVersionChanger( true,
true, true, true);
for (VersionChange versionChange : wrapper.sourceChanges) {
changer.apply(versionChange);
}
log.debug("Applying properties changes to the pom [{}]", pom);
new PropertyVersionChanger(wrapper, versions, parsedPom, loggerToMavenLog)
.apply(null);
try (BufferedWriter bw = new BufferedWriter(new FileWriter(pom))) {
bw.write(input.toString());
}
log.debug("Flushed changes to the pom file [{}]", pom);
} catch (Exception e) {
log.error("Exception occurred while trying to apply changes to the POM", e);
}
}
示例2: newParentVersionIsEqualTo
import org.codehaus.mojo.versions.change.VersionChange; //导入依赖的package包/类
VersionChangeAssert newParentVersionIsEqualTo(String groupId, String artifactId, String newVersion) {
boolean matches = false;
for (VersionChange change : actual.changes) {
if (newVersion.equals(change.getNewVersion())
&& groupId.equals(change.getGroupId())
&& artifactId.equals(change.getArtifactId())) {
matches = true;
break;
}
}
if (matches) {
return this;
}
failWithMessage("There is no change with that parent coordinates");
return this;
}
示例3: updateParentIfPossible
import org.codehaus.mojo.versions.change.VersionChange; //导入依赖的package包/类
private List<VersionChange> updateParentIfPossible(ModelWrapper wrapper, Versions versions,
Model model, List<VersionChange> sourceChanges) {
String rootProjectName = wrapper.projectName();
String rootProjectGroupId = wrapper.groupId();
List<VersionChange> changes = new ArrayList<>(sourceChanges);
if (model.getParent() == null || isEmpty(model.getParent().getVersion())) {
log.debug("Can't set the value for parent... Will return {}", sourceChanges);
return changes;
}
if (model.getGroupId() != null && !model.getGroupId().equals(rootProjectGroupId)) {
log.info("Will not update the project's [{}] parent [{}] since its group id [{}] is not equal the parent group id [{}]",
model.getArtifactId(), model.getParent().getArtifactId(), model.getGroupId(), rootProjectGroupId);
return changes;
}
String parentGroupId = model.getParent().getGroupId();
String parentArtifactId = model.getParent().getArtifactId();
log.debug("Searching for a version of parent [{}:{}]", parentGroupId, parentArtifactId);
String oldVersion = model.getParent().getVersion();
String version = versions.versionForProject(parentArtifactId);
log.debug("Found version is [{}]", version);
if (isEmpty(version)) {
if (hasText(model.getParent().getRelativePath())) {
version = versions.versionForProject(rootProjectName);
} else {
log.warn("There is no info on the [{}:{}] version", parentGroupId, parentArtifactId);
return changes;
}
}
if (oldVersion.equals(version)) {
log.debug("Won't update the version of parent [{}:{}] since you're already using the proper one", parentGroupId, parentArtifactId);
return changes;
}
log.info("Setting version of parent [{}] to [{}] for module [{}]", parentArtifactId,
version, model.getArtifactId());
if (hasText(version)) {
changes.add(new VersionChange(parentGroupId, parentArtifactId, oldVersion, version));
}
return changes;
}
示例4: apply
import org.codehaus.mojo.versions.change.VersionChange; //导入依赖的package包/类
@Override public void apply(final VersionChange versionChange) throws XMLStreamException {
this.versions.projects
.stream()
.filter(project -> {
Properties properties = getModel().getProperties();
String projectVersionKey = propertyName(project);
if (!properties.containsKey(projectVersionKey)) {
return false;
}
String version = properties.getProperty(projectVersionKey);
return !version.equals(project.version);
})
.forEach(this.propertyStorer::setPropertyVersionIfApplicable);
}
示例5: addChange
import org.codehaus.mojo.versions.change.VersionChange; //导入依赖的package包/类
private synchronized void addChange( String groupId, String artifactId, String oldVersion, String newVersion )
{
if ( !newVersion.equals( oldVersion ) )
{
sourceChanges.add( new VersionChange( groupId, artifactId, oldVersion, newVersion ) );
}
}
示例6: update
import org.codehaus.mojo.versions.change.VersionChange; //导入依赖的package包/类
/**
* Updates the pom file.
*
* @param pom The pom file to update.
* @throws org.apache.maven.plugin.MojoExecutionException when things go wrong.
* @throws org.apache.maven.plugin.MojoFailureException when things go wrong.
* @throws javax.xml.stream.XMLStreamException when things go wrong.
*/
protected synchronized void update( ModifiedPomXMLEventReader pom )
throws MojoExecutionException, MojoFailureException, XMLStreamException
{
ContextualLog log = new DelegatingContextualLog( getLog() );
try
{
Model model = PomHelper.getRawModel( pom );
log.setContext( "Processing " + PomHelper.getGroupId( model ) + ":" + PomHelper.getArtifactId( model ) );
VersionChangerFactory versionChangerFactory = new VersionChangerFactory();
versionChangerFactory.setPom( pom );
versionChangerFactory.setLog( log );
versionChangerFactory.setModel( model );
VersionChanger changer = versionChangerFactory.newVersionChanger( processParent, processProject,
processDependencies, processPlugins );
for ( VersionChange versionChange : sourceChanges )
{
changer.apply( versionChange );
}
}
catch ( IOException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
log.clearContext();
}
示例7: update
import org.codehaus.mojo.versions.change.VersionChange; //导入依赖的package包/类
/**
* Updates the pom file.
*
* @param pom The pom file to update.
* @throws org.apache.maven.plugin.MojoExecutionException
* when things go wrong.
* @throws org.apache.maven.plugin.MojoFailureException
* when things go wrong.
* @throws javax.xml.stream.XMLStreamException
* when things go wrong.
*/
protected synchronized void update( ModifiedPomXMLEventReader pom )
throws MojoExecutionException, MojoFailureException, XMLStreamException
{
ContextualLog log = new DelegatingContextualLog( getLog() );
try
{
Model model = PomHelper.getRawModel( pom );
log.setContext( "Processing " + PomHelper.getGroupId( model ) + ":" + PomHelper.getArtifactId( model ) );
VersionChangerFactory versionChangerFactory = new VersionChangerFactory();
versionChangerFactory.setPom( pom );
versionChangerFactory.setLog( log );
versionChangerFactory.setModel( model );
VersionChanger changer =
versionChangerFactory.newVersionChanger( processParent, processProject, processDependencies,
processPlugins );
Iterator i = sourceChanges.iterator();
while ( i.hasNext() )
{
VersionChange versionChange = (VersionChange) i.next();
changer.apply( versionChange );
}
}
catch ( IOException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
log.clearContext();
}
示例8: ModelWrapper
import org.codehaus.mojo.versions.change.VersionChange; //导入依赖的package包/类
ModelWrapper(Model model, List<VersionChange> sourceChanges, Versions versions) {
this.model = model;
this.versions = versions;
this.sourceChanges.addAll(sourceChanges);
}
示例9: updateModel
import org.codehaus.mojo.versions.change.VersionChange; //导入依赖的package包/类
/**q
* Updates the root / child module model
*
* @param rootPom - root project model
* @param pom - file with the pom
* @param versions - versions to update
* @return updated model
*/
ModelWrapper updateModel(ModelWrapper rootPom, File pom, Versions versions) {
Model model = this.pomReader.readPom(pom);
List<VersionChange> sourceChanges = new ArrayList<>();
sourceChanges = updateParentIfPossible(rootPom, versions, model, sourceChanges);
sourceChanges = updateVersionIfPossible(rootPom, versions, model, sourceChanges);
return new ModelWrapper(model, sourceChanges, versions);
}