Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2012 Red Hat, Inc. and/or its affiliates.
  *
  * Licensed under the Eclipse Public License version 1.0, available at
  * http://www.eclipse.org/legal/epl-v10.html
  */
 package org.jboss.forge.maven.providers;
 
Setup parent-child relation of Maven projects.

Author(s):
Torben Jaeger
Lincoln Baxter, III
   @Inject
   @Override
   public void associate(final Project projectfinal DirectoryResource parentDir)
   {
      if (canAssociate(projectparentDir))
      {
         Project parent = .findProject(parentDir);
         MavenCoreFacet parentMCF = parent.getFacet(MavenCoreFacet.class);
         Model parentPom = parentMCF.getPOM();
         parentPom.setPackaging("pom");
         parentPom.addModule(project.getProjectRoot().toString());
         parentMCF.setPOM(parentPom);
         MavenCoreFacet mcf = project.getFacet(MavenCoreFacet.class);
         Model pom = mcf.getPOM();
         Parent parentEntry = new Parent();
         parentEntry.setGroupId(parentPom.getGroupId());
         parentEntry.setArtifactId(parentPom.getArtifactId());
         parentEntry.setVersion(parentPom.getVersion());
         pom.setParent(parentEntry);
         mcf.setPOM(pom);
      }
   }
   @Override
   public boolean canAssociate(final Project projectfinal DirectoryResource parent)
   {
      return parent.getChild("pom.xml").exists() && project.getProjectRoot().getChild("pom.xml").exists();
   }
New to GrepCode? Check out our FAQ X