alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (Main.scala)

This example Scala source code file (Main.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

array, array, main, main, pluginrunner, pluginrunner, settings, settings

The Scala Main.scala source code

package plugintemplate.standalone

import plugintemplate.PluginProperties
import scala.tools.nsc.CompilerCommand
import scala.tools.nsc.Settings

/** An object for running the plugin as standalone application.
 * 
 *  @todo: print, parse and apply plugin options !!!
 *  ideally re-use the TemplatePlugin (-> runsAfter, optionsHelp,
 *  processOptions, components, annotationChecker) instead of
 *  duplicating it here and in PluginRunner.
 */
object Main {
  def main(args: Array[String]) {
    val settings = new Settings

    val command = new CompilerCommand(args.toList, settings) {
      /** The command name that will be printed in in the usage message.
       *  This is automatically set to the value of 'plugin.commandname' in the
       *  file build.properties.
       */
      override val cmdName = PluginProperties.pluginCommand
    }

    if (!command.ok)
      return()

    /** The version number of this plugin is read from the properties file
     */
    if (settings.version.value) {
      println(command.cmdName +" version "+ PluginProperties.versionString)
      return()
    }
    if (settings.help.value) {
      println(command.usageMsg)
      return()
    }

    val runner = new PluginRunner(settings)
    val run = new runner.Run
    run.compile(command.files)
  }
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala Main.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.