Makeopensource Documentation

Cotsec
share everything


Index
  Introduction
  Usage

Introduction

Makeopensource is a simple Ant task that copies an existing project directory to a target directory and performs the following translations:

Usage

Prerequisites: Makeopensource is an Ant task.  It will require both Ant and the Java JDK 1.5 (or above).

Usage:

  1. Edit the run/build.xml file and modify the source directory, file extension, and licence file location
  2. Type "ant" in the run directory
  3. Lines that contain the word 'copyright' but that don't match the translation regular expression are printed out as 'informational'.  This can be used to either modify the regular expression, or - if it's easier - to modify the copyright line to match the existing regexp.
makeopensource was initially used to translate existing Cotsec copyright notices in order to open-source the codebase.

Build.xml overview

Build.xml is a Jakarta Ant artifact that specifies the translation steps as follows:

<project name="Test Makeopen" default="makeopen">
      <!-- Note: You may well have to alter this classpath! -->

    <taskdef
        name="makeopen"
        classname="com.cotsec.projects.makeopensource.AntTask"
        classpath="../target/classes"/>

    <target name="makeopen"
            description="Add appropriate open source licences to your code, translate existing copyright notices">
        <makeopen
            newlicencetextfile="licencefile.txt"
            fileextensions="java"
            sourcedir="C:/cs/csworkspace/com.cotsec.commons"
            ignorefile="ignore_patterns.txt"
            replaceregexp="copyright.*?([0-9- ]+)\s(.*?)\s+all rights reserved"
            replacewith=" * Donated to the Open Source community by {2} in 2006 (copyright transferred)"
            destdir="output"
            >
        </makeopen>
    </target>

</project>

Download

Download makeopensource here

Example

An example input file is:



package com.cotsec.projects.makeopensource;


/**
 * Example code to be open-sourced
 *
 * Leave the author line and remove the copyright line.  Add a standard and short header to the top
 * of the file
 *
 * @author David Ford
 * @copyright (C) Copyright 2002 David Ford all rights reserved
 */
public class AntTask extends TaskBase {
    public static void main(String[] args) {
        System.out.println("Example code to be open-sourced...");
    }
}



And output:

/**
 * I am an example licence text file that will be inserted at the top
 * of the file.
 */

package com.cotsec.projects.makeopensource;


/**
 * Example code to be open-sourced
 *
 * Leave the author line and remove the copyright line.  Add a standard and short header to the top
 * of the file
 *
 * @author David Ford
 * Donated to the Open Source community by David Ford in 2006 (copyright transferred)
 */
public class AntTask extends TaskBase {
    public static void main(String[] args) {
        System.out.println("Example code to be open-sourced...");
    }
}

Bold indicates the modified lines by the translation process.