Initial commit maven-project-utils

git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1460347 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..2a8ec12
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,106 @@
+<?xml version='1.0' encoding='UTF-8'?>

+<!-- * Licensed to the Apache Software Foundation (ASF) under one * or more 

+  contributor license agreements. See the NOTICE file * distributed with this 

+  work for additional information * regarding copyright ownership. The ASF 

+  licenses this file * to you under the Apache License, Version 2.0 (the * 

+  "License"); you may not use this file except in compliance * with the License. 

+  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 

+  * * Unless required by applicable law or agreed to in writing, * software 

+  distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT 

+  WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the 

+  License for the * specific language governing permissions and limitations 

+  * under the License. * -->

+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+  <modelVersion>4.0.0</modelVersion>

+

+  <parent>

+    <groupId>org.apache.maven.shared</groupId>

+    <artifactId>maven-shared-components</artifactId>

+    <version>19</version>

+    <relativePath>../maven-shared-components/pom.xml</relativePath>

+  </parent>

+

+  <artifactId>maven-project-utils</artifactId>

+  <version>1.0-SNAPSHOT</version>

+

+  <name>Maven Project Utils</name>

+

+  <description>

+    Utils for Maven Projects, such as resolving multimodule paths

+  </description>

+

+  <scm>

+    <connection>scm:svn:http://svn.apache.org/repos/asf/maven/shared/trunk/maven-project-utils</connection>

+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/shared/trunk/maven-project-utils</developerConnection>

+    <url>http://svn.apache.org/viewvc/maven/shared/trunk/maven-project-utils</url>

+  </scm>

+  <issueManagement>

+    <system>jira</system>

+    <url>http://jira.codehaus.org/browse/MSHARED</url>

+  </issueManagement>

+

+  <properties>

+    <mavenVersion>2.2.1</mavenVersion>

+  </properties>

+

+  <dependencies>

+    <dependency>

+      <groupId>org.apache.maven</groupId>

+      <artifactId>maven-project</artifactId>

+      <version>${mavenVersion}</version>

+    </dependency>

+    <dependency>

+      <groupId>org.apache.maven</groupId>

+      <artifactId>maven-model</artifactId>

+      <version>${mavenVersion}</version>

+    </dependency>

+    <dependency>

+      <groupId>jmock</groupId>

+      <artifactId>jmock</artifactId>

+      <version>1.1.0</version>

+      <scope>test</scope>

+    </dependency>

+    <dependency>

+      <groupId>junit</groupId>

+      <artifactId>junit</artifactId>

+      <version>3.8.2</version>

+      <scope>test</scope>

+    </dependency>

+  </dependencies>

+

+  <profiles>

+    <profile>
+      <id>run-its</id>

+      <build>

+        <plugins>

+          <plugin>

+            <groupId>org.apache.maven.plugins</groupId>

+            <artifactId>maven-invoker-plugin</artifactId>

+            <version>1.8</version>

+            <executions>

+              <execution>

+                <goals>

+                  <goal>install</goal>

+                  <goal>integration-test</goal>

+                  <goal>verify</goal>

+                </goals>

+              </execution>

+            </executions>

+            <configuration>

+              <projectsDirectory>src/it</projectsDirectory>

+              <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>

+              <postBuildHookScript>verify</postBuildHookScript>

+              <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>

+              <settingsFile>src/it/settings.xml</settingsFile>

+              <pomIncludes>

+                <pomInclude>*</pomInclude>

+              </pomIncludes>

+            </configuration>

+          </plugin>

+        </plugins>

+      </build>
+    </profile>

+  </profiles>

+

+</project>

diff --git a/src/it/aggregator-flat/aggregator/pom.xml b/src/it/aggregator-flat/aggregator/pom.xml
new file mode 100644
index 0000000..4915bd4
--- /dev/null
+++ b/src/it/aggregator-flat/aggregator/pom.xml
@@ -0,0 +1,18 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+  <modelVersion>4.0.0</modelVersion>

+  <groupId>org.apache.maven.shared.project.utils.it.aggregator-flat</groupId>

+  <artifactId>aggregator</artifactId>

+  <version>0.0.1-SNAPSHOT</version>

+  <packaging>pom</packaging>

+  

+  <distributionManagement>

+    <site>

+      <url>http://localhost/aggregator</url>

+    </site>

+  </distributionManagement>

+  

+  <modules>

+    <module>../project</module>

+  </modules>

