Author: adangel Date: Sat Apr 29 19:15:09 2017 New Revision: 1793232 URL: http://svn.apache.org/viewvc?rev=1793232&view=rev Log: [MPMD-234] Support incremental analysis cache
Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/pom.xml maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/src/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/src/main/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/src/main/java/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/src/main/java/com/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/src/main/java/com/mycompany/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/src/main/java/com/mycompany/app/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/src/main/java/com/mycompany/app/Hello.java maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/pom.xml maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/src/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/src/main/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/src/main/java/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/src/main/java/com/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/src/main/java/com/mycompany/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/src/main/java/com/mycompany/app/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/src/main/java/com/mycompany/app/Hello.java maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/invoker.properties maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/pom.xml maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/src/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/src/main/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/src/main/java/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/src/main/java/com/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/src/main/java/com/mycompany/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/src/main/java/com/mycompany/app/ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/src/main/java/com/mycompany/app/Hello.java maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/pom.xml maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/verify.groovy maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/pom.xml?rev=1793232&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/pom.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/pom.xml Sat Apr 29 19:15:09 2017 @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<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>org.apache.maven.plugin.pmd.its.MPMD-234-analysis-cache</groupId> + <artifactId>custom-analysis-cache</artifactId> + <version>1.0-SNAPSHOT</version> + + <description> + Verify that an analysis cache file is produced at a custom location. + </description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <analysisCache>true</analysisCache> + <analysisCacheLocation>${project.build.directory}/custom-analysis-pmd.cache</analysisCacheLocation> + </configuration> + </plugin> + </plugins> + </build> +</project> Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/src/main/java/com/mycompany/app/Hello.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/src/main/java/com/mycompany/app/Hello.java?rev=1793232&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/src/main/java/com/mycompany/app/Hello.java (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/custom-analysis-cache/src/main/java/com/mycompany/app/Hello.java Sat Apr 29 19:15:09 2017 @@ -0,0 +1,28 @@ +package com.mycompany.app; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class Hello +{ + public static void main( String[] args ) + { + System.out.println( args[0] ); + } +} Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/pom.xml?rev=1793232&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/pom.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/pom.xml Sat Apr 29 19:15:09 2017 @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<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>org.apache.maven.plugin.pmd.its.MPMD-234-analysis-cache</groupId> + <artifactId>default-analysis-cache</artifactId> + <version>1.0-SNAPSHOT</version> + + <description> + Verify that an analysis cache file is produced at the default location. + </description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <analysisCache>true</analysisCache> + </configuration> + </plugin> + </plugins> + </build> +</project> Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/src/main/java/com/mycompany/app/Hello.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/src/main/java/com/mycompany/app/Hello.java?rev=1793232&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/src/main/java/com/mycompany/app/Hello.java (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/default-analysis-cache/src/main/java/com/mycompany/app/Hello.java Sat Apr 29 19:15:09 2017 @@ -0,0 +1,28 @@ +package com.mycompany.app; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class Hello +{ + public static void main( String[] args ) + { + System.out.println( args[0] ); + } +} Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/invoker.properties?rev=1793232&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/invoker.properties (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/invoker.properties Sat Apr 29 19:15:09 2017 @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.goals = clean verify pmd:pmd Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/pom.xml?rev=1793232&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/pom.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/pom.xml Sat Apr 29 19:15:09 2017 @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<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>org.apache.maven.plugin.pmd.its.MPMD-234-analysis-cache</groupId> + <artifactId>no-analysis-cache</artifactId> + <version>1.0-SNAPSHOT</version> + + <description> + Verify that no analysis cache file is produced. + </description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + <version>@project.version@</version> + </plugin> + </plugins> + </build> +</project> Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/src/main/java/com/mycompany/app/Hello.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/src/main/java/com/mycompany/app/Hello.java?rev=1793232&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/src/main/java/com/mycompany/app/Hello.java (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/no-analysis-cache/src/main/java/com/mycompany/app/Hello.java Sat Apr 29 19:15:09 2017 @@ -0,0 +1,28 @@ +package com.mycompany.app; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class Hello +{ + public static void main( String[] args ) + { + System.out.println( args[0] ); + } +} Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/pom.xml?rev=1793232&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/pom.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/pom.xml Sat Apr 29 19:15:09 2017 @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<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>org.apache.maven.plugin.pmd.its</groupId> + <artifactId>MPMD-234-analysis-cache</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <description> + Verify various analysis cache configurations. + </description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <modules> + <module>no-analysis-cache</module> + <module>default-analysis-cache</module> + <module>custom-analysis-cache</module> + </modules> +</project> Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/verify.groovy?rev=1793232&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/verify.groovy (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-234-analysis-cache/verify.groovy Sat Apr 29 19:15:09 2017 @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +File cacheFile = new File( basedir, 'no-analysis-cache/target/pmd/pmd.cache' ) +assert !cacheFile.exists() + +File defaultAnalysisCacheLocation = new File( basedir, 'default-analysis-cache/target/pmd/pmd.cache' ) +assert defaultAnalysisCacheLocation.exists() + +File customCacheLocation = new File( basedir, 'custom-analysis-cache/target/custom-analysis-pmd.cache' ) +assert customCacheLocation.exists() Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java?rev=1793232&r1=1793231&r2=1793232&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java Sat Apr 29 19:15:09 2017 @@ -182,6 +182,29 @@ public class PmdReport private boolean skipPmdError; /** + * Enables the analysis cache, which speeds up PMD. This + * requires a cache file, that contains the results of the last + * PMD run. Thus the cache is only effective, if this file is + * not cleaned between runs. + * + * @since 3.8 + */ + @Parameter( property = "pmd.analysisCache", defaultValue = "false" ) + private boolean analysisCache; + + /** + * The location of the analysis cache, if it is enabled. + * This file contains the results of the last PMD run and must not be cleaned + * between consecutive PMD runs. Otherwise the cache is not in use. + * If the file doesn't exist, PMD executes as if there is no cache enabled and + * all files are analyzed. Otherwise only changed files will be analyzed again. + * + * @since 3.8 + */ + @Parameter( property = "pmd.analysisCacheLocation", defaultValue = "${project.build.directory}/pmd/pmd.cache" ) + private String analysisCacheLocation; + + /** * {@inheritDoc} */ public String getName( Locale locale ) @@ -623,6 +646,12 @@ public class PmdReport configuration.setBenchmark( benchmark ); + if ( analysisCache ) + { + configuration.setAnalysisCacheLocation( analysisCacheLocation ); + getLog().debug( "Using analysis cache location: " + analysisCacheLocation ); + } + return configuration; } Modified: maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java?rev=1793232&r1=1793231&r2=1793232&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java Sat Apr 29 19:15:09 2017 @@ -91,6 +91,24 @@ public class PmdReportTest assertTrue( str.contains( "/xref/def/configuration/AppSample.html#L45" ) ); } + public void testDefaultConfigurationWithAnalysisCache() + throws Exception + { + FileUtils.copyDirectoryStructure( new File( getBasedir(), + "src/test/resources/unit/default-configuration/jxr-files" ), + new File( getBasedir(), "target/test/unit/pmd-with-analysis-cache-plugin-config/target/site" ) ); + + File testPom = + new File( getBasedir(), + "src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml" ); + PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom ); + mojo.execute(); + + // check if the PMD analysis cache file has been generated + File cacheFile = new File( getBasedir(), "target/test/unit/pmd-with-analysis-cache-plugin-config/target/pmd/pmd.cache" ); + assertTrue( FileUtils.fileExists( cacheFile.getAbsolutePath() ) ); + } + public void testJavascriptConfiguration() throws Exception { Added: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml?rev=1793232&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/default-configuration/pmd-with-analysis-cache-plugin-config.xml Sat Apr 29 19:15:09 2017 @@ -0,0 +1,68 @@ +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>def.configuration</groupId> + <artifactId>pmd-with-analysis-cache</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <inceptionYear>2017</inceptionYear> + <name>Maven PMD Plugin Default Configuration Test</name> + <url>http://maven.apache.org</url> + <build> + <finalName>pmd-with-analysis-cache-plugin-config</finalName> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + <configuration> + <project implementation="org.apache.maven.plugin.pmd.stubs.DefaultConfigurationMavenProjectStub"/> + <outputDirectory>${basedir}/target/test/unit/pmd-with-analysis-cache-plugin-config/target/site</outputDirectory> + <targetDirectory>${basedir}/target/test/unit/pmd-with-analysis-cache-plugin-config/target</targetDirectory> + <format>xml</format> + <linkXRef>true</linkXRef> + <xrefLocation>${basedir}/target/test/unit/pmd-with-analysis-cache-plugin-config/target/site/xref</xrefLocation> + <sourceEncoding>UTF-8</sourceEncoding> + <analysisCache>true</analysisCache> + <analysisCacheLocation>${basedir}/target/test/unit/pmd-with-analysis-cache-plugin-config/target/pmd/pmd.cache</analysisCacheLocation> + + <compileSourceRoots> + <compileSourceRoot>${basedir}/src/test/resources/unit/default-configuration/</compileSourceRoot> + </compileSourceRoots> + </configuration> + <dependencies> + <dependency> + <groupId>pmd</groupId> + <artifactId>pmd</artifactId> + <version>3.8</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </build> + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + </plugin> + </plugins> + </reporting> +</project>