All Projects → raydac → Java Comment Preprocessor

raydac / Java Comment Preprocessor

Licence: apache-2.0
The Most Powerful Multi-Pass Java Preprocessor

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Java Comment Preprocessor

Simple-YAML
A Java API that provides an easy-to-use way to store data using the YAML format.
Stars: ✭ 68 (-38.74%)
Mutual labels:  maven, comments
jscc
Tiny and powerful preprocessor for conditional comments and replacement of compile-time variables in text files
Stars: ✭ 44 (-60.36%)
Mutual labels:  preprocessor, comments
Insider
Static Application Security Testing (SAST) engine focused on covering the OWASP Top 10, to make source code analysis to find vulnerabilities right in the source code, focused on a agile and easy to implement software inside your DevOps pipeline. Support the following technologies: Java (Maven and Android), Kotlin (Android), Swift (iOS), .NET Full Framework, C#, and Javascript (Node.js).
Stars: ✭ 216 (+94.59%)
Mutual labels:  cli, maven
Mvn Search
command-line interface for the haters of the search.maven.org UI
Stars: ✭ 79 (-28.83%)
Mutual labels:  cli, maven
Cri
A tool for building commandline applications
Stars: ✭ 110 (-0.9%)
Mutual labels:  cli
Fuego
Fuego is a command line client for the firestore database (https://firebase.google.com/docs/firestore).
Stars: ✭ 110 (-0.9%)
Mutual labels:  cli
Appstoreconnect Cli
An easy to use command-line tool for interacting with the Apple AppStore Connect API
Stars: ✭ 110 (-0.9%)
Mutual labels:  cli
Do Latency
🐳 Digital Ocean regions latency checker
Stars: ✭ 109 (-1.8%)
Mutual labels:  cli
Rasterio
Rasterio reads and writes geospatial raster datasets
Stars: ✭ 1,643 (+1380.18%)
Mutual labels:  cli
Novagram
An Object-Oriented PHP library for Telegram Bots
Stars: ✭ 112 (+0.9%)
Mutual labels:  cli
Nodejs Cli Apps Best Practices
The largest Node.js CLI Apps best practices list ✨
Stars: ✭ 2,144 (+1831.53%)
Mutual labels:  cli
Switch Php
Easily switch between PHP versions on your Mac. Requires Homebrew and works with Laravel Valet. 🔀
Stars: ✭ 110 (-0.9%)
Mutual labels:  cli
Scaffold Static
Scaffolding utility for vanilla-js
Stars: ✭ 111 (+0%)
Mutual labels:  cli
Py7zr
7zip in python3 with ZStandard, PPMd, LZMA2, LZMA1, Delta, BCJ, BZip2, and Deflate compressions, and AES encryption.
Stars: ✭ 110 (-0.9%)
Mutual labels:  cli
Hsweb Payment
基于hsweb的开源聚合支付系统,多商户,多渠道,多配置.
Stars: ✭ 112 (+0.9%)
Mutual labels:  maven
Mole
CLI application to create ssh tunnels focused on resiliency and user experience.
Stars: ✭ 1,520 (+1269.37%)
Mutual labels:  cli
Dotnet Transform Xdt
Modern .NET tools and library for XDT (Xml Document Transformation)
Stars: ✭ 110 (-0.9%)
Mutual labels:  cli
Ytfzf
A posix script to find and watch youtube videos from the terminal. (Without API)
Stars: ✭ 2,212 (+1892.79%)
Mutual labels:  cli
Reicons
💅 Bundle your SVG into a fully customized React components
Stars: ✭ 110 (-0.9%)
Mutual labels:  cli
Easywebpack Cli
A Powerful Cross-platform Webpack CLI Tool
Stars: ✭ 110 (-0.9%)
Mutual labels:  cli

Logo

License Apache 2.0 Maven central Java 1.8+ Maven 3.0+ Gradle 3.0+ Ant 1.8.2+ PayPal donation Yandex.Money donation

Changelog

7.0.4 (26-sep-2020)

  • fixed default flag state keep comments for start in CLI mode #24
  • fixed working directory detection in CLI mode

7.0.3 (13-sep-2020)

  • added way to get info about all input and produced files from preprocessor context
  • reworked Gradle plug-in, removed extension and now properties should be directly provided for task #21
  • refactoring, removed some auxiliary plugins from build process and extra code

Full changelog

Introduction

Since 2001 I was strongly involved in development for J2ME mobile devices, it was too expensive to support the same sources for different devices if to use standard Java OOP approach, so that I choosed C/C++ approach and developed preprocessor which made my life much easier. Inintially it was a proprietary project but since 2011 it became OSS project.

I guess, at present it is the most powerful Java preprocessor with support of two-pass preprocessing, document part support, loops and even use XML files as data sources (I generated static files with it). Now it is implemented as a fat-jar and includes Maven, ANT and Gradle interfaces and can be used with these tools. For work it needs JDK 1.8+.

Documap

Documap

How to use

The Preprocessor can work as:

The Preprocessor is published in the Maven Central (it is not published in Gradle central, so that use the Maven central)

    <build>
        <plugins>
...
           <plugin>
                <groupId>com.igormaznitsa</groupId>
                <artifactId>jcp</artifactId>
                <version>7.0.4</version>
                <executions>
                    <execution>
                        <id>preprocessSources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>preprocess</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
...
        </plugins>
    </build>    

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-7.0.4.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-7.0.4.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
  • --z turn on checking of file content before replacement, if the same content then preprocessor will not replace the file
  • --es allow whitespace between comment and directive (by default it is turned off)

Internal test examples

Example of Java sources with directives

In Java the only allowed way to inject directives and to not break work of tools and conpilers - is to use commented space, so that the preprocessor uses it.

//#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

In opposite a regular document, a Java document has as minimum two sections - prefix (where situated import and special information) and body. For access to such sections there are special preprocessing directives //#prefix[-|+], //#postfix[-|+]. They allow to turn on or turn off output into prefix and postfix sections.

//#prefix+
 import java.lang.*;
 //#prefix-
 public class Main {
  //#prefix+
  import java.util.*;
  //#prefix-
  public static void main(String ... args){}
 }

How to remove all coments from sources

Sometime it is very useful to remove totally all comments from sources, such possiblitiy was included into JCP and can be activated through special flag or command line switcher. The Example of use for comment removing through CLI interface

java -jar ./jcp-7.0.4.jar --i:/sourceFolder --o:/resultFolder -ef:none --r
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].