+</project>
\ No newline at end of file
diff --git a/src/it/aggregator-flat/invoker.properties b/src/it/aggregator-flat/invoker.properties
new file mode 100644
index 0000000..071fe64
--- /dev/null
+++ b/src/it/aggregator-flat/invoker.properties
@@ -0,0 +1,3 @@
+invoker.goals = org.apache.maven.shared.project.utils.it:maven-projectutils-plugin:resolve-site

+invoker.project = aggregator

+invoker.debug = true
\ No newline at end of file
diff --git a/src/it/aggregator-flat/project/pom.xml b/src/it/aggregator-flat/project/pom.xml
new file mode 100644
index 0000000..5f8771c
--- /dev/null
+++ b/src/it/aggregator-flat/project/pom.xml
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+  <modelVersion>4.0.0</modelVersion>

+  <groupId>org.apache.maven.shared.project.utils.it.aggregator-flat</groupId>

+  <artifactId>project</artifactId>

+  <version>0.0.1-SNAPSHOT</version>

+  <packaging>pom</packaging>

+  

+</project>
\ No newline at end of file
diff --git a/src/it/aggregator-flat/verify.groovy b/src/it/aggregator-flat/verify.groovy
new file mode 100644
index 0000000..02d3e58
--- /dev/null
+++ b/src/it/aggregator-flat/verify.groovy
@@ -0,0 +1,22 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+File buildLog = new File( basedir, 'build.log' )

+assert buildLog.text.contains( '[INFO] Resolved distributionManagement site URL for org.apache.maven.shared.project.utils.it.aggregator-flat:aggregator:pom:0.0.1-SNAPSHOT: http://localhost/aggregator')

+// aggregator is not the parent of this project, so should use its own site URL

+assert buildLog.text.contains( '[INFO] Resolved distributionManagement site URL for org.apache.maven.shared.project.utils.it.aggregator-flat:project:pom:0.0.1-SNAPSHOT: null' )

diff --git a/src/it/multimodule-hierarchical/invoker.properties b/src/it/multimodule-hierarchical/invoker.properties
new file mode 100644
index 0000000..bafd56e
--- /dev/null
+++ b/src/it/multimodule-hierarchical/invoker.properties
@@ -0,0 +1,2 @@
+invoker.goals = org.apache.maven.shared.project.utils.it:maven-projectutils-plugin:resolve-site

+invoker.debug = true
\ No newline at end of file
diff --git a/src/it/multimodule-hierarchical/module/pom.xml b/src/it/multimodule-hierarchical/module/pom.xml
new file mode 100644
index 0000000..42fa60e
--- /dev/null
+++ b/src/it/multimodule-hierarchical/module/pom.xml
@@ -0,0 +1,12 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+  <modelVersion>4.0.0</modelVersion>

+  <parent>

+    <groupId>org.apache.maven.shared.project.utils.it.multimodule-hierarchical</groupId>

+    <artifactId>multimodule</artifactId>

+    <version>0.0.1-SNAPSHOT</version>

+  </parent>

+  <artifactId>module</artifactId>

+  <packaging>pom</packaging>

+  

+</project>
\ No newline at end of file
diff --git a/src/it/multimodule-hierarchical/pom.xml b/src/it/multimodule-hierarchical/pom.xml
new file mode 100644
index 0000000..65787c5
--- /dev/null
+++ b/src/it/multimodule-hierarchical/pom.xml
@@ -0,0 +1,18 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+  <modelVersion>4.0.0</modelVersion>

+  <groupId>org.apache.maven.shared.project.utils.it.multimodule-hierarchical</groupId>

+  <artifactId>multimodule</artifactId>

+  <version>0.0.1-SNAPSHOT</version>

+  <packaging>pom</packaging>

+  

+  <distributionManagement>

+    <site>

+      <url>http://localhost/multimodule</url>

+    </site>

+  </distributionManagement>

+  

+  <modules>

+    <module>module</module>

+  </modules>

+</project>
\ No newline at end of file
diff --git a/src/it/multimodule-hierarchical/verify.groovy b/src/it/multimodule-hierarchical/verify.groovy
new file mode 100644
index 0000000..e2426c1
--- /dev/null
+++ b/src/it/multimodule-hierarchical/verify.groovy
@@ -0,0 +1,21 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+File buildLog = new File( basedir, 'build.log' )

+assert buildLog.text.contains( '[INFO] Resolved distributionManagement site URL for org.apache.maven.shared.project.utils.it.multimodule-hierarchical:multimodule:pom:0.0.1-SNAPSHOT: http://localhost/multimodule')

