Skip to content

Commit

Permalink
Implemented the packaging of the plugin and cleaned a little.
Browse files Browse the repository at this point in the history
Now the plugin/product is ready to be distributed through an Eclipse Update Site. For that I created both:

- an Update Site project: to deliver the product
- a Feature project: to put it in the update site (can't put plugins directly)

Proper documentation has been added, especially as building the site has some quirks (with the basic tool one can't choose the export folder for instance).

Note that the export of the site embeds an instance of the Node.js program.

Grunt has also been added (along with npm package definition to do things well) in order to create a cleaning task, especially for the update site which gets generated locally.

I also added the main project (Plugin project) files to version control, since it's in fact part of the project configuration and not a user preference. And honestly most people will use Eclipse to work on this project, since PDE (Plugin Development Environment) is easier to use through it.

Finally, documentation has been updated, and things cleaned a little.

Here are some other technical changes:

- the Backend class has been refactored a lot, and a dedicated ProcessRunner class has been introduced (more powerful than the standard one).
- added a grunt task to configure automatically the port used by the backend to match the one used in the plugin
- changed this port arbitrary to 50000

Implements most of #1 (except maybe a proper interaction with the backend regarding its initialization - like for the port number), and all of #16.

fixes #16
closes #20
  • Loading branch information
ymeine committed Sep 3, 2014
1 parent 03ad0e3 commit c5951e5
Show file tree
Hide file tree
Showing 32 changed files with 897 additions and 302 deletions.
8 changes: 8 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="bin/"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/.classpath
/.project
/.settings/
/bin/
/export/
node_modules
bin
runtime
editor-plugin.zip
22 changes: 22 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AT Editor</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
107 changes: 107 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
module.exports = function(grunt) {

// ------------------------------ Definition of tasks using external modules

var node_url_prefix = "http://nodejs.org/dist/v";
var node_url_suffix = "/node.exe";

var node_version = "0.10.31";
var node_architecture = "32";

var node_url = node_url_prefix + node_version + (node_architecture === "64" ? "/x64" : "") + node_url_suffix;

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
'bin': ['bin/'],

'site': [
'build/site/artifacts.jar',
'build/site/content.jar',
'build/site/logs.zip',
'build/site/features/',
'build/site/plugins/'
],

'package': 'editor-plugin.zip',

'external': [
'runtime/node.exe'
]
},
curl: {
node: {
src: node_url,
dest: 'runtime/node.exe'
},
},

execute: {
'backend-build': {
src: ['node_modules/editor-backend/scripts/build.js']
}
},

compress: {
'site': {
options: {
archive: 'editor-plugin.zip'
},
files: [
{expand: true, cwd: 'build/site/', src: ['site.xml'], dest: '/'},
{expand: true, cwd: 'build/site/features/', src: ['**'], dest: '/features'},
{expand: true, cwd: 'build/site/plugins/', src: ['**'], dest: '/plugins'}
]
}
}
});

grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-curl');
grunt.loadNpmTasks('grunt-execute');
grunt.loadNpmTasks('grunt-contrib-compress');



// ------------------------------------------------- Custom tasks definition

grunt.registerTask('configure-backend-port', 'Applies custom configurations', function(port) {
// ------------------------------------------ Input arguments processing

port = parseInt(port, 10);

// ------------------------------------------------ Options modification

var default_options = require("editor-backend/app/options");
default_options.network.ports.prefered = port;
var output = JSON.stringify(default_options);

// ------------------------------------------------------- Result output

var fs = require('fs');
var pathlib = require('path');

var basepath = pathlib.join(__dirname, "node_modules", "editor-backend", "app")

// Remove the initial "options.js" file it it still exists (first time execution or after any npm install/update)

var initialFile = pathlib.join(basepath, "options.js");
if (fs.existsSync(initialFile)) {
fs.unlink(initialFile);
}

// Writes new options in "options.json"

fs.writeFileSync(pathlib.join(basepath, "options.json"), output);
});



// ----------------------------------------------- Compound tasks definition

grunt.registerTask('prepare-site', ['curl:node', 'execute:backend-build', 'configure-backend-port:50000', 'clean:site']);
// TODO Also remove the files as said in the doc
grunt.registerTask('package-site', ['compress:site', 'clean:site'])

// grunt.registerTask('default', ['clean', 'export']);
};
Loading

0 comments on commit c5951e5

Please sign in to comment.