Back to DevDoc/Netigso

NetBinox

Here is the tutorial from Jaroslav.

Sources are there.

Mylyn tutorial with Maven

Here, I try to reproduce the mylyn demo application of Jaroslav with maven.

Status: Fails!

Get the sources

You can fetch the sources:

svn co http://svn.simexplorer.org/SimExplorer/misc/mylyn-demo-suite

or follow these instructions to build you own application :

  • Get Netbinox
  • Launch extracted netbinox distribution and create a maven project with archetype "Netbeans Platform application"
  • In the pom.xml of the main project (pom packaging:
    • add our maven repository:
          <repositories>
              <!-- should provide eclipse and netbeans artifacts -->
              <repository>
                  <id>SimExplorer</id>
                  <name>SimExplorer repository</name>
                  <url>http://maven.simexplorer.org/repo/</url>
              </repository>
          </repositories>
      
    • alter the netbeans.version property to netbinox-52-on-091120.
  • in the sample Netbeans Module
    • add the dependencies org.eclipse.mylyn.bugzilla:core and org.eclipse.equinox:common
    • add an action that will list issues from a bugzilla by using mylyn

Build and run

  • Because of a bug in maven, you have to temporarily set our repository as a mirror for the central maven repo, by editing your ~/.m2/settings.xml like that:
    <?xml version="1.0" encoding="UTF-8"?>
    <settings>
        <mirrors>
            <mirror>
                <id>simexplorer</id>
                <name>SimExplorer repository</name>
                <url>http://maven.simexplorer.org/repo/</url>
                <mirrorOf>central</mirrorOf>
            </mirror>
        </mirrors>
    </settings>
    
  • Then run the build
    mvn install
    
  • If you try to run the application module, netigso appears well in the list of started module, but bugzilla classes are not found (because not loaded), here is the stacktrace:
INFO [org.openide.loaders.FolderInstance.Menu.File]: Cannot create org.openide.loaders.FolderInstance$HoldInstance@1d602b3[Menu/File/fr-cemagref-netbinox-mylyn-mylyndemosuite-TestBugzilla.shadow]
java.lang.ClassNotFoundException: org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:259)
Caused: java.lang.ClassNotFoundException: org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector starting from ModuleCL@cd83d8[fr.cemagref.netbinox.mylyn.module1] with possible defining loaders null and declared parents [org.netbeans.MainImpl$BootClassLoader@2808b3]
        at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:261)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Caused: java.lang.NoClassDefFoundError: org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
        at java.lang.Class.getConstructor0(Class.java:2699)
        at java.lang.Class.getDeclaredConstructor(Class.java:1985)
        at org.openide.util.SharedClassObject.createInstancePrivileged(SharedClassObject.java:629)
        at org.openide.util.SharedClassObject$SetAccessibleAction.run(SharedClassObject.java:1001)
        at org.openide.util.SharedClassObject$SetAccessibleAction.run(SharedClassObject.java:993)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.openide.util.SharedClassObject.findObject(SharedClassObject.java:515)
        at org.openide.loaders.InstanceSupport.instanceCreate(InstanceSupport.java:214)
Caused: java.lang.ClassNotFoundException: Cannot instantiate fr.cemagref.netbinox.mylyn.mylyndemosuite.TestBugzilla for MultiFileObject@a84b47[Actions/File/fr-cemagref-netbinox-mylyn-mylyndemosuite-TestBugzilla.instance]
        at org.openide.loaders.InstanceSupport.instanceCreate(InstanceSupport.java:230)
        at org.openide.loaders.InstanceDataObject$Ser.instanceCreate(InstanceDataObject.java:1386)
        at org.openide.loaders.InstanceDataObject.instanceCreate(InstanceDataObject.java:824)
        at org.openide.loaders.FolderInstance.instanceForCookie(FolderInstance.java:585)
        at org.openide.awt.MenuBar$LazyMenu$MenuFolder.instanceForCookie(MenuBar.java:651)
        at org.openide.loaders.FolderInstance$HoldInstance.instanceCreate(FolderInstance.java:1135)
        at org.openide.loaders.FolderInstance$1R.instances(FolderInstance.java:705)
[catch] at org.openide.loaders.FolderInstance$1R.run(FolderInstance.java:726)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:602)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1084)

Appendix: how to populate the maven repository

  • eclipse
    mvn eclipse:to-maven -DeclipseDir=eclipse -DstripQualifier=true
    
  • netbinox
    # Get regular Netbeans nbm
    wget 'http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastSuccessfulBuild/artifact/nbbuild/nbms/*zip*/nbms.zip'
    unzip nbms.zip
    # Build Netbinox nbm
    hg clone http://source.apidesign.org/hg/netbinox
    cd netbinox
    ant nbms
    # Populate maven local repository
    mvn nbm:populate-repository -DforcedVersion=netbinox-hg-20090125142700 -DnetbeansInstallDirectory=netbinox/tmp/netbeans -DnetbeansNbmDirectory=nbms
    

Mylyn tutorial with a classic ant project

  • create a NB application suite project
  • Edit the build.xml and add
    <ant antfile="platform.xml" target="convert"/>
    
  • Create the platform.xml file with this content:
    <?xml version="1.0" encoding="UTF-8"?>
    <project name="test-mylyn-nomaven" default="build" basedir=".">
        <!-- BEGIN: netbinox.mylyn.clusterize -->
        <target name="convert">
            <ant antfile="${harness.dir}/suite.xml" target="clusterize">
                <property name="cluster" location="../mylyn-bundles"/>
                <property name="includes" value="modules/*.jar"/>
            </ant>
        </target>
        <!-- END: netbinox.mylyn.clusterize -->
    </project>
    
  • create the directory mylyn-bundles, the subdirectory mylyn-bundles/modules and put into this one eclipse and mylyn bundles
  • run ant on the project for initializing the cluster of mylyn bundles
  • in the properties of the suite add the cluster just initialized
  • create a module in your suite and add an action
  • add as libraries in this module: org.eclipse.equinox.common, org.eclipse.mylyn.bugzilla.core and org.eclipse.mylyn.tasks.core
  • put your mylyn-related code in this action
            TaskRepository repository = new TaskRepository("bugzilla", "http://issues.apache.org/bugzilla");
            TaskRepositoryManager trm = new TaskRepositoryManager();
            BugzillaRepositoryConnector brc = new BugzillaRepositoryConnector();
            trm.addRepository(repository);
            trm.addRepositoryConnector(brc);
            IRepositoryQuery query = new RepositoryQuery(repository.getConnectorKind(), "");
            query.setUrl("/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&limit=5");
            final List<TaskData> collectedData = new ArrayList<TaskData>();
            TaskDataCollector collector = new TaskDataCollector() {
    
                public void accept(TaskData taskData) {
                    collectedData.add(taskData);
                }
            };
            brc.performQuery(repository, query, collector, null, new NullProgressMonitor());
    
            StringBuffer sb = new StringBuffer();
            sb.append("Info: listed 5 issues from ").append(repository.getUrl()).append("\n\n");
            for (TaskData td : collectedData) {
                sb.append(td.getTaskId()).append(" - ");
                sb.append(td.getRoot().getMappedAttribute(BugzillaAttribute.SHORT_DESC.getKey()).getValue());
                sb.append("\n");
            }
            JOptionPane.showMessageDialog(null, sb.toString());
    
  • fix imports and run!

logo cemagref

logo iscpif

logo lifegrid

logo region auvergne

logo patres project