本文整理汇总了Java中org.codehaus.mojo.versions.change.VersionChanger类的典型用法代码示例。如果您正苦于以下问题:Java VersionChanger类的具体用法?Java VersionChanger怎么用?Java VersionChanger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VersionChanger类属于org.codehaus.mojo.versions.change包,在下文中一共展示了VersionChanger类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import org.codehaus.mojo.versions.change.VersionChanger; //导入依赖的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: update
import org.codehaus.mojo.versions.change.VersionChanger; //导入依赖的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();
}
示例3: update
import org.codehaus.mojo.versions.change.VersionChanger; //导入依赖的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();
}