<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2171/18/9/_/styles/combined.css?spaceKey=TOP&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>
<br/>
<h4>Changes (2)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >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 [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's assumed that you already [know all about that, too|http://maven.apache.org/guides/introduction/introduction-to-repositories.html]. <br> <br></td></tr>
<tr><td class="diff-changed-lines" >h3. <span class="diff-added-words"style="background-color: #dfd;">(Option 1)</span> Deploying Ice to a remote repository <br></td></tr>
<tr><td class="diff-unchanged" > <br>If you'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-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" ># Change to the {{slice}} directory, and run {{ant ice.deploy-ice}} <br> <br></td></tr>
<tr><td class="diff-changed-lines" >h3. <span class="diff-added-words"style="background-color: #dfd;">(Option 2)</span> Installing Ice to the local repository <br></td></tr>
<tr><td class="diff-unchanged" > <br>If you'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-snipped" >...<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-%28Option1%29DeployingIcetoaremoterepository"></a>1.1.1. (Option 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"><servers>
<server>
<id>asterisk.repo</id>
<username>deployer</username>
<password>song-20-cobol-at&amp;t-elute-tawny-yawl</password>
</server>
</servers></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-%28Option2%29InstallingIcetothelocalrepository"></a>1.1.2. (Option 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"><dependency>
<groupId>org.asterisk.scf</groupId>
<artifactId>api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency></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=10&originalVersion=9">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/TOP/Building+Java+components?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>