当我运行maven命令,例如“mvn install”或“mvn validate”时,maven将输出它构建的所有项目的工件ID。我想在脚本中使用此输出,然后调用类似于以下命令的内容:
mvn clean install -pl <comma separated list of groupId:artifactId>
不幸的是,我无法找到如何让maven输出组ID以及工件ID。到目前为止,我已经梳理了maven reactor和依赖插件,但没有任何运气。有没有办法做到这一点?
编辑:如果你在它前面放一个冒号,你可以使用神器ID。 E.g
mvn clean install -pl :fooProject,:barProject
答案 0 :(得分:1)
默认情况下,maven不支持此功能,很难修复输出项目名称
here是相关来源
private void logReactorSummary( MavenSession session )
{
logger.info( chars( '-', LINE_LENGTH ) );
logger.info( "Reactor Summary:" );
logger.info( "" );
MavenExecutionResult result = session.getResult();
for ( MavenProject project : session.getProjects() )
{
StringBuilder buffer = new StringBuilder( 128 );
buffer.append( project.getName() );
buffer.append( ' ' );
if ( buffer.length() <= MAX_PROJECT_NAME_LENGTH )
{
while ( buffer.length() < MAX_PROJECT_NAME_LENGTH )
{
buffer.append( '.' );
}
buffer.append( ' ' );
}
BuildSummary buildSummary = result.getBuildSummary( project );
if ( buildSummary == null )
{
buffer.append( "SKIPPED" );
}
else if ( buildSummary instanceof BuildSuccess )
{
buffer.append( "SUCCESS [" );
String buildTimeDuration = formatDuration( buildSummary.getTime() );
int padSize = MAX_PADDED_BUILD_TIME_DURATION_LENGTH - buildTimeDuration.length();
if ( padSize > 0 )
{
buffer.append( chars( ' ', padSize ) );
}
buffer.append( buildTimeDuration );
buffer.append( "]" );
}
else if ( buildSummary instanceof BuildFailure )
{
buffer.append( "FAILURE [" );
String buildTimeDuration = formatDuration( buildSummary.getTime() );
int padSize = MAX_PADDED_BUILD_TIME_DURATION_LENGTH - buildTimeDuration.length();
if ( padSize > 0 )
{
buffer.append( chars( ' ', padSize ) );
}
buffer.append( buildTimeDuration );
buffer.append( "]" );
}
logger.info( buffer.toString() );
}
}
如果您仍想这样做,请检查源代码,更新此方法以输出您想要构建maven的方式并开始使用您的本地maven构建