Search This Blog

Showing posts with label Darkstar. Show all posts
Showing posts with label Darkstar. Show all posts

12 April 2010

Project Darkstar, Red Dwarf, Kryten

As you are probably aware, Project Darkstar is no more.  Owen and others have moved it over into a new project called Red Dwarf.  One of the things I noticed was that they have a maven plugin to ease quick development cycles.  I decided to spend some time this weekend getting associated with the plugin and the new project.

I started off by redoing the original tutorial exercises from the Darkstar ServerAppTutorial and ClientTutorial.  One of the goals while doing this was to come up with a basic skeleton to get a RedDwarf project up and running quickly.  After getting each tutorial exercise running as a submodule in maven, I tweaked the pom's until I had a fairly clean approach.

Originally I had planned on documenting those minimal steps here.  Instead, I chose to write my first maven archetype.  I'm sure there are errors and such, but as you will see below, this should give you an entry point very quickly.  (Getting the archetype catalog working in Nexus was another story because it took me a few hours to realize that you will get a 500 Server Error if you try to point to a repository group [like 'public'] instead of a specific repository [thus the long URL below]).

Ok, let's get started.  First thing we need to do is use the archetype to create a basic structure:



F:\work>mvn archetype:generate -DarchetypeCatalog=http://kallisti.eoti.org:8081/content/repositories/snapshots/archetype-catalog.xml
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-archetype-plugin:2.0-alpha-5-SNAPSHOT:generate (default-cli) @ standalone-pom ---
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: http://kallisti.eoti.org:8081/content/repositories/snapshots/archetype-catalog.xml -> ardor3d-archetype (null)
2: http://kallisti.eoti.org:8081/content/repositories/snapshots/archetype-catalog.xml -> kryten-archetype (null)
Choose a number: : 2
[INFO] snapshot com.example.myapp:kryten-archetype:1.0-SNAPSHOT: checking for updates from eoti-public
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '218a428a68f50b483a388f7fee54d2bb1ceec981'; remote = 'f1bcef05eca9d0e230f5dc8ff1fa0b8af1e8ab53' - RETRYING
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '218a428a68f50b483a388f7fee54d2bb1ceec981'; remote = 'f1bcef05eca9d0e230f5dc8ff1fa0b8af1e8ab53' - IGNORING
Define value for property 'groupId': : org.eoti.kryten.test
Define value for property 'artifactId': : TestApp
Define value for property 'version':  1.0-SNAPSHOT: :
Define value for property 'package':  org.eoti.kryten.test: :
Confirm properties configuration:
groupId: org.eoti.kryten.test
artifactId: TestApp
version: 1.0-SNAPSHOT (hit enter)
package: org.eoti.kryten.test
(hit enter)
 Y: : (hit enter)
[INFO] Parent element not overwrited in F:\work\TestApp\api\pom.xml
[INFO] Parent element not overwrited in F:\work\TestApp\client\pom.xml
[INFO] Parent element not overwrited in F:\work\TestApp\server\pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25.844s
[INFO] Finished at: Sun Apr 11 23:26:34 PDT 2010
[INFO] Final Memory: 6M/11M
[INFO] ------------------------------------------------------------------------
F:\work>cd TestApp
I have bold-faced the actual typing involved...  This will create a basic structure:
F:\WORK\TESTAPP
│   pom.xml
│
├───api
│   │   pom.xml
│   │
│   └───src
│       └───main
│           └───java
│               └───org
│                   └───eoti
│                       └───kryten
│                           └───test
│                               └───api
│                                       MyApp.java
│
├───client
│   │   pom.xml
│   │
│   └───src
│       └───main
│           └───java
│               └───org
│                   └───eoti
│                       └───kryten
│                           └───test
│                               └───client
│                                       MyClient.java
│
└───server
    │   pom.xml
    │
    └───src
        └───main
            ├───java
            │   └───org
            │       └───eoti
            │           └───kryten
            │               └───test
            │                   └───server
            │                           MyServer.java
            │                           MyServerUser.java
            │
            └───resources
                └───META-INF
                        app.properties

As you can see, this makes a multimodule project.  The top-level pom specifies versions of libraries, repositories, etc.  The API module provides a common library to be used by both the client and server [in this case, it just converts Strings to/from ByteBuffers.  The server module is a minimalist server app and the client module is a minimalist client app (console i/o rather than swing from the tutorials).

To get started, we first need to build it
F:\work\TestApp>mvn clean install
Next, we will startup a red dwarf server, deploy the app and dependencies to it, and then boot it.
F:\work\TestApp>cd server
F:\work\TestApp\server>mvn validate -Psgs-run
This utilizes a maven profile (named 'sgs-run') to do all the heavy lifting via the red dwarf maven plugin.

In another terminal, go to the client subdirectory and start the client:
F:\work\TestApp\client>mvn validate -Pclient-run
The client-run profile just executes the client module (executable jar) with the dependencies in the classpath.  When it starts up, it will log into the server then wait for you to type.  Every time you hit enter, it will send the text you had typed to the server.  The server will simply respond with a message telling you that it received the message.  When you are done, type 'quit' or 'exit' to stop the client.

Once you are done and you want to stop the server, make sure to use the profile to stop it or you will have to kill it in the task manager (ie: do NOT use ctrl-c).
F:\work\TestApp\server>mvn validate -Psgs-stop
It will take about 1-2 minutes to shut down cleanly (in the 'sgs-run' window).

Now that you have a basic structure that you can easily run and test, start editing the code =)