+assert buildLog.text.contains( '[INFO] Resolved distributionManagement site URL for org.apache.maven.shared.project.utils.it.multimodule-hierarchical:module:pom:0.0.1-SNAPSHOT: http://localhost/multimodule/module' )

diff --git a/src/it/settings.xml b/src/it/settings.xml
new file mode 100644
index 0000000..666ef94
--- /dev/null
+++ b/src/it/settings.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>

+

+<!--

+Licensed to the Apache Software Foundation (ASF) under one

+or more contributor license agreements.  See the NOTICE file

+distributed with this work for additional information

+regarding copyright ownership.  The ASF licenses this file

+to you under the Apache License, Version 2.0 (the

+"License"); you may not use this file except in compliance

+with the License.  You may obtain a copy of the License at

+

+  http://www.apache.org/licenses/LICENSE-2.0

+

+Unless required by applicable law or agreed to in writing,

+software distributed under the License is distributed on an

+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+KIND, either express or implied.  See the License for the

+specific language governing permissions and limitations

+under the License.

+-->

+

+<settings>

+

+  <servers>

+    <server>

+      <id>my.server</id>

+      <username>me</username>

+      <password>{iFtD2TFFjzoHEDN1RxW21zEBYW0Gt7GwbsOm6yDS63s=}</password>

+    </server>

+  </servers>

+

+  <profiles>

+    <profile>

+      <id>it-repo</id>

+      <activation>

+        <activeByDefault>true</activeByDefault>

+      </activation>

+      <repositories>

+        <repository>

+          <id>local.central</id>

+          <url>@localRepositoryUrl@</url>

+          <releases>

+            <enabled>true</enabled>

+          </releases>

+          <snapshots>

+            <enabled>true</enabled>

+          </snapshots>

+        </repository>

+        <repository>

+          <id>apache.snapshots</id>

+          <name>Apache Snapshot Repository</name>

+          <url>http://people.apache.org/repo/m2-snapshot-repository</url>

+          <releases>

+            <enabled>false</enabled>

+          </releases>

+          <snapshots>

+            <enabled>true</enabled>

+          </snapshots>

+        </repository>

+      </repositories>

+      <pluginRepositories>

+        <pluginRepository>

+          <id>local.central</id>

+          <url>@localRepositoryUrl@</url>

+          <releases>

+            <enabled>true</enabled>

+          </releases>

+          <snapshots>

+            <enabled>true</enabled>

+          </snapshots>

+        </pluginRepository>

+      </pluginRepositories>

+    </profile>

+  </profiles>

+</settings>

diff --git a/src/it/setup-plugin/invoker.properties b/src/it/setup-plugin/invoker.properties
new file mode 100644
index 0000000..521301a
--- /dev/null
+++ b/src/it/setup-plugin/invoker.properties
@@ -0,0 +1 @@
+invoker.goals = install
\ No newline at end of file
diff --git a/src/it/setup-plugin/pom.xml b/src/it/setup-plugin/pom.xml
new file mode 100644
index 0000000..b6f66e6
--- /dev/null
+++ b/src/it/setup-plugin/pom.xml
@@ -0,0 +1,56 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+  <modelVersion>4.0.0</modelVersion>

+  <groupId>org.apache.maven.shared.project.utils.it</groupId>

+  <artifactId>maven-projectutils-plugin</artifactId>

+  <version>0.0.1-SNAPSHOT</version>

+  <packaging>maven-plugin</packaging>

+

+  <build>

+    <plugins>

+      <plugin>

+        <groupId>org.apache.maven.plugins</groupId>

+        <artifactId>maven-plugin-plugin</artifactId>

+        <version>3.2</version>

+        <configuration>

+          <!-- see http://jira.codehaus.org/browse/MNG-5346 -->

+          <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>

+        </configuration>

+        <executions>

+          <execution>

+            <id>mojo-descriptor</id>

+            <goals>

+              <goal>descriptor</goal>

+            </goals>

+          </execution>

+        </executions>

+      </plugin>

+      <plugin>

+        <groupId>org.apache.maven.plugins</groupId>

+        <artifactId>maven-compiler-plugin</artifactId>

+        <version>3.0</version>

+      </plugin>

+    </plugins>

+  </build>

+

+  <dependencies>

+    <dependency>

+      <groupId>org.apache.maven.shared</groupId>

+      <artifactId>maven-project-utils</artifactId>

+      <version>1.0-SNAPSHOT</version>

+    </dependency>

+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0.6</version>
+    </dependency>

+

+    <dependency>

+      <groupId>org.apache.maven.plugin-tools</groupId>

+      <artifactId>maven-plugin-annotations</artifactId>

