Buckminster RCP simple project materialization - eclipse-rcp

After watching the webinar, skimming over the BuckyBook PDF, and following the Eclipse RCP build tutorial, I still don't know how to materialize a simple RCP plug-in project from CVS into an eclipse workspace.
Does anyone have an example with a CQUERY and an RMAP file, for a simple one project workspace?

Its actually easy.
Here is a sample CSPEC:
<?xml version="1.0" encoding="UTF-8"?>
<cq:componentQuery xmlns:cq="http://www.eclipse.org/buckminster/CQuery-1.0" resourceMap="example-site.rmap">
<cq:rootRequest name="example-site" componentType="eclipse.feature"/>
</cq:componentQuery>
Note the root request name property points to a component. If you have an RCP app which has a main bundle (say one that is the launching point to your app), then you would point to this component using the name property above. This CSPEC will then download all dependent components using the RMAP below, using search paths, providers etc.
The RMAP:
<searchPath name="default">
<provider
readerType="cvs"
componentTypes="osgi.bundle,eclipse.feature"
source="true"
mutable="true">
<uri format=":pserver:anon#cvs.local:/opt/data/cvsroot,{0}/">
<bc:propertyRef key="buckminster.component" />
</uri>
</provider>
</searchPath>
<searchPath name="galileo">
<provider readerType="eclipse.import" componentTypes="osgi.bundle,eclipse.feature"
mutable="false" source="false">
<uri format="http://download.eclipse.org/releases/galileo?importType=binary"/>
</provider>
</searchPath>
<locator searchPathRef="default" pattern="^example\-.*" />
<locator searchPathRef="galileo" failOnError="false" />

Related

Adding junit test single file target to free-form java project in netbeans

I promise, I've read:http://netbeans.org/kb/articles/freeform-config.html
I have a java free-form project that I would like to modify to include a "Test Single File" target to the context menu within Netbeans 7.2
The included link outlines creating an action with the name "test.single" (in order to override Netbeans' Test Single File command) and within that action creation, one must specify an ant target and a context object like so:
<context>
<property>testclass</property>
<folder>${current.dir}</folder>
<pattern>\.java$</pattern>
<format>java-name</format>
<arity>
<one-file-only/>
</arity>
</context>
So to summarize, I have:
Created the action in project.xml within the ide-actions block:
<action name="test.single">
<target>test-single</target>
<context>
<property>testclass</property>
<folder>${current.dir}</folder>
<pattern>\.java$</pattern>
<format>java-name</format>
<arity>
<one-file-only/>
</arity>
</context>
</action>
Added the ide-action to the context-menu block"
<ide-action name="test.single"/>
Adding this to the free-form project's project.xml file yields a grayed out "test.single" entry in the context menu upon right-clicking on the project name. Further, right clicking on a test class in my src/test directory yields a grayed out "Test Single File" entry.
I've checked and validated the xml and it all seems to check out. What could I be doing wrong?
thanks in advance!
Had the same problem and managed to solve it by cloning the action run.single in by nbproject/project.xml and calling it test.single:
<action name="test.single">
<script>build.xml</script>
<target>test-single</target>
<context>
<property>test.class</property>
<folder>src/java</folder>
<pattern>\.java$</pattern>
<format>java-name</format>
<arity>
<one-file-only/>
</arity>
</context>
</action>
I also changed the property to test.class as we need this in the projects build.xml to run the appropriate test class.
In the main build.xml I have a target test-single:
<target name="test-single" description="Run individual Unit tests" depends="compile, compile-test" >
<junit
printsummary="yes"
errorProperty="test.failed"
failureproperty="test.failed"
haltonfailure="yes"
fork="yes"
showoutput="yes">
<formatter type="plain" usefile="false"/>
<classpath>
<pathelement location="${build.base.classes.dir}" />
<pathelement location="${unit.test.classes.dir}" />
<pathelement location="${junit.dir}" />
</classpath>
<test name="${test.class}Test" todir="${results}">
</test>
</junit>
<fail message="Tests failed!" if="test.failed"/>
</target>
Note that the refers to the property ${test.class}. But when I leave it like that it tries to run the class being tested instead of the JUnit test class. Since this is always called the same as the class being tested with the word "Test" at the end I have written it so that the name is ${test.class}Test.

Automate jar export across projects in eclipse

I have a Google Web Toolkit project for which i include a second project into the build path. This other project has a lot of my commonly used functions and classes. Building the project works fine but to avoid run time errors i have to jar the second project into the WAR folder of the GAE project.
The process of jar/exporting the second project into the first is a manual process that i do with a right click in eclipse.
Is there a way to automate the process of jar/exporting to WAR of the second project into a location on the first?
Would i do this with an ANT script?
Or is there a way this can be done within Eclipse itself.
Thanks for you help
You are in for some reading mate :)
Step 1 : Create a JAR of the first project ( Read this). In the jar task you could put as the path of your GAE's folder lib as the destfile like so :
<target name="jar">
<jar basedir="bin" destfile="../GAE_PROJECT/war/WEB-INF/lib/${project-name}.jar">
<manifest>
<attribute name="Built-By" value="${builder}" />
<attribute name="Built-On" value="${build-info.current-date}" />
<attribute name="Built-At" value="${build-info.current-time}" />
</manifest>
</jar>
</target>
Step 2 : Create the WAR for your GAE project ( Read the official documentation here ). The documentation shows how the jars in the lib are included :
<fileset dir="war/WEB-INF/lib">
<include name="**/*.jar" />
</fileset>

