<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2160/1/7/_/styles/combined.css?spaceKey=TOP&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/TOP/Building+Java+components">Building Java components</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~dlee">David M. Lee</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Added instructions for deploying to remote repo<br />
    </div>
        <br/>
                         <h4>Changes (24)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{numberedheadings} <br></td></tr>
            <tr><td class="diff-unchanged" >Components that interact with Asterisk SCF may be written in [Java|http://java.com].  They can do this by using the Java bindings for the Asterisk SCF interfaces. <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{note} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h2. (Maven) Installing Ice to the local repository <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h2. Using Maven <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">If you&#39;re using Maven, you must install the {{Ice.jar}} file to your local Maven repository.  Our {{build.xml}} file provides a {{install-ice}} target for doing just this.  You only need to do this once, or whenever you re-compile Ice. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">If you wish to use Maven to build your Java based Asterisk SCF components, you must either deploy the Ice and Asterisk SCF .jar&#39;s to your own artifact repository, or install them into your local Maven repository.  If you wish to use Maven, it&#39;s assumed that you already [know a bit about it|http://maven.apache.org/guides/getting-started/index.html].  If you have a team of developers, and want to share artifacts using a central Maven repository, such as [Artifactory|http://www.jfrog.com/products.php] or [Nexus|http://nexus.sonatype.org/], it&#39;s assumed that you already [know all about that, too|http://maven.apache.org/guides/introduction/introduction-to-repositories.html]. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;"># Set the environment variable {{ICE_HOME}} to your Ice installation prefix. <br># Change to the {{slice}} directory, and run {{ant ice.install-ice}} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3. Deploying Ice to a remote repository <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h2. Building  <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">If you&#39;re using a remote Maven repository, you must deploy the {{Ice.jar}} file to it.  Our {{build.xml}} file provides a {{deploy-ice}} target to help you out.  You only need to do this once, or whenever you re-compile Ice. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;"># Create the file {{~/.ant/repositories.properties}}, with the URL&#39;s for your repository manager <br>{code:none} <br>release.repo.url=http://artifactory.mycompany.internal/artifactory/ext-release-local <br>snapshot.repo.url=http://artifactory.mycompany.internal/artifactory/ext-snapshot-local <br>{code} <br># Add the following section to your {{~/.m2/settings.xml}} file. <br>{code:xml} <br>  &lt;servers&gt; <br>    &lt;server&gt; <br>      &lt;id&gt;asterisk.repo&lt;/id&gt; <br>      &lt;username&gt;deployer&lt;/username&gt; <br>      &lt;password&gt;song-20-cobol-at&amp;amp;t-elute-tawny-yawl&lt;/password&gt; <br>    &lt;/server&gt; <br>  &lt;/servers&gt; <br>{code} <br>{note} <br>Unfortunately, the Maven Ant Tasks [do not support password encryption|http://jira.codehaus.org/browse/MANTTASKS-177], so the password must be in plaintext. <br>{note} <br></td></tr>
            <tr><td class="diff-unchanged" ># Set the environment variable {{ICE_HOME}} to your Ice installation prefix. <br></td></tr>
            <tr><td class="diff-changed-lines" ># Change to the {{slice}} directory, and run {{ant <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">install}}</span> <span class="diff-added-words"style="background-color: #dfd;">ice.deploy-ice}}</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The build generates the following files: <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3. Installing Ice to the local repository <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{code} <br>  ./target/asterisk-scf-api.jar <br>  ./target/asterisk-scf-api-javadoc.jar <br>  ./target/asterisk-scf-api-sources.jar <br>{code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">If you&#39;re not using a remote repository, you may instead just deploy it to your local repository.  Once again, out {{build.xml}} helps you out with a {{install-ice}} target.  Similarly, You only need to do this once, or whenever you re-compile Ice. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h1. Usage with Maven <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;"># Set the environment variable {{ICE_HOME}} to your Ice installation prefix. <br># Change to the {{slice}} directory, and run {{ant ice.install-ice}} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Add the following dependency to your {{pom.xml}} file: <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3. Usage with Maven <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">For your component, add the following dependency to its {{pom.xml}} file: <br> <br></td></tr>
            <tr><td class="diff-unchanged" >{code:xml} <br>&lt;dependency&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h1. Usage without Maven <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h2. Not using Maven <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">If you&#39;re not using Maven for your dependency management, you can simply build that Asterisk SCF API .jar file and use it directly. <br> <br># Set the environment variable {{ICE_HOME}} to your Ice installation prefix. <br># Change to the {{slice}} directory, and run {{ant package}} <br> <br>The build generates the following files: <br> <br>* {{./java/asterisk-scf-api.jar}} <br>* {{./java/asterisk-scf-api-javadoc.jar}} <br>* {{./java/asterisk-scf-api-sources.jar}} <br> <br> <br></td></tr>
            <tr><td class="diff-unchanged" >Copy {{./java/asterisk-scf-api.jar}} to wherever you like to keep Java libraries, and add it to your classpath.  Also add {{$ICE_HOME/lib/Ice.jar}} to your classpath, where {{$ICE_HOME}} is the installation prefix for your Ice install. <br> <br>If you use an IDE, I also recommend attaching the sources and javadoc to the library.  This makes navigating the API much easier. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{numberedheadings} <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        
<p>Components that interact with Asterisk SCF may be written in <a href="http://java.com" class="external-link" rel="nofollow">Java</a>.  They can do this by using the Java bindings for the Asterisk SCF interfaces.</p>

<p>Asterisk SCF provides an <a href="htttp://ant.apache.org" class="external-link" rel="nofollow">Ant</a> <tt>build.xml</tt> file for building the Java bindings, and installing them into the local <a href="http://www.maven.org" class="external-link" rel="nofollow">Maven</a> repository.</p>

<h1><a name="BuildingJavacomponents-Buildinstructions"></a>1. Build instructions</h1>

<p>Before your begin, you must build Asterisk SCF itself.  See the appropriate <a href="/wiki/display/TOP/Installing" title="Installing">install page</a> for details.</p>

<p>If you've built Asterisk SCF from a clone of <tt>gitall</tt>, then you can cd into the <tt>slice</tt> directory.  Otherwise, you can obtain the latest Slice definitions by cloning <tt>git://git.asterisk.org/asterisk-scf/integration/slice</tt>.</p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Be sure that the Slice definitions you are using are consistent with those you used to compile Asterisk SCF.  The safest thing to do is to just build the Java bindings from the same sources you used to build Asterisk SCF.</td></tr></table></div>

<h2><a name="BuildingJavacomponents-UsingMaven"></a>1.1. Using Maven</h2>

<p>If you wish to use Maven to build your Java based Asterisk SCF components, you must either deploy the Ice and Asterisk SCF .jar's to your own artifact repository, or install them into your local Maven repository.  If you wish to use Maven, it's assumed that you already <a href="http://maven.apache.org/guides/getting-started/index.html" class="external-link" rel="nofollow">know a bit about it</a>.  If you have a team of developers, and want to share artifacts using a central Maven repository, such as <a href="http://www.jfrog.com/products.php" class="external-link" rel="nofollow">Artifactory</a> or <a href="http://nexus.sonatype.org/" class="external-link" rel="nofollow">Nexus</a>, it's assumed that you already <a href="http://maven.apache.org/guides/introduction/introduction-to-repositories.html" class="external-link" rel="nofollow">know all about that, too</a>.</p>

<h3><a name="BuildingJavacomponents-DeployingIcetoaremoterepository"></a>1.1.1. Deploying Ice to a remote repository</h3>

<p>If you're using a remote Maven repository, you must deploy the <tt>Ice.jar</tt> file to it.  Our <tt>build.xml</tt> file provides a <tt>deploy-ice</tt> target to help you out.  You only need to do this once, or whenever you re-compile Ice.</p>

<ol>
        <li>Create the file <tt>~/.ant/repositories.properties</tt>, with the URL's for your repository manager
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: plain; gutter: false">release.repo.url=http://artifactory.mycompany.internal/artifactory/ext-release-local
snapshot.repo.url=http://artifactory.mycompany.internal/artifactory/ext-snapshot-local</pre>
</div></div></li>
        <li>Add the following section to your <tt>~/.m2/settings.xml</tt> file.
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: xml; gutter: false">&lt;servers&gt;
    &lt;server&gt;
      &lt;id&gt;asterisk.repo&lt;/id&gt;
      &lt;username&gt;deployer&lt;/username&gt;
      &lt;password&gt;song-20-cobol-at&amp;amp;t-elute-tawny-yawl&lt;/password&gt;
    &lt;/server&gt;
  &lt;/servers&gt;</pre>
</div></div>
<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Unfortunately, the Maven Ant Tasks <a href="http://jira.codehaus.org/browse/MANTTASKS-177" class="external-link" rel="nofollow">do not support password encryption</a>, so the password must be in plaintext.</td></tr></table></div></li>
        <li>Set the environment variable <tt>ICE_HOME</tt> to your Ice installation prefix.</li>
        <li>Change to the <tt>slice</tt> directory, and run <tt>ant ice.deploy-ice</tt></li>
</ol>


<h3><a name="BuildingJavacomponents-InstallingIcetothelocalrepository"></a>1.1.2. Installing Ice to the local repository</h3>

<p>If you're not using a remote repository, you may instead just deploy it to your local repository.  Once again, out <tt>build.xml</tt> helps you out with a <tt>install-ice</tt> target.  Similarly, You only need to do this once, or whenever you re-compile Ice.</p>

<ol>
        <li>Set the environment variable <tt>ICE_HOME</tt> to your Ice installation prefix.</li>
        <li>Change to the <tt>slice</tt> directory, and run <tt>ant ice.install-ice</tt></li>
</ol>


<h3><a name="BuildingJavacomponents-UsagewithMaven"></a>1.1.3. Usage with Maven</h3>

<p>For your component, add the following dependency to its <tt>pom.xml</tt> file:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: xml; gutter: false">&lt;dependency&gt;
  &lt;groupId&gt;org.asterisk.scf&lt;/groupId&gt;
  &lt;artifactId&gt;api&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
&lt;/dependency&gt;</pre>
</div></div>

<h2><a name="BuildingJavacomponents-NotusingMaven"></a>1.2. Not using Maven</h2>

<p>If you're not using Maven for your dependency management, you can simply build that Asterisk SCF API .jar file and use it directly.</p>

<ol>
        <li>Set the environment variable <tt>ICE_HOME</tt> to your Ice installation prefix.</li>
        <li>Change to the <tt>slice</tt> directory, and run <tt>ant package</tt></li>
</ol>


<p>The build generates the following files:</p>

<ul>
        <li><tt>./java/asterisk-scf-api.jar</tt></li>
        <li><tt>./java/asterisk-scf-api-javadoc.jar</tt></li>
        <li><tt>./java/asterisk-scf-api-sources.jar</tt></li>
</ul>



<p>Copy <tt>./java/asterisk-scf-api.jar</tt> to wherever you like to keep Java libraries, and add it to your classpath.  Also add <tt>$ICE_HOME/lib/Ice.jar</tt> to your classpath, where <tt>$ICE_HOME</tt> is the installation prefix for your Ice install.</p>

<p>If you use an IDE, I also recommend attaching the sources and javadoc to the library.  This makes navigating the API much easier.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=TOP">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://wiki.asterisk.org/wiki/display/TOP/Building+Java+components">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=9076752&revisedVersion=9&originalVersion=8">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/TOP/Building+Java+components?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>