Project: clover
Issue CLOV-1682: Repository pollution protection reports a custom classifier under Maven 2.2.x
*Problem:* Probably bug in Maven, needs further investigation. Running "clean clover2:instrument" on a simple project (no additional plugins) with repository pollution protection enabled causes a build failure. {noformat} maven-clover2-plugin-hg\src\it\pollutionProtection>mvn clean clover2:instrument -Dmaven.clover.repositoryPollutionProtection=true [INFO] Scanning for projects... [INFO] snapshot com.atlassian.maven.plugins:maven-clover2-plugin:4.0.4-SNAPSHOT: checking for updates from atlassian-internal [INFO] ------------------------------------------------------------------------ [INFO] Building Unnamed - com.atlassian.maven.plugins.sample:clover-pollution-protection:jar:1.0-SNAPSHOT [INFO] task-segment: [clean, clover2:instrument] [INFO] ------------------------------------------------------------------------ [INFO] [clean:clean {execution: default-clean}] [INFO] Deleting directory f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target [INFO] Preparing clover2:instrument [INFO] snapshot com.atlassian.clover:clover:4.0.4-SNAPSHOT: checking for updates from atlassian-internal [INFO] [clover2:instrumentInternal {execution: default-instrumentInternal}] [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Clover's repository pollution protection is enabled. Your build produces an artifact (com.atlassian.maven.plugins.sample:clover-pollution-protection:jar:tests:1.0-SNAPSHOT) with a custom classi fier. As Maven does not support multiple classifiers for an artifact, appending second 'clover' classifier may not be handled correctly. You can: - remove a custom classifier or - configure Clover to not append the '-clover' classifier to fix it. You can also disable pollution protection (-Dmaven.clover.repositoryPollutionProtection=false) if you know that it doesn't affect your build. {noformat} Adding extra logging showed that it fails because a custom 'tests' classifier is used during a build - see XXXXXXXXXX below. {noformat} maven-clover2-plugin-hg\src\it\pollutionProtection>mvn clean clover2:instrument [INFO] Scanning for projects... [INFO] snapshot com.atlassian.maven.plugins:maven-clover2-plugin:4.0.4-SNAPSHOT: checking for updates from atlassian-internal [INFO] ------------------------------------------------------------------------ [INFO] Building Unnamed - com.atlassian.maven.plugins.sample:clover-pollution-protection:jar:1.0-SNAPSHOT [INFO] task-segment: [clean, clover2:instrument] [INFO] ------------------------------------------------------------------------ [INFO] [clean:clean {execution: default-clean}] [INFO] Preparing clover2:instrument [INFO] snapshot com.atlassian.clover:clover:4.0.4-SNAPSHOT: checking for updates from atlassian-internal [INFO] [clover2:instrumentInternal {execution: default-instrumentInternal}] [INFO] XXXXXXXXXX CLASSIFIER= com.atlassian.maven.plugins.sample:clover-pollution-protection:jar:tests:1.0-SNAPSHOT [INFO] Clover Version 4.0.4, built on April 15 2015 (build-dev) [INFO] Loaded from: d:\Data\.m2\repository\com\atlassian\clover\clover\4.0.4-SNAPSHOT\clover-4.0.4-SNAPSHOT.jar [INFO] Clover: Developer License registered to Atlassian. [INFO] Creating new database at 'f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\clover\clover.db'. [INFO] Processing files at 1.8 source level. [INFO] Clover all over. Instrumented 1 file (1 package). [INFO] Elapsed time = 0,077 secs. (12,987 files/sec, 64,935 srclines/sec) [INFO] Clover Version 4.0.4, built on April 15 2015 (build-dev) [INFO] Loaded from: d:\Data\.m2\repository\com\atlassian\clover\clover\4.0.4-SNAPSHOT\clover-4.0.4-SNAPSHOT.jar [INFO] Clover: Developer License registered to Atlassian. [INFO] Updating existing database at 'f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\clover\clover.db'. [INFO] Processing files at 1.8 source level. [INFO] Clover all over. Instrumented 1 file (1 package). [INFO] 1 test method detected. [INFO] Elapsed time = 0,016 secs. (62,5 files/sec, 562,5 srclines/sec) [INFO] [resources:resources {execution: default-resources}] [WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\src\main\resources [INFO] Copying 1 resource [INFO] [compiler:compile {execution: default-compile}] [INFO] Compiling 1 source file to f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\clover\classes [INFO] [resources:testResources {execution: default-testResources}] [WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\src\test\resources [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] Compiling 1 source file to f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\clover\test-classes [INFO] [surefire:test {execution: default-test}] [INFO] Surefire report directory: f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\clover\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running ATest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.168 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [jar:jar {execution: default-jar}] [INFO] Building jar: f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\clover\clover-pollution-protection-1.0-SNAPSHOT-clover.jar [INFO] [install:install {execution: default-install}] [INFO] Installing f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\clover\clover-pollution-protection-1.0-SNAPSHOT-clover.jar to d:\Data\.m2\repository\com\atlassian\maven\plugins\sam ple\clover-pollution-protection\1.0-SNAPSHOT\clover-pollution-protection-1.0-SNAPSHOT-clover.jar [INFO] [clover2:instrument {execution: default-cli}] [INFO] XXXXXXXXXX CLASSIFIER= com.atlassian.maven.plugins.sample:clover-pollution-protection:jar:1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ {noformat} What's interesting, running the same test but with clover2:setup not only does not fails a build (because repository pollution protection does not fail due to custom classifier if no 'clover' is used), but the artifact produced does NOT have the 'tests' classifier: {noformat} maven-clover2-plugin-hg\src\it\pollutionProtection>mvn clean clover2:setup verify [INFO] Scanning for projects... [INFO] snapshot com.atlassian.maven.plugins:maven-clover2-plugin:4.0.4-SNAPSHOT: checking for updates from atlassian-internal [INFO] ------------------------------------------------------------------------ [INFO] Building Unnamed - com.atlassian.maven.plugins.sample:clover-pollution-protection:jar:1.0-SNAPSHOT [INFO] task-segment: [clean, clover2:setup, verify] [INFO] ------------------------------------------------------------------------ [INFO] [clean:clean {execution: default-clean}] [INFO] Deleting directory f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target [INFO] snapshot com.atlassian.clover:clover:4.0.4-SNAPSHOT: checking for updates from atlassian-internal [INFO] [clover2:setup {execution: default-cli}] [INFO] XXXXXXXXXX CLASSIFIER= com.atlassian.maven.plugins.sample:clover-pollution-protection:jar:1.0-SNAPSHOT [INFO] Clover Version 4.0.4, built on April 15 2015 (build-dev) [INFO] Loaded from: d:\Data\.m2\repository\com\atlassian\clover\clover\4.0.4-SNAPSHOT\clover-4.0.4-SNAPSHOT.jar [INFO] Clover: Developer License registered to Atlassian. [INFO] Creating new database at 'f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\clover\clover.db'. [INFO] Processing files at 1.8 source level. [INFO] Clover all over. Instrumented 1 file (1 package). [INFO] Elapsed time = 0,057 secs. (17,544 files/sec, 87,719 srclines/sec) [INFO] Clover Version 4.0.4, built on April 15 2015 (build-dev) [INFO] Loaded from: d:\Data\.m2\repository\com\atlassian\clover\clover\4.0.4-SNAPSHOT\clover-4.0.4-SNAPSHOT.jar [INFO] Clover: Developer License registered to Atlassian. [INFO] Updating existing database at 'f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\clover\clover.db'. [INFO] Processing files at 1.8 source level. [INFO] Clover all over. Instrumented 1 file (1 package). [INFO] 1 test method detected. [INFO] Elapsed time = 0,011 secs. (90,909 files/sec, 818,182 srclines/sec) [INFO] [resources:resources {execution: default-resources}] [WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\src\main\resources [INFO] Copying 1 resource [INFO] [compiler:compile {execution: default-compile}] [INFO] Compiling 1 source file to f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\classes [INFO] [resources:testResources {execution: default-testResources}] [WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\src\test\resources [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] Compiling 1 source file to f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\test-classes [INFO] [surefire:test {execution: default-test}] [INFO] Surefire report directory: f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running ATest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.155 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [jar:jar {execution: default-jar}] [INFO] Building jar: f:\Work\maven-clover2-plugin-hg\src\it\pollutionProtection\target\clover-pollution-protection-1.0-SNAPSHOT.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ {noformat} It affects Maven 2.2.x. Does not occur in Maven 2.1.x or Maven 3.x. Summarizing, it seems that forking a parallel build life cycle causes that an artefact's classifier changes from empty to 'tests': * with clover2:instrument: {noformat} [INFO] [clover2:instrumentInternal {execution: default-instrumentInternal}] [INFO] XXXXXXXXXX CLASSIFIER= com.atlassian.maven.plugins.sample:clover-pollution-protection:jar:tests:1.0-SNAPSHOT ... [INFO] [clover2:instrument {execution: default-cli}] [INFO] XXXXXXXXXX CLASSIFIER= com.atlassian.maven.plugins.sample:clover-pollution-protection:jar:1.0-SNAPSHOT {noformat} * with clover2:setup: {noformat} [INFO] [clover2:setup {execution: default-cli}] [INFO] XXXXXXXXXX CLASSIFIER= com.atlassian.maven.plugins.sample:clover-pollution-protection:jar:1.0-SNAPSHOT {noformat} *Workaround:* * use clover2:setup instead of clover2:instrument to avoid forking life cycle or * use different Maven version or * disable the protection
Story points: 3