How do inject properties or environment variables into my Maven plugin testcase? -
I've created a Maven plugin using and I'm trying to check it out.
I'm using to test and I'm having trouble giving injections to values for my plugin parameters.
I have the following pom.xml file ( My mojo looks like this (at the top): I am using the approach for testing and my setup method looks like this: I use setter for some of my tests (which tests bad docker locations), but for my good path testing, I Environmental variable I have tried to dump What am I missing here? Why not my Where did you do syntax is mentioned: "(More can be found in" Parameter Expression "document)" . Although it is my experience that at least some, if not all, the latest information of the connected docks and not the latest enhancements. A possible interpretation program logic point of view: If a default value is set out from the scope of a program, then it can not be considered as the default value. In the sense of Maven EDIT: Added Expression Document src / test / resources / pom.xml ) for testing:
& lt; Project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns: xsi = "http: // www. W3.org/2001/XMLSchema-instance" xsi: schema location = "http: / /maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "& gt; & Lt; ModelVersion & gt; 4.0.0 & lt; / ModelVersion & gt; & Lt; Group & gt; Com.vodori.pepper.docker.vm.unit & lt; / Group & gt; & Lt; ArtifactId & gt; Test pom & lt; / ArtifactId> & Lt; Version & gt; 1.0-snapshots & lt; / Edition & gt; & Lt; Packaging & gt; Jar & lt; / Packaging & gt; & Lt; Name & gt; Exam VMStarter & lt; / Name & gt; & Lt; Dependency & gt; & Lt; Dependency & gt; & Lt; Group & gt; JUnit & lt; / Group & gt; & Lt; ArtifactId & gt; JUnit & lt; / ArtifactId> & Lt; Version & gt; 4.11 & lt; / Edition & gt; & Lt; Scope & gt; Trial & lt; / Scope & gt; & Lt; / Dependencies & gt; & Lt; / Dependencies & gt; & Lt; Construction & gt; & Lt; Plugins & gt; & Lt; Plugin & gt; & Lt; Group & gt; Com.vodori.common & lt; / Group & gt; & Lt; ArtifactId & gt; Black Pepper-Docher-VM & lt; / ArtifactId> & Lt; Version & gt; 1.0.1-Snapshot & lt; / Edition & gt; & Lt; Configuration & gt; & Lt; DockerSnapshotSite & gt; Black pepper-demo site & lt; / DockerSnapshotSite & gt; & Lt; DockerSnapshotVersion & gt; 3.6.11 & lt; / DockerSnapshotVersion & gt; & Lt; / Configuration & gt; & Lt; / Plugin & gt; & Lt; / Plugins & gt; & Lt; / Create & gt; & Lt; / Project & gt;
Public abstract class VMPlugin extends AbstractMojo {/ ** * Docker location * / @Parameter (essential = true, property = "docker.", Defaultwall = "$ {env.DOCKER_LOCATION}") string dock path; Public Zero Set Dokterpath (String Dock Path) {this.dockerpath = Dokterpath; } / ** * Doker VM site name * / @ parameter (required = true, property = "docker scapshot.") String Docker snapshot site; / ** * Version of the dockkey snapshot / @ parameter (required = true, property = "docker snapshot.version") string docker snapshot version;
@ throws public first zero exceptions (exceptions) Exception {vmStarter = (VMStarter) rule.lookupMojo ("Start- docker-vm", "src / test / resources / pom.xml"); AssertNotNull (vmStarter); }
DOCKER_LOCATION for population, however, for some reason,
Docarpath is now visible as
null . It looks like
defaultValue is being ignored.
System.getEnv () on STDERR and I can see that
DOCKER_LOCATION is in fact set.
@Parameter being populated correctly?
default value = "$ {env.DOCKER_LOCATION}" From?
and * another "You can use Maven in a pom.xml file or in any resource that is being processed by the MyOne resource plug-in filtering features."
Default-value
But I have not found any such document yet. Thx @khmarbaise:. $ {env} does not show with my Maven 3.2.1.
Comments
Post a Comment