How to configure a Google Web Toolkit application with Datanucleus + PostgreSQL

I created an application using GWT and support for the Google Datastore but now i'm trying to move my application to my own server and i'm also trying to detach my app from Google App Engine and from Datastore.
To be more precise: I want to stop using Google Datastore and start using JDO and Datanucleus but with PostgreSQL (or other relational database). I tried searching in Datanucleus.org but there was no simple tutorial for me to use.
Please, can someone help me?
Thank you very much!
=)
I've discovered how to do it though I think it should be more easy eheheh.
Here it goes:
1) First we must setup PostgreSQL server;
2) Create our web application with webAppCreator (from GWT SDK);
3) Since we must enhance our domain classes for them to be used by datanucleus and JDO, we have multiple options to do it. I used an Apache Ant task ( from Google App Engine SDK). If we do this we can use the good parts from app engine (simple class enhancement) but our application won't be tied to the restrictions of App Engine.
The additions to the build.xml created with webAppCreator:
<!-- this refers to the location of my Google AppEngine SDK -->
<property name="sdk.dir" location="C:/Projects/appengine-java-sdk" />
<import file="${sdk.dir}/config/user/ant-macros.xml" />
<target name="copyjars"
description="Copies the App Engine JARs to the WAR.">
<copy
todir="war/WEB-INF/lib"
flatten="true">
<fileset dir="${sdk.dir}/lib/user">
<include name="**/*.jar" />
</fileset>
</copy>
</target>
<target name="compile" depends="copyjars"
description="Compiles Java source and copies other source files to the WAR.">
<mkdir dir="war/WEB-INF/classes" />
<copy todir="war/WEB-INF/classes">
<fileset dir="src">
<exclude name="**/*.java" />
</fileset>
</copy>
<javac
srcdir="src"
destdir="war/WEB-INF/classes"
classpathref="project.class.path"
debug="on" />
</target>
<target name="datanucleusenhance" depends="compile"
description="Performs JDO enhancement on compiled data classes.">
<enhance_war war="war" />
</target>
4) Download the PostgreSQL JDBC Driver from the official site;
5) Download the datanucleus-rdbms.jar file from the official sourceforge page;
6) Add these jars to the Project Classpath;
7) Create a file with the following content:
javax.jdo.PersistenceManagerFactoryClass=org.datanucleus.jdo.JDOPersistenceManagerFactory
javax.jdo.option.ConnectionDriverName=org.postgres.jdbc.Driver
javax.jdo.option.ConnectionURL=jdbc:postgres://localhost:5432/myschool
javax.jdo.option.ConnectionUserName=root
javax.jdo.option.ConnectionPassword=rootroot
datanucleus.autoCreateTables=true
8) Create a PersistenceManagerFactory like this:
File propsFile = new File("Insert the location of the properties file here");
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(propsFile);
9) Create the domain classes and run the new Ant Target datanucleusenhance;
10) This will create enhanced classes and the connection with the relational database and also store the information in the PostgreSQL's tables.
11) If I'm not mistaken and if I didn't forget anything than that's all :)
Thank you for reading the question.
Please, if you notice anything wrong, can you tell me? It's my first time here :P
==== Some References ====
http://code.google.com/intl/en/appengine/docs/java/tools/ant.html#Enhancing_JDO_Classes

Netbeans manifest