+      <version>3.2</version>

+      <scope>provided</scope>

+    </dependency>

+

+  </dependencies>

+</project>
\ No newline at end of file
diff --git a/src/it/setup-plugin/src/main/java/org/apache/maven/shared/project/utils/it/ResolveSiteMojo.java b/src/it/setup-plugin/src/main/java/org/apache/maven/shared/project/utils/it/ResolveSiteMojo.java
new file mode 100644
index 0000000..8ddde49
--- /dev/null
+++ b/src/it/setup-plugin/src/main/java/org/apache/maven/shared/project/utils/it/ResolveSiteMojo.java
@@ -0,0 +1,23 @@
+package org.apache.maven.shared.project.utils.it;

+

+import org.apache.maven.plugin.AbstractMojo;

+import org.apache.maven.plugin.MojoExecutionException;

+import org.apache.maven.plugin.MojoFailureException;

+import org.apache.maven.plugins.annotations.Mojo;

+import org.apache.maven.plugins.annotations.Parameter;

+import org.apache.maven.project.MavenProject;

+import org.apache.maven.shared.project.utils.SiteUtils;

+

+@Mojo( name="resolve-site" )

+public class ResolveSiteMojo

+    extends AbstractMojo

+{

+    @Parameter( defaultValue = "${project}", required = true, readonly = true )

+    private MavenProject project;

+

+    public void execute()

+        throws MojoExecutionException, MojoFailureException

+    {

+        getLog().info( "Resolved distributionManagement site URL for " + project.getId() + ": " + SiteUtils.resolveDistributionManagementSiteUrl( project ) );

+    }

+}

diff --git a/src/it/standalone/invoker.properties b/src/it/standalone/invoker.properties
new file mode 100644
index 0000000..bafd56e
--- /dev/null
+++ b/src/it/standalone/invoker.properties
@@ -0,0 +1,2 @@
+invoker.goals = org.apache.maven.shared.project.utils.it:maven-projectutils-plugin:resolve-site

+invoker.debug = true
\ No newline at end of file
diff --git a/src/it/standalone/pom.xml b/src/it/standalone/pom.xml
new file mode 100644
index 0000000..9005f27
--- /dev/null
+++ b/src/it/standalone/pom.xml
@@ -0,0 +1,15 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+  <modelVersion>4.0.0</modelVersion>

+  <groupId>org.apache.maven.shared.project.utils.it.standalone</groupId>

+  <artifactId>standalone</artifactId>

+  <version>0.0.1-SNAPSHOT</version>

+  <packaging>pom</packaging>

+  

+  <distributionManagement>

+    <site>

+      <url>http://localhost/standalone</url>

+    </site>

+  </distributionManagement>

+

+</project>
\ No newline at end of file
diff --git a/src/it/standalone/verify.groovy b/src/it/standalone/verify.groovy
new file mode 100644
index 0000000..17dd0a4
--- /dev/null
+++ b/src/it/standalone/verify.groovy
@@ -0,0 +1,20 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+File buildLog = new File( basedir, 'build.log' )

+assert buildLog.text.contains( '[INFO] Resolved distributionManagement site URL for org.apache.maven.shared.project.utils.it.standalone:standalone:pom:0.0.1-SNAPSHOT: http://localhost/standalone')

diff --git a/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java b/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java
new file mode 100644
index 0000000..414d1a3
--- /dev/null
+++ b/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java
@@ -0,0 +1,63 @@
+package org.apache.maven.shared.project.utils;

+

+import java.util.List;

+

+import org.apache.maven.project.MavenProject;

+

+/*

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *  http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+

+public final class ProjectUtils

+{

+

+    private ProjectUtils()

+    {

+    }

+

+    /**

+     * Returns {@code true} if this project has no parent, or it has a parent but isn't one of its modules.

+     * 

+     * @param project the project to verify

+     * @return {@code true} if this is a root project, otherwise {@code false}

+     */

+    public static boolean isRootProject( MavenProject project )

+    {

+        if( project.hasParent() )

+        {

+            MavenProject parent = project.getParent();

+

+            // Are collectedProject the resolved modules?

+            @SuppressWarnings( "unchecked" )

+            List<MavenProject> collectedProjects = (List<MavenProject>) parent.getCollectedProjects();

+            

+            for( MavenProject collectedProject :  collectedProjects )

+            {

+                if( project.getId().equals( collectedProject.getId() ) )

+                {

+                    return true;

+                }

+            }

+            return false;

+        }

+        else 

+        {

+            return true;

+        }

+    }

+}

