Skip to content

Commit

Permalink
PR: CONTINUUM-492
Browse files Browse the repository at this point in the history
Notifiers are now optional.

git-svn-id: https://svn.apache.org/repos/asf/maven/continuum/trunk@354104 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Emmanuel Venisse committed Dec 5, 2005
1 parent d829e1b commit 8f4ac2a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 48 deletions.
Expand Up @@ -252,10 +252,6 @@ public void mapMetadata( File metadata, Project project )
{
notifiers = project.getNotifiers();
}
else
{
throw new MavenOneMetadataHelperException( "Missing 'build' element in the POM." );
}
}
else
{
Expand All @@ -277,8 +273,6 @@ public void mapMetadata( File metadata, Project project )

if ( notifier == null && ( notifiers == null || notifiers.isEmpty() ) )
{
throw new MavenOneMetadataHelperException(
"Missing 'nagEmailAddress' element in the 'build' element in the POM." );
}
else
{
Expand Down
Expand Up @@ -215,21 +215,24 @@ public void mapMavenProjectToContinuumProject( MavenProject mavenProject, Projec

List userNotifiers = new ArrayList();

for ( int i = 0; i < continuumProject.getNotifiers().size(); i++ )
if ( continuumProject.getNotifiers() != null )
{
ProjectNotifier notifier = (ProjectNotifier) continuumProject.getNotifiers().get( i );

if ( notifier.isFromUser() )
for ( int i = 0; i < continuumProject.getNotifiers().size(); i++ )
{
ProjectNotifier userNotifier = new ProjectNotifier();
ProjectNotifier notifier = (ProjectNotifier) continuumProject.getNotifiers().get( i );

if ( notifier.isFromUser() )
{
ProjectNotifier userNotifier = new ProjectNotifier();

userNotifier.setType( notifier.getType() );
userNotifier.setType( notifier.getType() );

userNotifier.setConfiguration( notifier.getConfiguration() );
userNotifier.setConfiguration( notifier.getConfiguration() );

userNotifier.setFrom( notifier.getFrom() );
userNotifier.setFrom( notifier.getFrom() );

userNotifiers.add( userNotifier );
userNotifiers.add( userNotifier );
}
}
}

Expand Down Expand Up @@ -269,20 +272,6 @@ public MavenProject getMavenProject( File file )
// Validate the MavenProject using some Continuum rules
// ----------------------------------------------------------------------

// Nag email address
CiManagement ciManagement = project.getCiManagement();

if ( ciManagement == null )
{
throw new MavenBuilderHelperException( "Missing 'ciManagement' element in the " + getProjectName( project ) + " POM." );
}

if ( getNotifiers( project ).isEmpty() )
{
throw new MavenBuilderHelperException(
"Missing 'notifiers' element in the 'ciManagement' element in the " + getProjectName( project ) + " POM." );
}

// SCM connection
Scm scm = project.getScm();

Expand Down Expand Up @@ -327,37 +316,40 @@ private List getNotifiers( MavenProject mavenProject )
{
List notifiers = new ArrayList();

for ( Iterator i = mavenProject.getCiManagement().getNotifiers().iterator(); i.hasNext(); )
if ( mavenProject.getCiManagement() != null && mavenProject.getCiManagement().getNotifiers() != null )
{
Notifier projectNotifier = (Notifier) i.next();
for ( Iterator i = mavenProject.getCiManagement().getNotifiers().iterator(); i.hasNext(); )
{
Notifier projectNotifier = (Notifier) i.next();

ProjectNotifier notifier = new ProjectNotifier();
ProjectNotifier notifier = new ProjectNotifier();

if ( StringUtils.isEmpty( projectNotifier.getType() ) )
{
throw new MavenBuilderHelperException( "Missing type from notifier." );
}
if ( StringUtils.isEmpty( projectNotifier.getType() ) )
{
throw new MavenBuilderHelperException( "Missing type from notifier." );
}

notifier.setType( projectNotifier.getType() );
notifier.setType( projectNotifier.getType() );

if ( projectNotifier.getConfiguration() == null )
{
throw new MavenBuilderHelperException( "Notifier configuration cannot be null." );
}
if ( projectNotifier.getConfiguration() == null )
{
throw new MavenBuilderHelperException( "Notifier configuration cannot be null." );
}

notifier.setConfiguration( projectNotifier.getConfiguration() );
notifier.setConfiguration( projectNotifier.getConfiguration() );

notifier.setFrom( ProjectNotifier.FROM_PROJECT );
notifier.setFrom( ProjectNotifier.FROM_PROJECT );

notifier.setSendOnSuccess( projectNotifier.isSendOnSuccess() );
notifier.setSendOnSuccess( projectNotifier.isSendOnSuccess() );

notifier.setSendOnFailure( projectNotifier.isSendOnFailure() );
notifier.setSendOnFailure( projectNotifier.isSendOnFailure() );

notifier.setSendOnError( projectNotifier.isSendOnError() );
notifier.setSendOnError( projectNotifier.isSendOnError() );

notifier.setSendOnWarning( projectNotifier.isSendOnWarning() );
notifier.setSendOnWarning( projectNotifier.isSendOnWarning() );

notifiers.add( notifier );
notifiers.add( notifier );
}
}

return notifiers;
Expand Down

0 comments on commit 8f4ac2a

Please sign in to comment.