raydac / java-comment-preprocessor

preprocessor for computer languages with C-like comment format (C/C++/Java/Go)
Apache License 2.0
172 stars 27 forks source link

Maven problem #18

Closed TihomirBorcic closed 6 years ago

TihomirBorcic commented 6 years ago

Hi, i find this tool very useful, but cannot make it to run with Maven, when i put your sample code in my pom file im getting the following error "Plugin execution not covered by lifecycle configuration: com.igormaznitsa:jcp:6.1.2:preprocess (execution: preprocessSources, phase: generate-sources)" if i put this code in "pluginManagement" part of pom it gives no errors, but im not getting expected results. What maven goal should i run to get it compiled with this tool? I assumed it will run with standard install goals ? Maybe im using this wrong ?

raydac commented 6 years ago

could you provide your pom.xml?

TihomirBorcic commented 6 years ago

sure, here it is

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany</groupId>
  <artifactId>Preprocesor</artifactId>
  <version>1.0</version>
  <name>Preprocesor-Test</name>

  <build>
    <sourceDirectory>src</sourceDirectory>

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.7</version>
            </plugin>

        </plugins>
    </pluginManagement>

    <plugins>

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>        
      </plugin>

      <plugin>
                <groupId>com.igormaznitsa</groupId>
                <artifactId>jcp</artifactId>
                <version>6.1.2</version>
                <executions>
                    <execution>
                        <id>preprocessSources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>preprocess</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>clearGeneratedFolders</id>
                        <goals>
                            <goal>clear</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

    </plugins>

    <extensions>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-ftp</artifactId>
            <version>2.6</version>
        </extension>
    </extensions>
  </build>

  <dependencies>

    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans</artifactId>
        <version>2.5.0</version>
    </dependency>

    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.2.11</version>
    </dependency>
    <dependency>
        <groupId>org.samba.jcifs</groupId>
        <artifactId>jcifs</artifactId>
        <version>1.3.3</version>
    </dependency>

  </dependencies>

</project>
raydac commented 6 years ago

and why you don't have <packaging> tag for project in your pom?

TihomirBorcic commented 6 years ago

Im using it in Eclipse, i see its jar, in another tab, i think its default, no need for it. I managed to run jcp:preprocess goal when i put this code in "pluginManagement" part of pom. Im getting *.java files in target\generated-sources\preprocessed\ directory now, but not sure how to integrate this in for example maven deploy goal so i have it compiled in my .jar. Sorry if im taking your time, if you are busy, you dont need to take care of this. Thanks

public class Test {

    //JCP! local TESTVAR="TEST LOCAL VARIABLE"
        //JCP! echo TESTVAR=/*$TESTVAR$*/

    public static void main(String[] args) {
        // TODO Auto-generated method stub
         System.out.println(TEST LOCAL VARIABLE);
         System.out.println("// Hello commentaries");
         //JCP! local counter=10
                //JCP! while counter!=0
                System.out.println("Number 10");
                //JCP! local counter=counter-1
                //JCP! end
                //JCP! while counter!=0
                System.out.println("Number 9");
                //JCP! local counter=counter-1
                //JCP! end
                //JCP! while counter!=0
                System.out.println("Number 8");
                //JCP! local counter=counter-1
                //JCP! end
                //JCP! while counter!=0
                System.out.println("Number 7");
                //JCP! local counter=counter-1
                //JCP! end
                //JCP! while counter!=0
                System.out.println("Number 6");
                //JCP! local counter=counter-1
                //JCP! end
                //JCP! while counter!=0
                System.out.println("Number 5");
                //JCP! local counter=counter-1
                //JCP! end
                //JCP! while counter!=0
                System.out.println("Number 4");
                //JCP! local counter=counter-1
                //JCP! end
                //JCP! while counter!=0
                System.out.println("Number 3");
                //JCP! local counter=counter-1
                //JCP! end
                //JCP! while counter!=0
                System.out.println("Number 2");
                //JCP! local counter=counter-1
                //JCP! end
                //JCP! while counter!=0
                System.out.println("Number 1");
                //JCP! local counter=counter-1
                //JCP! end
                //JCP! while counter!=0
//JCP>              System.out.println("Number /*$counter$*/");
                //JCP! local counter=counter-1
                //JCP! end

         //JCP! if issubstr("Hello","Hello")
         System.out.println("Substring found");
         //JCP! endif

    }

}
TihomirBorcic commented 6 years ago

Hm, if i understood this correctly i must make it work with your plugin in build/plugin part of pom so it executes before process-resources lifecycle phase, but dont know whats wrong as it is now.

TihomirBorcic commented 6 years ago

I found the solution for Eclipse: Window > Preferences > Maven > Errors/Warnings > Plugin execution not covered by lifecycle configuration. Select Ignore. Works like a charm ;) Thanks for your time and this tool.

raydac commented 6 years ago

cool! thank you very much for info! I am not an eclipse user so that any info about eclipse specific usage of my preprocessor is very valued