diff --git a/src/main/java/org/apache/maven/shared/project/utils/ScmUtils.java b/src/main/java/org/apache/maven/shared/project/utils/ScmUtils.java
new file mode 100644
index 0000000..1234a80
--- /dev/null
+++ b/src/main/java/org/apache/maven/shared/project/utils/ScmUtils.java
@@ -0,0 +1,115 @@
+package org.apache.maven.shared.project.utils;

+

+import org.apache.maven.model.Model;

+import org.apache.maven.project.MavenProject;

+

+/*

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *  http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+

+public final class ScmUtils

+{

+    private ScmUtils()

+    {

+    }

+

+    public static String resolveScmConnection( MavenProject project )

+    {

+        String scmConnection = getScmConnection( project.getModel() );

+

+        if ( scmConnection == null )

+        {

+            // prevent null-value

+            scmConnection = "" + getScmConnection( project );

+            

+            if ( !ProjectUtils.isRootProject( project ) )

+            {

+                // assuming that folder matches the moduleName

+                scmConnection += "/" + project.getFile().getParentFile().getName();

+            }

+        }

+        return scmConnection;

+    }

+

+    public static String resolveScmDeveloperConnection( MavenProject project )

+    {

+        String siteUrl = getScmDeveloperConnection( project.getModel() );

+

+        if ( siteUrl == null )

+        {

+            // prevent null-value

+            siteUrl = "" + getScmDeveloperConnection( project );

+            

+            if ( !ProjectUtils.isRootProject( project ) )

+            {

+                // assuming that folder matches the moduleName

+                siteUrl += "/" + project.getFile().getParentFile().getName();

+            }

+        }

+        return siteUrl;

+    }

+

+    protected static String getScmConnection( Model model )

+    {

+        if ( model.getScm() != null )

+        {

+            return model.getScm().getConnection();

+        }

+        else

+        {

+            return null;

+        }

+    }

+

+    protected static String getScmConnection( MavenProject project )

+    {

+        if ( project.getScm() != null )

+        {

+            return project.getScm().getConnection();

+        }

+        else

+        {

+            return null;

+        }

+    }

+

+    protected static String getScmDeveloperConnection( Model model )

+    {

+        if ( model.getScm() != null )

+        {

+            return model.getScm().getDeveloperConnection();

+        }

+        else

+        {

+            return null;

+        }

+    }

+

+    protected static String getScmDeveloperConnection( MavenProject project )

+    {

+        if ( project.getScm() != null )

+        {

+            return project.getScm().getDeveloperConnection();

+        }

+        else

+        {

+            return null;

+        }

+    }

+

+}

diff --git a/src/main/java/org/apache/maven/shared/project/utils/SiteUtils.java b/src/main/java/org/apache/maven/shared/project/utils/SiteUtils.java
new file mode 100644
index 0000000..e29746d
--- /dev/null
+++ b/src/main/java/org/apache/maven/shared/project/utils/SiteUtils.java
@@ -0,0 +1,78 @@
+package org.apache.maven.shared.project.utils;

+

+import org.apache.maven.model.Model;

+import org.apache.maven.project.MavenProject;

+

+/*

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *  http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+

+public final class SiteUtils

+{

+

+    private SiteUtils()

+    {

+    }

+    

+    public static String resolveDistributionManagementSiteUrl( MavenProject project )

+    {

+        String siteUrl = getDistributionManagementSiteUrl( project.getModel() ); 

+        

+        if( siteUrl == null  )

+        {

+            // prevent null-value

+            siteUrl = "" + getDistributionManagementSiteUrl( project );

+            if( !ProjectUtils.isRootProject( project ) )

+            {

+                // assuming that folder matches the moduleName

+                siteUrl += "/" + project.getFile().getParentFile().getName(); 

+            }

+        }

+        return siteUrl;

+    }

+    

+    /**

+     * 

+     * @param model

+     * @return return the url if available, otherwise {@code null} 

+     */

+    protected static final String getDistributionManagementSiteUrl( Model model )

+    {

+        if( model.getDistributionManagement() != null && model.getDistributionManagement().getSite() != null )

+        {

+            return model.getDistributionManagement().getSite().getUrl();

+        }

+        else

+        {

+            return null;

+        }

+    }

+

+    protected static final String getDistributionManagementSiteUrl( MavenProject project )

+    {

+        if( project.getDistributionManagement() != null && project.getDistributionManagement().getSite() != null )

+        {

+            return project.getDistributionManagement().getSite().getUrl();

+        }

+        else

+        {

+            return null;

+        }

+    }

+

+}