Quantcast
Channel: Oracle Bloggers
Viewing all articles
Browse latest Browse all 19780

Set Up Couchbase Java Client Sources in NetBeans IDE

$
0
0

The Couchebase Java Client is a library for other clients to implement. The Couchbase team uses Ant to test and create the JAR, while using both Ivy and Maven for dependency related tasks. In other words, a highly customized project structure. How to set it up in NetBeans IDE? The end goal is this:

I.e., no red error marks, and [which you can't see above], code completion working, as well as compilation of the application. Also, the ability to run single test classes is a requirement.

Therefore, use the Java Free-Form Project Type and point to the root folder of the download, once you've got it from Git:

https://github.com/couchbase/couchbase-java-client 

Spend some time configuring the project, with this end result:

Below, for the Source Packages, select all the JARs from build/ivy/lib/couchbase-client/common. Then, for the Test Packages, select all JARs from build/ivy/lib/couchbase-client/common AND from build/jars/*.jar:

Everything below is defined as you see it by default, except for the mapping of "jar" to Build Project and "mvn-install" to Run Project:

What's great is that all these configurations have no impact on the original build.xml file. Nevertheless, one small, but very important, tweak should be done to the 'clean' target in the build.xml file, so that the "nbproject" file is not deleted when clean target is run. 

Next, let's make it possible to, as requested, provide the ability to run individual test classes. In the project.xml file, add this to the ide-actions section:

<action name="test.single"><script>nbproject/ide-file-targets.xml</script><target>run-selected-files-in-test</target><context><property>classname</property><folder>src/test/java</folder><pattern>\.java$</pattern><format>java-name</format><arity><one-file-only/></arity></context></action>

Then create a new file named ide-file-targets.xml in the same folder as where project.xml is found and define it as follows:

<?xml version="1.0" encoding="UTF-8"?><project basedir=".." name="couchbase-client-IDE"><target name='run-selected-files-in-test'><fail unless='classname'>Must set property 'classname'</fail><ant antfile="build.xml" inheritall="false"><target name="jar"/><target name="srcjar"/><target name="package"/><target name="mvn-prep"/></ant><junit 
            dir='build/test/classes'
            printsummary='true'
            showoutput='true'
            fork='true'><classpath><pathelement path="build/ivy/lib/couchbase-client/common/asm-3.3.1.jar:
build/ivy/lib/couchbase-client/common/cglib-2.2.2.jar:
build/ivy/lib/couchbase-client/common/commons-codec-1.5.jar:
build/ivy/lib/couchbase-client/common/easymock-2.4.jar:
build/ivy/lib/couchbase-client/common/easymockclassextension-2.4.jar:
build/ivy/lib/couchbase-client/common/httpcore-4.1.1.jar:
build/ivy/lib/couchbase-client/common/httpcore-nio-4.1.1.jar:
build/ivy/lib/couchbase-client/common/jettison-1.1.jar:
build/ivy/lib/couchbase-client/common/jmock-1.2.0.jar:
build/ivy/lib/couchbase-client/common/junit-4.7.jar:
build/ivy/lib/couchbase-client/common/junit-addons-1.4.jar:
build/ivy/lib/couchbase-client/common/mockito-all-1.9.5.jar:
build/ivy/lib/couchbase-client/common/netty-3.5.5.Final.jar:
build/ivy/lib/couchbase-client/common/spymemcached-2.8.12.jar:
build/ivy/lib/couchbase-client/common/spymemcached-test-2.8.12.jar:
build/jars/couchbase-client-no-version.jar:
build/jars/couchbase-client-test-no-version.jar"/></classpath>            <formatter type='brief' usefile='false'></formatter><formatter type='xml'></formatter><test name='${classname}'></test></junit></target></project>

Better than the above is to use "Automatic Projects", which works fine in 7.3:

http://wiki.netbeans.org/AutomaticProjects

http://plugins.netbeans.org/plugin/37522/automatic-projects

I will blog about this soon, works perfectly with Couchbase Java Client Library.


Viewing all articles
Browse latest Browse all 19780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>