I have added a custom PMD rule using official documentation (http://pmd.sourceforge.net/pmd-5.1.0/howtowritearule.html)
Rule:
package com.comp.www.lty.awards.service.pmd;
import net.sourceforge.pmd.lang.ast.*;
import net.sourceforge.pmd.lang.java.ast.*;
import net.sourceforge.pmd.lang.java.rule.*;
public class WhileLoopsMustUseBracesRule extends AbstractJavaRule {
public Object visit(ASTWhileStatement node, Object data) {
Node firstStmt = node.jjtGetChild(1);
if (!hasBlockAsFirstChild(firstStmt)) {
addViolation(data, node);
}
return super.visit(node,data);
}
private boolean hasBlockAsFirstChild(Node node) {
return (node.jjtGetNumChildren() != 0 && (node.jjtGetChild(0) instanceof ASTBlock));
}
}
This is my ruleset xml file:
<?xml version="1.0"?>
<ruleset name="My custom rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>While loop desc</description>
<rule name="WhileLoopsMustUseBracesRule"
message="Avoid using 'while' statements without curly braces"
class="com.comp.www.lty.awards.service.pmd.WhileLoopsMustUseBracesRule">
<description>
Avoid using 'while' statements without using curly braces
</description>
<priority>3</priority>
<example>
<![CDATA[
public void doSomething() {
while (true)
x++;
}
]]>
</example>
</rule>
</ruleset>
I am using mvn to run these pmd rules. Works fine when I try to use existing rules from pmd jar, but whenever I try to use my above custom rule, I am getting ClassNotFoundException.
Stacktrace:
java.lang.ClassNotFoundException: com.comp.www.lty.awards.service.pmd.WhileLoopsMustUseBracesRule
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
at net.sourceforge.pmd.RuleSetFactory.parseSingleRuleNode(RuleSetFactory.java:377)
at net.sourceforge.pmd.RuleSetFactory.parseRuleNode(RuleSetFactory.java:291)
at net.sourceforge.pmd.RuleSetFactory.parseRuleSetNode(RuleSetFactory.java:242)
at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:176)
at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:171)
at net.sourceforge.pmd.RuleSetFactory.parseRuleSetReferenceNode(RuleSetFactory.java:331)
at net.sourceforge.pmd.RuleSetFactory.parseRuleNode(RuleSetFactory.java:289)
at net.sourceforge.pmd.RuleSetFactory.parseRuleSetNode(RuleSetFactory.java:242)
at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:176)
at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:171)
at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:135)
at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:119)
at net.sourceforge.pmd.RulesetsFactoryUtils.getRuleSets(RulesetsFactoryUtils.java:31)
at net.sourceforge.pmd.processor.AbstractPMDProcessor.createRuleSets(AbstractPMDProcessor.java:54)
at net.sourceforge.pmd.processor.MultiThreadProcessor.processFiles(MultiThreadProcessor.java:38)
at net.sourceforge.pmd.PMD.processFiles(PMD.java:352)
at org.apache.maven.plugin.pmd.PmdReport.executePmd(PmdReport.java:377)
at org.apache.maven.plugin.pmd.PmdReport.executePmdWithClassloader(PmdReport.java:280)
at org.apache.maven.plugin.pmd.PmdReport.canGenerateReport(PmdReport.java:254)
at org.apache.maven.reporting.AbstractMavenReport.execute(AbstractMavenReport.java:119)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:365)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:199)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Although not an ideal solution, but even I spent time to include this custom rule class file in the pmd jar (Custom Java PMD rule: Can't find the class CustomRule), but that didn't help either.
pom.xml:
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.springframework.boot
spring-boot-starter-parent
1.4.0.RELEASE
lty-awards-service
com.comp.www
war
lty-awards-service
Spring Boot Service Sample
1.0-SNAPSHOT
http://maven.apache.org
1.8
<findbugs-maven-plugin.version>3.0.3</findbugs-maven-plugin.version>
<findbugs.include.filter.location>buildtools/findbugs/include.xml</findbugs.include.filter.location>
<findbugs.exclude.filter.location>buildtools/findbugs/exclude.xml</findbugs.exclude.filter.location>
<maven-pmd-plugin.version>3.5</maven-pmd-plugin.version>
<pmd.version>5.3.2</pmd.version>
<pmdRule.version>5.1.0</pmdRule.version>
<pmd.ruleset.location>buildtools/pmd-rules/ltyawardsservicepmd.xml</pmd.ruleset.location>
<pmd.skip>false</pmd.skip>
<pmd.typeResolution>true</pmd.typeResolution>
<!-- spring boot -->
<debug.port>5000</debug.port>
<run.jvmArguments>-Dspring.profiles.active=dev -Dapplication.home=. -Dapplication.name=${project.name}
-Dapplication.environment=dev -Dproject.name=${project.name} -Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${debug.port}
</run.jvmArguments>
<error-inspector.version>0.1.9</error-inspector.version>
<platform-diagnostics.version>0.0.43</platform-diagnostics.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>${pmdRule.version}</version>
<scope>system</scope>
<systemPath>/Users/babu/.m2/repository/net/sourceforge/pmd/pmd/5.1.0/test.jar</systemPath>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.comp.prime.errorcatalog</groupId>
<artifactId>error-inspector</artifactId>
<version>${error-inspector.version}</version>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/error-inspect</outputDirectory>
<destFileName>inspect.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>com.comp.www.platform</groupId>
<artifactId>platform-diagnostics-main</artifactId>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/error-inspect/lib</outputDirectory>
<destFileName>platform-diagnostics-main.jar</destFileName>
</artifactItem>
</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<message>.*** ERROR: Detected Maven version ${maven.version}, We need Maven 3.0.3 or
higher ***.
</message>
<version>[3.0.3,)</version>
</requireMavenVersion>
<requireJavaVersion>
<message>.*** ERROR: Detected JDK version ${java.version}, We need JDK
${project.jdk.version} or higher ***.
</message>
<version>${project.jdk.version}</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
<execution>
<id>enforce-dont-exist</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireFilesDontExist>
<files>
<file>${project.basedir}/src/main/scala</file>
</files>
</requireFilesDontExist>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${project.jdk.version}</source>
<target>${project.jdk.version}</target>
<encoding>UTF-8</encoding>
</configuration>
<version>3.3</version>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin.version}</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaCompatVersion>${scala.major.minor.version}</scalaCompatVersion>
<jvmArgs>
<jvmArg>-Xms512m</jvmArg>
<jvmArg>-Xmx2048m</jvmArg>
</jvmArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${maven-pmd-plugin.version}</version>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>${pmd.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>${pmd.version}</version>
</dependency>
<dependency>
<groupId>WhileLoopsMustUseBracesRule</groupId>
<artifactId>pmd.ruleset</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>/Users/babu/Downloads/cache.jar</systemPath>
</dependency>
<dependency>
<groupId>com.comp.www.platform</groupId>
<artifactId>platform-build-tools</artifactId>
<version>${platform-build-tools.version}</version>
</dependency>
</dependencies>
<configuration>
<targetJdk>${project.jdk.version}</targetJdk>
<includeTests>true</includeTests>
<skip>${pmd.skip}</skip>
<sourceEncoding>${project.sourceEncoding}</sourceEncoding>
<rulesets>
<ruleset>${pmd.ruleset.location}</ruleset>
</rulesets>
</configuration>
<executions>
<execution>
<id>cpd-report</id>
<phase>test-compile</phase>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
<goal>pmd</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!--<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>-->
Here test.jar is my jar bundled (i.e. pmd jar unbundled, added class file & ruleset and again bundled it as test.jar). Although this is not how I want to use the rule. But if there is a better way to use pmd jar as it is & add a mvn dependency for new rule that is the ideal solution I'm looking for. Thanks!
You need to add your custom rule jar to the classpath when PMD runs. You should bundle your custom PMD rule in its own Maven dependency, then you can include it in the PMD plugin classpath by adding a dependency to your plugin configuration like so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.7</version>
<dependencies>
<dependency>
<groupId>com.foo.bar</groupId>
<artifactId>my-custom-pmd-rule</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
...
</plugin>
See this page for more information about plugin classloading. See how it says:
Please note that the plugin classloader does neither contain the dependencies of the current project nor its build output
Try changing your pom.xml file to the following. Notice I moved your test.jar dependency to the plugin dependencies so that it'll be loaded on the plugin's classpath. Note that you don't have to bundle your rules with PMD. You just need to package your rules in its own jar and include it in the plugin dependencies section.
<findbugs-maven-plugin.version>3.0.3</findbugs-maven-plugin.version>
<findbugs.include.filter.location>buildtools/findbugs/include.xml</findbugs.include.filter.location>
<findbugs.exclude.filter.location>buildtools/findbugs/exclude.xml</findbugs.exclude.filter.location>
<maven-pmd-plugin.version>3.5</maven-pmd-plugin.version>
<pmd.version>5.3.2</pmd.version>
<pmdRule.version>5.1.0</pmdRule.version>
<pmd.ruleset.location>buildtools/pmd-rules/ltyawardsservicepmd.xml</pmd.ruleset.location>
<pmd.skip>false</pmd.skip>
<pmd.typeResolution>true</pmd.typeResolution>
<!-- spring boot -->
<debug.port>5000</debug.port>
<run.jvmArguments>-Dspring.profiles.active=dev -Dapplication.home=. -Dapplication.name=${project.name}
-Dapplication.environment=dev -Dproject.name=${project.name} -Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${debug.port}
</run.jvmArguments>
<error-inspector.version>0.1.9</error-inspector.version>
<platform-diagnostics.version>0.0.43</platform-diagnostics.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.comp.prime.errorcatalog</groupId>
<artifactId>error-inspector</artifactId>
<version>${error-inspector.version}</version>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/error-inspect</outputDirectory>
<destFileName>inspect.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>com.comp.www.platform</groupId>
<artifactId>platform-diagnostics-main</artifactId>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/error-inspect/lib</outputDirectory>
<destFileName>platform-diagnostics-main.jar</destFileName>
</artifactItem>
</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<message>.*** ERROR: Detected Maven version ${maven.version}, We need Maven 3.0.3 or
higher ***.
</message>
<version>[3.0.3,)</version>
</requireMavenVersion>
<requireJavaVersion>
<message>.*** ERROR: Detected JDK version ${java.version}, We need JDK
${project.jdk.version} or higher ***.
</message>
<version>${project.jdk.version}</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
<execution>
<id>enforce-dont-exist</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireFilesDontExist>
<files>
<file>${project.basedir}/src/main/scala</file>
</files>
</requireFilesDontExist>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${project.jdk.version}</source>
<target>${project.jdk.version}</target>
<encoding>UTF-8</encoding>
</configuration>
<version>3.3</version>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin.version}</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaCompatVersion>${scala.major.minor.version}</scalaCompatVersion>
<jvmArgs>
<jvmArg>-Xms512m</jvmArg>
<jvmArg>-Xmx2048m</jvmArg>
</jvmArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${maven-pmd-plugin.version}</version>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>${pmd.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>${pmd.version}</version>
</dependency>
<dependency>
<groupId>WhileLoopsMustUseBracesRule</groupId>
<artifactId>pmd.ruleset</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope><systemPath>/Users/babu/Downloads/cache.jar</systemPath>
</dependency>
<dependency>
<groupId>com.comp.www.platform</groupId>
<artifactId>platform-build-tools</artifactId>
<version>${platform-build-tools.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>${pmdRule.version}</version>
<scope>system</scope>
<systemPath>/Users/babu/.m2/repository/net/sourceforge/pmd/pmd/5.1.0/test.jar</systemPath>
</dependency>
</dependencies>
<configuration>
<targetJdk>${project.jdk.version}</targetJdk>
<includeTests>true</includeTests>
<skip>${pmd.skip}</skip>
<sourceEncoding>${project.sourceEncoding}</sourceEncoding>
<rulesets>
<ruleset>${pmd.ruleset.location}</ruleset>
</rulesets>
</configuration>
<executions>
<execution>
<id>cpd-report</id>
<phase>test-compile</phase>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
<goal>pmd</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!--<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>-->
Related
I am trying to reference a Java class from a Kotlin file, but the problem is that I cannot reference the package containing the Java sources.
What I am trying:
fun main.dmla.java.parser.DMLAParser.parseDmla(source: Source): Any {
val lexer = DMLALexer(CharStreams.fromString(source.characters.toString()))
val parser = DMLAParser(CommonTokenStream(lexer))
val walker = DmlaWalker()
return walker.visit(parser.model())
}
I cannot reference the main.dmla.java package for some reason, therefore I cannot reach the DMLAParser class.
The Maven pom.xml looks like this:
<parent>
<groupId>DMLAGraalVM</groupId>
<artifactId>DMLA-parent</artifactId>
<version>0.0.1</version>
</parent>
<artifactId>language</artifactId>
<properties>
<java.version>1.8</java.version>
<kotlin.version>1.3.21</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-dsl-processor</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-tck</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/dmla/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/dmla/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>dmla</finalName>
<artifactSet>
<excludes>
<exclude>org.graalvm.truffle:truffle-api</exclude>
<exclude>org.graalvm.truffle:truffle-dsl-processor</exclude>
<exclude>org.graalvm.truffle:truffle-tck</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
What am I doing wrong?
I am having an issue migrating from Adobe Flex 3.3.0.4852 to 4.5.1.21328
Applying the same configuration I had it set up it throws a exception executing flexmojos-maven-plugin
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>3.2.0</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>compile-swf</goal>
</goals>
</execution>
</executions>
<configuration>
<moduleFiles>
<module>APP_MIGRATED.mxml</module>
</moduleFiles>
<locales>
<param>en_US</param>
</locales>
<services>${basedir}/src/main/resources/services-config.xml</services>
<contextRoot>root</contextRoot>
<keepAllTypeSelectors>true</keepAllTypeSelectors>
<output>${basedir}/target/APP_MIGRATED.swf</output>
<targetPlayer>9.0.0</targetPlayer>
</configuration>
</plugin>
The error is triying to compile the source it trows the next error:
[ERROR]
C:\m2_repo_clean\com\adobe\flex\framework\advancedgrids\4.5.1.21328\advancedgrids-4.5.1.21328.swc$defaults.css:[13,-1]
{ expected. [ERROR]
C:\m2_repo_clean\com\adobe\flex\framework\charts\4.5.1.21328\charts-4.5.1.21328.swc$defaults.css:[13,-1]
{ expected. [ERROR]
C:\m2_repo_clean\com\adobe\flex\framework\charts\4.5.1.21328\charts-4.5.1.21328.swc$defaults.css:[14,-1]
{ expected. [ERROR]
C:\m2_repo_clean\com\adobe\flex\framework\charts\4.5.1.21328\charts-4.5.1.21328.swc$defaults.css:[108,-1]
Unexpected character: D. [ERROR]
C:\m2_repo_clean\com\adobe\flex\framework\charts\4.5.1.21328\charts-4.5.1.21328.swc$defaults.css:[112,-1]
{ expected. [ERROR]
C:\m2_repo_clean\com\adobe\flex\framework\framework\4.5.1.21328\framework-4.5.1.21328.swc$defaults.css:[15,-1]
{ expected. [ERROR]
C:\m2_repo_clean\com\adobe\flex\framework\mx\4.5.1.21328\mx-4.5.1.21328.swc$defaults.css:[15,-1]
{ expected. [ERROR]
C:\m2_repo_clean\com\adobe\flex\framework\spark\4.5.1.21328\spark-4.5.1.21328.swc$defaults.css:[15,-1]
{ expected. [WARNING]
C:\Workspaces\aa_Branches\aa_jdk8_upgrade\flex\src\main\flexapp\APP_MIGRATED.mxml:[0,-1]
CSS selector condition type is not supported: ':normalWithPrompt'
[WARNING]
C:\Workspaces\aa_Branches\aa_jdk8_upgrade\flex\src\main\flexapp\APP_MIGRATED.mxml:[0,-1]
CSS selector condition type is not supported: ':disabledWithPrompt'
This is my full pom configuration
<parent>
<artifactId>app-migrated</artifactId>
<groupId>com.appmigrated</groupId>
<version>1.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>flex</artifactId>
<packaging>pom</packaging>
<name>Flex</name>
<build>
<finalName>APP_MIGRATED</finalName>
<sourceDirectory>src/main/flexapp</sourceDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>${basedir}/target/generated-resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>${flex-mojos.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>compile-swf</goal>
</goals>
</execution>
</executions>
<configuration>
<moduleFiles>
<module>APP_MIGRATED.mxml</module>
</moduleFiles>
<locales>
<param>en_US</param>
</locales>
<services>${basedir}/src/main/resources/services-config.xml</services>
<contextRoot>root</contextRoot>
<keepAllTypeSelectors>true</keepAllTypeSelectors>
<output>${basedir}/target/APP_MIGRATED.swf</output>
<targetPlayer>9.0.0</targetPlayer>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>wrapper</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<ignoreVersionIssues>true</ignoreVersionIssues>
<htmlName>APP_MIGRATED</htmlName>
<outputDirectory>${project.build.directory}/html-wrapper</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-config</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<outputDirectory>${project.build.directory}/generated-resources</outputDirectory>
<includeArtifacIds>APP_MIGRATED</includeArtifacIds>
<includeGroupIds>${project.groupId}</includeGroupIds>
<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make.html-bundle</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>src/main/assembly/html-bundle.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make.resources</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>src/main/assembly/resources.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<flex.sdk.version>4.5.1.21328</flex.sdk.version>
<flex-mojos.version>4.0-RC2</flex-mojos.version>
</properties>
<dependencies>
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>flex-framework</artifactId>
<version>${flex.sdk.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.adobe.cairngorm</groupId>
<artifactId>cairngorm</artifactId>
<version>2.2.1</version>
<type>swc</type>
</dependency>
</dependencies>
I know maybe there is can be another errors after this one, but this is the one which concerns me more.
Greetings,
try flexmojos 7 :
<properties>
<flexmojos.version>7.0.1</flexmojos.version>
<flex.version>4.13.0.20140701</flex.version>
<flash.version>16.0</flash.version>
</properties>
plugin look like this
<plugins>
<plugin>
<groupId>net.flexmojos.oss</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>${flexmojos.version}</version>
<extensions>true</extensions>
<configuration>
<sourceFile>APP_MIGRATED.mxml</sourceFile>
<compilerWarnings>
<warn-no-constructor>false</warn-no-constructor>
</compilerWarnings>
</configuration>
<dependencies>
<!-- This handles a bug in maven which causes problems with flex resources -->
<dependency>
<groupId>net.flexmojos.oss</groupId>
<artifactId>flexmojos-threadlocaltoolkit-wrapper</artifactId>
<version>${flexmojos.version}</version>
</dependency>
<!-- Without this FM will use the compiler configured in its master
pom, which will result in version conflicts -->
<dependency>
<groupId>org.apache.flex</groupId>
<artifactId>compiler</artifactId>
<version>${flex.version}</version>
<type>pom</type>
</dependency>
</dependencies>
</plugin>
I am using AspectJ (not Spring) to implement AOP in my Java Web application. It works fine when built by Maven project in Eclipse.
But putting and deploying the war package on the remote server, the AOP won't execute.
here's part of pom.xml:
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.9</version>
<!--<properties>
<war.bundle>true</war.bundle>
</properties>
-->
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.8.9</version>
<!--<properties>
<war.bundle>true</war.bundle>
</properties>
-->
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.8</version>
<!--<properties>
<war.bundle>true</war.bundle>
</properties>
-->
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<privateScope>true</privateScope>
<showWeaveInfo>true</showWeaveInfo>
<source>1.7</source>
<target>1.7</target>
<complianceLevel>1.7</complianceLevel>
<!-- <encoding>UTF-8</encoding> -->
<verbose>false</verbose>
<outxml>true</outxml>
<aspectLibraries>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>${project.basedir}/src/main/webapp/WEB-INF/lib</directory>
</fileset>
<fileset>
<directory>${project.basedir}/../deploy</directory>
<includes>
<include>${project.artifactId}.war</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-installed</id>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>${project.packaging}</type>
<destFileName>rm-cloud-web.war</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.basedir}/../deploy</outputDirectory>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
<execution>
<id>unpack-dependencies</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/test-classes</outputDirectory>
<overWriteReleases>true</overWriteReleases>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Any advice?
Sorry guys, AspectJ did work on the server side and it does NOT need to add any extra jar file. I tried to log some info in an aspect method by using a enum that been advised, means the advise will be called recursively that caused stackoverflowexception.
Now I cant exclude Enum whthin the curtain class:
LogLevel is a enum in the class: xxx.xx.Utility
The compile info:
[INFO] Join point 'method-execution(int[] xxx.xx.Utility.$SWITCH_TABLE$xxx$xx$Utility$LogLevel())' in Type 'xxx.xx.Utility' (Utility.java:49) advised by before advice from 'zzz.zz.AAAA' (AAAA.aj:5)
my aspect content:
pointcut pc() : (execution(* xxx.xx..(..)) && !within(is(EnumType)));
before() : pc() {
...
}
No matter how much I do mvn clean install even with -U this dependency (along with some other) is not being coped into the target\app-1.0-SNAPSHOT\WEB-INF\lib folder:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-webmvc</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
Not sure why this happens now, when in the pom.xml there is the <packaging>war</packaging>
build
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.version}</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- Copies static web files from src/main/webapp to target/${webappDirectory} -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<!-- the exploded goal gets executed during compile phase -->
<phase>compile</phase>
<goals>
<goal>exploded</goal>
<goal>war</goal>
</goals>
</execution>
</executions>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>${project.artifactId}</warName>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
</plugins>
</build>
i get this error while using jetty:run plugin on a ZK web project , i am using a zk archetype version 7.0.0.
[ERROR] failed org.mortbay.jetty.plugin.Jetty6PluginWebAppContext#a925d{/InTouchF,G:\workspace\InTouchF\src\main\webapp}
java.lang.NoClassDefFoundError
at org.mortbay.jetty.plus.webapp.EnvConfiguration.class$(EnvConfiguration.java:163)
this is my jetty configuration :
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
<configuration>
<scanIntervalSeconds>5</scanIntervalSeconds>
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
Try adding this to your dependencies :
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-plus</artifactId>
<version>6.1.10</version>
</dependency>
i resolved the problem by using the version 7.0.0pre2 of jetty-maven-plugin and jsp-2.1 as follow :
<properties>
<jetty.version>7.0.0pre2</jetty.version>
</properties>
<dependencies>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
<version>${jetty.version}</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>${jetty.version}</version>
........