NOTE: The URL has been changed:
mvn archetype:generate -DarchetypeCatalog=http://repository-malachid.forge.cloudbees.com/public-snapshot/archetype-catalog.xml


05 February 2010

Oracle Kills Off Project Darkstar

Well, as we all expected, Oracle is not taking any time in ruining the Java platform.  The latest on the chopping block? Project Darkstar.  There goes at least 3 projects I had planned.

27 June 2009

Update: Ardor3d and DarkMMO on OpenSolaris

As noted in the previous entry, I have Ardor3d working now in OpenSolaris (as of v 0.6-SNAPSHOT of Ardor3d).

I now have a mavenized-version of DarkMMO working as well (poms will be checked in soon).

Below is the startup script I am currently using to launch it.
#!/bin/bash

DS_PATH=`pwd`
DS_CP="$DS_PATH/DarkMMO-Client/target/DarkMMO-Client-1.0-SNAPSHOT.jar"
for file in $DS_PATH/DarkMMO-Client/target/dependency/*.jar; do
    DS_CP="$DS_CP:$file"
done

export LD_LIBRARY_PATH=/export/home/malachi/work/Ardor3Dv1/ardor3d-lwjgl/lib/lwjgl/native/solaris

java -cp $DS_CP -Ddarkmmo.nwndatadir="$DS_PATH/nwn" com.worldwizards.darkmmo.client.DarkMMOClient

14 May 2009

Project Darkstar

I recently had this conversation with Owen (rest of the conversation is here):

Owen F. Kellett to meLink

Wed, May 6, 2009 at 12:11 PM

Hi Malachi,

I haven't forgotten about you. Good news though. We have recently gotten approval to make the server api as well as the interfaces for writing custom services, authenticators, etc GPLv2 + classpath exception. We haven't updated the code yet, but this is coming very soon. I would anticipate the next official release should contain this new licensing scheme. In the meantime, keep an eye on our incremental releases: http://download.java.net/maven/2/com/projectdarkstar/server/sgs-server-dist/

Either the next one, or the one following will likely have this change.

thanks, Owen

Malachi de Ælfweald to Owen

Wed, May 6, 2009 at 3:39 PM

Hey Owen,

That is great news! So if I am understanding correctly, that will allow me to specify the sgs-server-api as a maven dependency without dropping the MIT licensing on my game?

Thanks, Malachi de Ælfweald http://www.google.com/profiles/malachid

Owen F. Kellett to me

Wed, May 6, 2009 at 5:09 PM

Yes that is correct. The classpath exception should free you from the requirement of using GPL for any linked code.



Based on that, I decided it was time to move forward with the darkstar-based projects...

Since I have a Hudson server, I decided to let it keep track of how to make it successfully build...

At first I was trying to build with JDK7, but it kept failing on the Javadoc module saying that the jars had invalid characters in it. That went away once I changed to JDK6. I also had to tell it to skip the tests, because one of them just hung forever...

The Hudson job for the server is here.
The Hudson job for the client is here.
The Hudson job for the maven plugin is here.

The distributables were delivered to Nexus.
sgs-server-dist-0.9.10-SNAPSHOT.zip
sgs-tutorial-server-dist-0.9.10-SNAPSHOT.zip
sgs-client-dist-0.9.10-SNAPSHOT.zip
sgs-tutorial-client-dist-0.9.10-SNAPSHOT.zip
sgs-maven-plugin-1.0-alpha-4-SNAPSHOT.jar

I created a new user on the server ('darkstar'/'darkstar') and unzipped the sgs-server-dist-0.9.10-SNAPSHOT.zip

I then created a symlink (/home/darkstar/current to /home/darkstar/sgs-server-dist-0.9.10-SNAPSHOT)

I don't know if it is correct, but I made this SMF manifest for it.

darkstar@kallisti [0] ~> svccfg import hudson.xml

darkstar@kallisti [0] ~> svcs -xv
svc:/application/darkstar:default (Project Darkstar Server)
State: maintenance since Thu May 14 23:37:36 2009
Reason: Restarting too quickly.
See: http://sun.com/msg/SMF-8000-L5
See: http://www.projectdarkstar.com/
See: /var/svc/log/application-darkstar:default.log
Impact: This service is not running.


darkstar@kallisti [0] ~> cat /var/svc/log/application-darkstar:default.log
WARNING: No application jar found with a META-INF/app.properties configuration file in the /home/darkstar/sgs-server-dist-0.9.10-SNAPSHOT/deploy directory
May 14, 2009 11:37:36 PM com.sun.sgs.impl.kernel.Kernel checkProperties
SEVERE: Missing required property com.sun.sgs.app.name
Exception in thread "main" java.lang.IllegalArgumentException: Missing required property com.sun.sgs.app.name
at com.sun.sgs.impl.kernel.Kernel.checkProperties(Kernel.java:855)
at com.sun.sgs.impl.kernel.Kernel.(Kernel.java:202)
at com.sun.sgs.impl.kernel.Kernel.main(Kernel.java:1123)
[ May 14 23:37:36 Stopping because all processes in service exited. ]
[ May 14 23:37:36 Restarting too quickly, changing state to maintenance. ]

Guess it's time to build an app...