java-comment-preprocessor-6.0.1/README.md 0000664 0000000 0000000 00000020076 12631632404 0020110 0 ustar 00root root 0000000 0000000 Introduction
=============
It is the most powerful multi-pass preprocessor for Java but also it can be used everywhere for text processing if the destination technology supports Java like comment definitions. The Initial version was developed in 2002 by Igor Maznitsa to make easier development for J2ME platform to avoid bunch of repeated class sources for different devices, so that the preprocessor is a powerful tool to avoid DRY (Don't Repeat Yourself) problems. Injection of preprocessor directives into Java comments allows to keep full compatibility with standard Java development chain and make transparent usage in all Java IDEs.
The Latest prebuilt version
============================
[The Version 6.0.0](http://search.maven.org/#artifactdetails|com.igormaznitsa|jcp|6.0.0|maven-plugin)
Changelog
==========
- **6.0.0**
- bugfixing and log improvement
- RENAMED DIRECTIVE! //#assert renamed to appropriate name //#echo
- RENAMED FUNCTIONS! renamed XML functions to more appropriate and short names
- xml_getRoot to xml_root
- xml_elementAt to xml_get
- xml_elementsNumber to xml_size
- xml_getAttribute to xml_attr
- xml_getElementName to xml_name
- xml_getElementsForName to xml_list
- xml_getElementText to xml_text
- fixed //#exit and //#exitif behavior to prevent total exit and return level up in include stack
- added //#abort directive to provide possibility to stop preprocessing immediately without errors
- added function 'STR evalfile(STR)' for local preprocessing of a file body and return it as a string
- added predefined variables '__line__','__filename__','__filefolder__' and '__file__' which allow to get name and path parameters for the current preprocessing file path
- added predefined variables '__time__','__date__' and '__timestamp__' which work similar C++ predefined macroses
- added function 'STR str2java(STR,BOOL)' to escape and split string to be presented as java sources
- added functions 'STR str2js(STR)', 'STR str2json(STR)','STR str2xml(STR)' and 'STR str2csv(STR)'
- added functions 'STR xml_xlist(STR,STR)' and 'STR xml_xelement(STR,STR)' which allow to use xpath to get element lists an elements
- apache common-io and common-lang libraries have been packed into the jar and hidden
- added the short variant '//#ifdef BOOL' for '//#ifdefined BOOL'
- added '//#ifndef BOOL' to check that a variable is undefined
- added '//#definel NAME' and '//#define NAME' to define local and global variables, they can use not only the default TRUE value for defined variables, but also result of expression (example: //#define ten 2*5)
- added '//#undef NAME' to remove a variable definition from context
- added '//#error EXPR' and '//#warning EXPR' directives to throw exception and log warnings
- added support of custom line separator through the 'jcp.line.separator' system property
- added '//#noautoflush' to prevent auto saving text buffers after file preprocessing
How to use
===========
The Preprocessor can be used by different ways:
- as ANT task, and with Android SDK
- as Maven plugin
- [with Gradle through ANT task](https://github.com/raydac/java-comment-preprocessor/wiki/AndroidGradlePreprocessing)
- as Java framework with direct class calls
- as external utility through CLI (command line interface)
The Preprocessor is published in the Maven Central so that can be added in Maven projects without any problems
```
...
com.igormaznitsajcp6.0.0preprocessSourcesgenerate-sourcespreprocessclearGeneratedFoldersclear
...
```
How to use from command line
=============================
The Preprocessor jar can be started under Java as a console application. Let's take a look at short example below how to start in command line under Linux The Easy variant of usage:
```
java -jar jcp-6.0.0.jar --i:./test --o:./result
```
The Example just preprocess files from ./test folder which extensions allowed to be preprocessed by default, and places result into ./result folder, but keep in your mind that the preprocessor copies not all files, XML files will not be preprocessed by default. Files which extension are not marked for preprocessing will be just copied (of course if the extensions is not in the list of excluded file extensions)
More complex example:
```
java -jar jcp-6.0.0.jar --c --r --v --f:java,xml --ef:none --i:./test --o:./result '--p:HelloWorld=$Hello world$'
```
- --c clear the destination folder before work
- --r remove all Java-style comments from preprocessed result files
- --v show verbose log about preprocessing process
- --f include .java and .xml files into preprocessing (by default the preprocessor doesn't preprocess XNL files and the extension should to be defined explicitly)
- --ef don't exclude any extension from preprocessing
- --i use ./test as source folder
- --o use ./result as destination folder
- --p define named global variable HelloWorld? with the 'Hello world' content
The Main idea
==============
The Java language was born without any preprocessor in creator's mind and even now there are not any plans to include preprocessing into Java. It was good until mass usage Java on mobile and TV devices where we have bunches of half-compatible devices with (sometime) very bizarre standard framework implementations. In the case, preprocessing allows to decrease support of sources dramatically.
The only possible way to include preprocessing directives into Java and to not break standard processes and Java tool chain is to inject them into comments, take a look at the example below:
```Java
//#local TESTVAR="TEST LOCAL VARIABLE"
//#echo TESTVAR=/*$TESTVAR$*/
//#include "./test/_MainProcedure.java"
public static final void testproc()
{
System.out.println(/*$VARHELLO$*/);
System.out.println("// Hello commentaries");
//#local counter=10
//#while counter!=0
System.out.println("Number /*$counter$*/");
//#local counter=counter-1
//#end
System.out.println("Current file name is /*$SRV_CUR_FILE$*/");
System.out.println("Output dir is /*$SRV_OUT_DIR$*/");
//#if issubstr("Hello","Hello world")
System.out.println("Substring found");
//#endif
}
```
Multi-sectioned documents
==========================
Java sources usually have sections, there are the import section and the main section thus JCP has support for such case and there are three section where the preprocessor can write results - the prefix, the middle part and the postfix. Usually I use the prefix to form the import section for Java files. You can switch the text output for sections with //#prefix[+|-] and //#postfix[+|-] directives.
```Java
//#prefix+
import java.lang.*;
//#prefix-
public class Main {
//#prefix+
import java.util.*;
//#prefix-
public static void main(String ... args){}
}
```
OMG! It allows to remove all your comments!
============================================
Sometime it is very useful to remove all comments from my sources at all, JCP has such feature which can be turned on by special flag or command line switcher (see wiki). The Example of use for comment removing through CLI interface
```
java -jar ./jcp-6.0.0.jar --i:/sourceFolder --o:/resultFolder -ef:none --r
```
Donation
=========
If you like the software you can make some donation to the author
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AHWJHJFBAWGL2)
java-comment-preprocessor-6.0.1/changelog.txt 0000664 0000000 0000000 00000007444 12631632404 0021325 0 ustar 00root root 0000000 0000000 6.0.1
- improved the MAVEN plugin to hide content of potentially sensitive properties from printing into Maven log (issue #2)
- added --z option ('compareDestination' in MAVEN and ANT) to check content of existing result file and to not replace it if content equals (issue #1), by default turned off because makes some overhead
- fixed --c argument usage in CLI, now by default the preprocessor started in CLI doesn't clear its output folder, use --c to turn it on
- improved tests
- minor bug-fixing
6.0.0
- bugfixing and log improvement
- RENAMED DIRECTIVE! //#assert renamed to appropriate name //#echo
- RENAMED FUNCTIONS! renamed XML functions to more appropriate and short names
- xml_getRoot to xml_root
- xml_elementAt to xml_get
- xml_elementsNumber to xml_size
- xml_getAttribute to xml_attr
- xml_getElementName to xml_name
- xml_getElementsForName to xml_list
- xml_getElementText to xml_text
- fixed //#exit and //#exitif behavior to prevent total exit and return level up in include stack
- added //#abort directive to provide possibility to stop preprocessing immediately without errors
- added function 'STR evalfile(STR)' for local preprocessing of a file body and return it as a string
- added predefined variables 'line','filename','filefolder' and 'file' which allow to get name and path parameters for the current preprocessing file path
- added predefined variables 'time','date' and 'timestamp' which work similar C++ predefined macroses
- added function 'STR str2java(STR,BOOL)' to escape and split string to be presented as java sources
- added functions 'STR str2js(STR)', 'STR str2json(STR)','STR str2xml(STR)' and 'STR str2csv(STR)'
- added functions 'STR xml_xlist(STR,STR)' and 'STR xml_xelement(STR,STR)' which allow to use xpath to get element lists an elements
- apache common-io and common-lang libraries have been packed into the jar and hidden
- added the short variant '//#ifdef BOOL' for '//#ifdefined BOOL'
- added '//#ifndef BOOL' to check that a variable is undefined
- added '//#definel NAME' and '//#define NAME' to define local and global variables, they can use not only the default TRUE value for defined variables, but also result of expression (example: //#define ten 2*5)
- added '//#undef NAME' to remove a variable definition from context
- added '//#error EXPR' and '//#warning EXPR' directives to throw exception and log warnings
- added support of custom line separator through the 'jcp.line.separator' system property
- added '//#noautoflush' to prevent auto saving text buffers after file preprocessing
5.3.4
- added support of test source folder preprocessing for maven projects
- added the "clear" maven goal to clear created preprocessing folders or any defined folders and files
- by default the maven plugin trying to keep numeration of lines in preprocessed files (the 'keepLines' is true by default)
5.3.3
- fixed the bug in the comment removing (multiple stars before closing slash)
- fixed the exception if there is not any organization tag in a project pom.xml
- added support for '-' and '--' prefixes in CLI arguments
- improved CLI argument error messaging
- the license has been changed to Apache 2.0
5.3.2
- very minor refactoring.
- fixed issue (ID 5) "Removing strings contain only spaces"
- the first version published in the maven central
5.3.1
- very minor bug-fixing, added the main-class attribute in the preprocessor JAR Manifest
5.3
- Added feature to keep non-executing lines as commented ones (/k command line key), all non-executing lines will be saved in the output as commented ones
5.2
- Fixed issue (ID 3). The default charset was used to read text files.
5.1
- Fixed issue (ID 1). Inaccessible functionality both "load a file with global variables" and "define global variable" through a command line call.
5.0
- The initial published version of totally reworked preprocessor
java-comment-preprocessor-6.0.1/logo.svg 0000664 0000000 0000000 00000043062 12631632404 0020312 0 ustar 00root root 0000000 0000000
java-comment-preprocessor-6.0.1/pom.xml 0000664 0000000 0000000 00000031041 12631632404 0020140 0 ustar 00root root 0000000 0000000 4.0.0com.igormaznitsajcp6.0.1maven-pluginJava Comment PreprocessorA Multi-pass java based preprocessor which directives can be injected as Java commentshttps://github.com/raydac/java-comment-preprocessorUTF-8${maven.build.timestamp}yyyyMMddHHmm${user.home}/Programs/apache-maven-3.3.9GitHub Issueshttps://github.com/raydac/java-comment-preprocessor/issues2011raydacIgor Maznitsarrg4400@gmail.comhttp://www.igormaznitsa.com+2Author3.0https://github.com/raydac/java-comment-preprocessorscm:git:git://github.com/raydac/java-comment-preprocessor.gitscm:git:git@github.com:raydac/java-comment-preprocessor.gitIgor Maznitsahttp://www.igormaznitsa.comThe Apache Software License, Version 2.0http://www.apache.org/licenses/LICENSE-2.0.txtrepointegration-testsmaven-failsafe-plugin2.19integration-testverifyUTF-8maven.home${maven.home}plugin.jar${project.build.directory}/${project.build.finalName}.jarproject.pom${basedir}/pom.xmlprepare-distributiveorg.apache.maven.pluginsmaven-assembly-plugin2.4make-distributiveinstallsinglefalse${project.artifactId}-${project.version}-${timestamp}-distrsrc/assemble/distribution.xmlmake-bundleinstallsinglesrc/assemble/bundle.xmlorg.apache.maven.pluginsmaven-javadoc-plugin2.9generate-javadocpackagejarorg.apache.maven.pluginsmaven-gpg-plugin1.4sign-artifactsverifysignorg.apache.maven.plugin-toolsmaven-plugin-annotations3.3providedorg.apache.mavenmaven-plugin-api3.0.3compileorg.apache.mavenmaven-core3.0.3compilejunitjunit4.11testorg.mockitomockito-all1.10.8testorg.apache.antant1.8.2compileorg.apache.maven.plugin-testingmaven-plugin-testing-harness2.0testorg.apache.maven.sharedmaven-verifier1.3testorg.apache.maven.sharedmaven-shared-jar1.1testorg.apache.maven.sharedfile-management1.2.1org.apache.antant-testutil1.8.2testcommons-iocommons-io2.4compileorg.apache.commonscommons-lang33.4compileorg.apache.maven.pluginsmaven-plugin-plugin3.3truemojo-descriptordescriptorhelp-goalhelpmojoorg.apache.maven.pluginsmaven-shade-plugin2.4.2packageshadeorg.apache.commonshidden.jcp.org.apache.commonscommons-io:*org.apache.commons:*org.apache.maven.pluginsmaven-jar-plugin2.6com.igormaznitsa.jcp.JCPreprocessororg.apache.maven.pluginsmaven-site-plugin3.4org.codehaus.mojocobertura-maven-plugin2.6org.apache.maven.pluginsmaven-compiler-plugin3.3-Xlint:alltrue1.61.6truetrue**/JCPreprocessor/src/test/resources/com/igormaznitsa/jcp/it/maven/dummy_maven_project/**/*.javaorg.apache.maven.pluginsmaven-source-plugin2.4generate-sourcespackagejarorg.codehaus.mojoanimal-sniffer-maven-plugin1.14org.codehaus.mojo.signaturejava16-sun1.10ensure-java-1.6-class-librarytestcheckorg.codehaus.mojoexec-maven-plugin1.4.0javacom.igormaznitsa.jcp.JCPreprocessor--i:/home/igorm/1/cc/Source--o:/home/igorm/1/cc/Preprocessed
java-comment-preprocessor-6.0.1/src/ 0000775 0000000 0000000 00000000000 12631632404 0017413 5 ustar 00root root 0000000 0000000 java-comment-preprocessor-6.0.1/src/assemble/ 0000775 0000000 0000000 00000000000 12631632404 0021206 5 ustar 00root root 0000000 0000000 java-comment-preprocessor-6.0.1/src/assemble/bundle.xml 0000775 0000000 0000000 00000001770 12631632404 0023211 0 ustar 00root root 0000000 0000000
bundlefalsefalsejar${project.build.directory}/*.jar.asc*.jar*.pom*.pom.ascoriginal*.**.zip