Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Commit

Permalink
Add ForceParentModder
Browse files Browse the repository at this point in the history
  • Loading branch information
rnc committed Mar 21, 2014
1 parent 675adaa commit c243e09
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.redhat.rcm.version.mgr.mod;

import org.apache.maven.mae.project.key.FullProjectKey;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.codehaus.plexus.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.redhat.rcm.version.mgr.session.VersionManagerSession;
import com.redhat.rcm.version.model.Project;

@Component( role = ProjectModder.class, hint = "force-parent-realignment" )
public class ForceParentModder
implements ProjectModder
{
private final Logger logger = LoggerFactory.getLogger( getClass() );

@Override
public String getDescription()
{
return "Forcibly set the project's parent GAV using the declared toolchain GAV";
}

@Override
public boolean inject( final Project project, final VersionManagerSession session )
{
boolean changed = false;

if ( session.getToolchainKey() == null )
{
return changed;
}

final Model model = project.getModel();
final FullProjectKey toolchainKey = session.getToolchainKey();

Parent parent;

if ( toolchainKey != null )
{
logger.info( "Injecting toolchain as parent for: " + project.getKey() );

parent = new Parent();
parent.setGroupId( toolchainKey.getGroupId() );
parent.setArtifactId( toolchainKey.getArtifactId() );
parent.setVersion( toolchainKey.getVersion() );

model.setParent( parent );

changed = true;
}
else
{
logger.info( "Toolchain not specified. Skipping toolchain-parent injection..." );
}

return changed;
}

}

0 comments on commit c243e09

Please sign in to comment.