Is it possible to add entries to the manifest.mf file of jars generated by netbeans?
to build an osgi bundle for instance.
Note that you can create a manifest on-the-fly via an ant task and set properties dynamically.
First, you must update your Netbeans "project.properties" file found in the "nbproject" directory. Add the following line to the file:
manifest.file=manifest.mf
Next, create an ant task to create/update the manifest using the "build.xml" file. In this example, we will set the version number and date of the jar file.
<target name="-pre-init">
<property name="project.name" value="My Library" />
<property name="version.num" value="1.4.1" />
<tstamp>
<format property="NOW" pattern="yyyy-MM-dd HH:mm:ss z" />
</tstamp>
<!--
<exec outputproperty="svna.version" executable="svnversion">
<arg value="-c" />
<redirector>
<outputfilterchain>
<tokenfilter>
<replaceregex pattern="^[0-9]*:?" replace="" flags="g"/>
<replaceregex pattern="M" replace="" flags="g"/>
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
-->
<manifest file="MANIFEST.MF">
<attribute name="Bundle-Name" value="${project.name}" />
<attribute name="Bundle-Version" value="${version.num}" />
<attribute name="Bundle-Date" value="${NOW}" />
<!--<attribute name="Bundle-Revision" value="${svna.version}" />-->
<attribute name="Implementation-Title" value="${project.name}" />
<attribute name="Implementation-Version" value="${version.num}" />
<attribute name="Implementation-URL" value="http://www.example.com" />
</manifest>
</target>
This will create a manifest file in your netbeans project directory and stuff it into your jar file. If you want to delete the autogenerated manifest file from your netbeans project directory, simply create another ant task (post jar of course):
<target name="-post-jar">
<delete file="MANIFEST.MF"/>
</target>
Interesting information might be here:
http://wiki.netbeans.org/FaqNoMainClass
I have a Java Class Library project with a custom manifest file - perfect for an OSGI bundle. To get this working first edit project.properties and set:
manifest.file=manifest.mf
manifest.available=true
Create your own custom manifest.mf file in the project directory.
(At this point if you try a clean/build you still won't get your custom manifest file - NetBeans will provide its own. This is because the build-impl.xml Ant target "-do-jar-with-libraries-without-manifest" is being called immediately after "-do-jar-with-manifest", overwriting your custom manifest JAR file with a default NetBeans manifest JAR.)
Add a custom target to your build.xml file as follows:
<target name="-do-jar-with-libraries-without-manifest">
<!-- Inserted to prevent target from running so we can have a custom
manifest file with a class library project type. -->
</target>
Tested in NetBeans 6.7.1
in the same dir as the build.xml
you can put your manifest.mf file
I'm using Netbeans 6.7.1
Turns out that the build-imp.xml (the actual build script Netbeans uses)
doesn't have a target which runs if 'with manifest, without main-class'
but it does have one like 'with manifest, with main-class'
So.. make sure you have the project-properties,run,main-Class filled with -anything-
i think that's some undocumented feature :(
this is my manifest content:
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Bundle-ManifestVersion: 2
Bundle-Name: jinstall
Bundle-SymbolicName: jinstall
Import-Package: ( .... )
Export-Package: ( .... )
Bundle-Activator: ( ..... )
In case you using maven (nbm-maven-plugin), look at this
NBM Maven plugin
Why not using the a maven project, which worked well for me? E.g. apache felix
See this pluggable Swing example which I created in netbeans.
You can edit the nbproject/build-impl.xml adding the necessary properties like this:
....
<target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+main.class.available" name="-do-jar-set-mainclass">
<manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update">
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Property1" value="foo"/>
<attribute name="Property2" value="bar"/>
</manifest>
</target>
....
This will result in a MANIFEST.MF in jar file like this:
Manifest-Version: 1.0
...
Property1: foo
Property2: bar
Tested on Netbeans 8.1.
See this article.
Here it is described how to
create own ant targets
add manual entries to manifest.mf for the output JAR
run custom ant targets from Netbeans

How can I automate compiling a large Java project?

I'm working on an automation project for my employer. We have a pool for each revision of our source code. When you download a revision, you need to create a directory structure with a bunch of third party includes to eventually build the project. I've automated this entire process up to the point of having my script (.bat) compile each particular runnable java application. There are many applications to this single project, and the directory listing looks something like this:
Proj Name
-variousincludesfolder1
-variousincludesfolder2
-variousincludesfolder3
-variousincludesfolder4
-runnableapplicationsandmoreincludes
-con.java
Right now, I'd like to do an automated compiling of con.java, but I don't know where to begin. People have suggested I try Ant, but any automated Ant file generation I get using Eclipse seems only enough to build con.java while an active project file exists. Is there anyway to automate this without using eclipse, to the point of having the batch file generate a .jar itself?
This is definitely a job for Ant. Don't rely on Eclipse-generated Ant files; read through the manual and write one yourself. (You'll likely find out that Ant does things you didn't think of doing in your build script, too.)
To be more specific, here is the documentation for the jar task.
You can define wildcard and pattern matches to include/exclude all sorts of files and folders in your build. Take a look at the Ant manual to see how things like filesets work with include and exclude filters.
Also, read the tutorial.
Here is a simple build file that looks to compile all java files and reference all jars. Place it in the top level directory:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="http://www.ibm.com/developerworks/xml/library/x-antxsl/examples/example2/ant2html.xsl"?>
<project name="Proj Name" default="build" basedir=".">
<property name="src.dir" value="${basedir}" description="base folder where the source files will be found. Typically under /src, but could be anywhere. Defaulting to root directory of the project" />
<property name="build.dir" value="build" description="Where to put build files, separate from src and resource files." />
<path id="master-classpath">
<fileset dir="${basedir}" description="looks for any jar file under the root directory">
<include name="**/*.jar" />
</fileset>
</path>
<target name="build" description="Compile all JAVA files in the project">
<javac srcdir="${src.dir}"
destdir="${build.dir}/classes"
debug="true"
deprecation="true"
verbose="false"
optimize="false"
failonerror="true">
<!--master-classpath is defined above to include any jar files in the project subdirectories(can be customized to include/exclude)-->
<classpath refid="master-classpath"/>
<!--If you want to define a pattern of files/folders to exclude from compilation...-->
<exclude name="**/realm/**"/>
</javac>
</target>
</project>