Wednesday, April 29, 2015

Build single bundle checkout - WSO2

Sometime you need to checkout single bundle from WSO2 source repository and build. Lets say you need to check out this bundle and build.

svn co https://svn.wso2.org/repos/wso2/carbon/platform/branches/turing/components/identity/org.wso2.carbon.identity.application.authenticator.facebook/4.2.0

If you try to build using maven (version >= 3.0.5), it will end with following error.
[INFO] Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/org/wso2/carbon/identity/4.2.0/identity-4.2.0.pom
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project org.wso2.carbon:org.wso2.carbon.identity.application.authenticator.facebook:4.2.0 (/home/ajith/Desktop/4.2.0/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM: Could not find artifact org.wso2.carbon:identity:pom:4.2.0 in central (http://repo.maven.apache.org/maven2) and 'parent.relativePath' points at wrong local POM @ line 18, column 10 -> [Help 2]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
 
How to fix.

1. You need to remove the <parent> element.
<!--parent>
        <groupId>org.wso2.carbon</groupId>
        <artifactId>identity</artifactId>
        <version>4.2.0</version>
        <relativePath>../../pom.xml</relativePath>
</parent-->
2. Add groupId element.
<groupId>org.wso2.carbon</groupId>
3. Define the version for all the dependencies that not available. Eg:
<dependency>
         <groupId>org.wso2.carbon</groupId>
         <artifactId>org.wso2.carbon.logging</artifactId>
         <version>4.2.0</version>
</dependency>

      <dependency>
         <groupId>org.wso2.carbon</groupId>
         <artifactId>org.wso2.carbon.ui</artifactId>
         <version>4.2.0</version>
</dependency>
4. Define the maven repositories to get the artifacts.
<repositories>
      <!-- WSO2 released artifact repository -->
      <repository>
         <id>wso2.releases</id>
         <name>WSO2 Releases Repository</name>
         <url>http://maven.wso2.org/nexus/content/repositories/releases/</url>
         <releases>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
            <checksumPolicy>ignore</checksumPolicy>
         </releases>
      </repository>
      <repository>
         <id>wso2-nexus</id>
         <name>WSO2 internal Repository</name>
         <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
         <releases>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
            <checksumPolicy>ignore</checksumPolicy>
         </releases>
      </repository>
</repositories>