Java Code Examples for org.apache.maven.it.Verifier#addCliOption()
The following examples show how to use
org.apache.maven.it.Verifier#addCliOption() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MavenPluginMigrationTest.java From thorntail with Apache License 2.0 | 6 votes |
@Before public void setUpProject() throws IOException, VerificationException { assumeTrue("Set the M2_HOME environment variable", System.getenv("M2_HOME") != null); assumeTrue("Run from Maven or set the project.version system property", System.getProperty("project.version") != null); File projectDir = ResourceExtractor.extractResourcePath(getClass(), "/testing-project", tmp.getRoot(), true); verifier = new Verifier(projectDir.getAbsolutePath(), true); verifier.setForkJvm(true); String settingsXml = System.getProperty("org.apache.maven.user-settings"); if (settingsXml != null && new File(settingsXml).isFile()) { verifier.addCliOption("-s"); verifier.addCliOption(settingsXml); } logPath = Paths.get(verifier.getBasedir()).resolve(verifier.getLogFileName()); }
Example 2
Source File: MavenPluginTest.java From thorntail with Apache License 2.0 | 6 votes |
@Before public void setUpProject() throws IOException, VerificationException { assumeTrue("Set the M2_HOME environment variable", System.getenv("M2_HOME") != null); assumeTrue("Run from Maven or set the project.version system property", System.getProperty("project.version") != null); File projectDir = ResourceExtractor.extractResourcePath(getClass(), "/testing-project", tmp.getRoot(), true); testingProject.prepare(projectDir.toPath()); verifier = new Verifier(projectDir.getAbsolutePath(), true); verifier.setForkJvm(true); String settingsXml = System.getProperty("org.apache.maven.user-settings"); if (settingsXml != null && new File(settingsXml).isFile()) { verifier.addCliOption("-s"); verifier.addCliOption(settingsXml); } logPath = Paths.get(verifier.getBasedir()).resolve(verifier.getLogFileName()); }
Example 3
Source File: YangToSourcesPluginTestIT.java From yangtools with Eclipse Public License 1.0 | 6 votes |
static Verifier setUp(final String project, final boolean ignoreF) throws VerificationException, URISyntaxException, IOException { final URL path = YangToSourcesPluginTestIT.class.getResource("/" + project + "pom.xml"); final Verifier verifier = new Verifier(new File(path.toURI()).getParent()); if (ignoreF) { verifier.addCliOption("-fn"); } final Optional<String> maybeSettings = getEffectiveSettingsXML(); if (maybeSettings.isPresent()) { verifier.addCliOption("-gs"); verifier.addCliOption(maybeSettings.get()); } verifier.setMavenDebug(true); verifier.executeGoal("generate-sources"); return verifier; }
Example 4
Source File: TestPlugin.java From minikube-build-tools-for-java with Apache License 2.0 | 5 votes |
@Override protected void before() throws IOException, XmlPullParserException, VerificationException { // Installs the plugin for use in tests. Verifier verifier = new Verifier(".", true); verifier.setAutoclean(false); verifier.addCliOption("-DskipTests"); verifier.executeGoal("install"); // Reads the project version. MavenXpp3Reader reader = new MavenXpp3Reader(); Model model = reader.read(new FileReader("pom.xml")); pluginVersion = model.getVersion(); }
Example 5
Source File: MavenVerifierUtil.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public static Verifier newVerifier(String pathToTestProject) throws IOException, VerificationException { File testDir = ResourceExtractor.simpleExtractResources(MavenVerifierUtil.class, pathToTestProject); Verifier verifier = new Verifier(testDir.getAbsolutePath()); System.out.println("gradle: " + System.getProperty("gradleMavenRepo")); for (Object iterable_element : System.getProperties().keySet()) { System.out.println(iterable_element + "=" + System.getProperty(iterable_element.toString())); } String gradleMavenRepo = System.getProperty("gradleMavenRepo"); Assert.assertNotNull("gradleMavenRepo is null", gradleMavenRepo); verifier.setSystemProperty("gradleMavenRepo", gradleMavenRepo); verifier.setSystemProperty("nonTestMavenRepo", System.getProperty("maven.repo.local")); verifier.setSystemProperty("WORKSPACE", System.getProperty("WORKSPACE")); String testMavenRepo = System.getProperty("testMavenRepo"); Assert.assertNotNull("testMavenRepo is null", testMavenRepo); verifier.setLocalRepo(testMavenRepo); verifier.setDebug(true); String testSettingsXML = System.getProperty("testSettingsXML"); if (testSettingsXML != null) { verifier.addCliOption("-s"); verifier.addCliOption(testSettingsXML); } verifier.addCliOption("-U"); verifier.setMavenDebug(true); // verifier.setDebugJvm(true); // verifier.setForkJvm(false); return verifier; }
Example 6
Source File: GitVersioningExtensionIT.java From maven-git-versioning-extension with MIT License | 5 votes |
@Test void tagVersioning_cliOption_gitTag() throws Exception { // Given Git git = Git.init().setDirectory(projectDir.toFile()).call(); RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call(); String givenTag = "v1"; writeModel(projectDir.resolve("pom.xml").toFile(), pomModel); writeExtensionsFile(projectDir); Configuration extensionConfig = new Configuration(); extensionConfig.tag.add(createTagVersionDescription()); writeExtensionConfigFile(projectDir, extensionConfig); // When Verifier verifier = new Verifier(projectDir.toFile().getAbsolutePath()); verifier.addCliOption("-Dgit.tag=" + givenTag); verifier.executeGoal("verify"); // Then String log = getLog(verifier); assertThat(log).doesNotContain("[ERROR]", "[FATAL]"); String expectedVersion = givenTag + "-gitVersioning"; assertThat(log).contains("Building " + pomModel.getArtifactId() + " " + expectedVersion); Model gitVersionedPomModel = readModel(projectDir.resolve("target/").resolve(GIT_VERSIONING_POM_NAME).toFile()); assertThat(gitVersionedPomModel).satisfies(it -> assertSoftly(softly -> { softly.assertThat(it.getModelVersion()).isEqualTo(pomModel.getModelVersion()); softly.assertThat(it.getGroupId()).isEqualTo(pomModel.getGroupId()); softly.assertThat(it.getArtifactId()).isEqualTo(pomModel.getArtifactId()); softly.assertThat(it.getVersion()).isEqualTo(expectedVersion); softly.assertThat(it.getProperties()).doesNotContainKeys( "git.commit", "git.ref", "git.tag" ); })); }
Example 7
Source File: GitVersioningExtensionIT.java From maven-git-versioning-extension with MIT License | 5 votes |
@Test void tagVersioning_cliOption_preferTags_true() throws Exception { // Given Git git = Git.init().setDirectory(projectDir.toFile()).call(); RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call(); String givenTag = "v1"; git.tag().setAnnotated(false).setName(givenTag).call(); writeModel(projectDir.resolve("pom.xml").toFile(), pomModel); writeExtensionsFile(projectDir); Configuration extensionConfig = new Configuration(); extensionConfig.branch.add(createBranchVersionDescription()); extensionConfig.tag.add(createTagVersionDescription()); writeExtensionConfigFile(projectDir, extensionConfig); // When Verifier verifier = new Verifier(projectDir.toFile().getAbsolutePath()); verifier.addCliOption("-Dversioning.preferTags=true"); verifier.executeGoal("verify"); // Then String log = getLog(verifier); assertThat(log).doesNotContain("[ERROR]", "[FATAL]"); String expectedVersion = givenTag + "-gitVersioning"; assertThat(log).contains("Building " + pomModel.getArtifactId() + " " + expectedVersion); Model gitVersionedPomModel = readModel(projectDir.resolve("target/").resolve(GIT_VERSIONING_POM_NAME).toFile()); assertThat(gitVersionedPomModel).satisfies(it -> assertSoftly(softly -> { softly.assertThat(it.getModelVersion()).isEqualTo(pomModel.getModelVersion()); softly.assertThat(it.getGroupId()).isEqualTo(pomModel.getGroupId()); softly.assertThat(it.getArtifactId()).isEqualTo(pomModel.getArtifactId()); softly.assertThat(it.getVersion()).isEqualTo(expectedVersion); softly.assertThat(it.getProperties()).doesNotContainKeys( "git.commit", "git.ref", "git.tag" ); })); }
Example 8
Source File: GitVersioningExtensionIT.java From maven-git-versioning-extension with MIT License | 5 votes |
@Test void tagVersioning_cliOption_conflictingTag() throws Exception { // Given Git git = Git.init().setDirectory(projectDir.toFile()).call(); RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call(); String givenTag = "v1"; git.tag().setAnnotated(false).setName("v2").call(); writeModel(projectDir.resolve("pom.xml").toFile(), pomModel); writeExtensionsFile(projectDir); Configuration extensionConfig = new Configuration(); extensionConfig.tag.add(createTagVersionDescription()); writeExtensionConfigFile(projectDir, extensionConfig); // When Verifier verifier = new Verifier(projectDir.toFile().getAbsolutePath()); verifier.addCliOption("-Dgit.tag=" + givenTag); verifier.executeGoal("verify"); // Then String log = getLog(verifier); assertThat(log).doesNotContain("[ERROR]", "[FATAL]"); String expectedVersion = givenTag + "-gitVersioning"; assertThat(log).contains("Building " + pomModel.getArtifactId() + " " + expectedVersion); Model gitVersionedPomModel = readModel(projectDir.resolve("target/").resolve(GIT_VERSIONING_POM_NAME).toFile()); assertThat(gitVersionedPomModel).satisfies(it -> assertSoftly(softly -> { softly.assertThat(it.getModelVersion()).isEqualTo(pomModel.getModelVersion()); softly.assertThat(it.getGroupId()).isEqualTo(pomModel.getGroupId()); softly.assertThat(it.getArtifactId()).isEqualTo(pomModel.getArtifactId()); softly.assertThat(it.getVersion()).isEqualTo(expectedVersion); softly.assertThat(it.getProperties()).doesNotContainKeys( "git.commit", "git.ref", "git.tag" ); })); }
Example 9
Source File: GitVersioningExtensionIT.java From maven-git-versioning-extension with MIT License | 5 votes |
@Test void tagVersioning_cliOption_withBranch() throws Exception { // Given Git git = Git.init().setDirectory(projectDir.toFile()).call(); RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call(); String givenTag = "v1"; writeModel(projectDir.resolve("pom.xml").toFile(), pomModel); writeExtensionsFile(projectDir); Configuration extensionConfig = new Configuration(); extensionConfig.branch.add(createBranchVersionDescription()); extensionConfig.tag.add(createTagVersionDescription()); writeExtensionConfigFile(projectDir, extensionConfig); // When Verifier verifier = new Verifier(projectDir.toFile().getAbsolutePath()); verifier.addCliOption("-Dgit.tag=" + givenTag); verifier.executeGoal("verify"); // Then String log = getLog(verifier); assertThat(log).doesNotContain("[ERROR]", "[FATAL]"); String expectedVersion = givenTag + "-gitVersioning"; assertThat(log).contains("Building " + pomModel.getArtifactId() + " " + expectedVersion); Model gitVersionedPomModel = readModel(projectDir.resolve("target/").resolve(GIT_VERSIONING_POM_NAME).toFile()); assertThat(gitVersionedPomModel).satisfies(it -> assertSoftly(softly -> { softly.assertThat(it.getModelVersion()).isEqualTo(pomModel.getModelVersion()); softly.assertThat(it.getGroupId()).isEqualTo(pomModel.getGroupId()); softly.assertThat(it.getArtifactId()).isEqualTo(pomModel.getArtifactId()); softly.assertThat(it.getVersion()).isEqualTo(expectedVersion); softly.assertThat(it.getProperties()).doesNotContainKeys( "git.commit", "git.ref", "git.tag" ); })); }
Example 10
Source File: GitVersioningExtensionIT.java From maven-git-versioning-extension with MIT License | 4 votes |
@Test void tagVersioning_cliOption_preferTags_false() throws Exception { // Given Git git = Git.init().setDirectory(projectDir.toFile()).call(); RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call(); String givenTag = "v1"; git.tag().setAnnotated(false).setName(givenTag).call(); writeModel(projectDir.resolve("pom.xml").toFile(), pomModel); writeExtensionsFile(projectDir); Configuration extensionConfig = new Configuration(); extensionConfig.branch.add(createBranchVersionDescription()); extensionConfig.tag.add(createTagVersionDescription()); extensionConfig.preferTags = true; writeExtensionConfigFile(projectDir, extensionConfig); // When Verifier verifier = new Verifier(projectDir.toFile().getAbsolutePath()); verifier.addCliOption("-Dversioning.preferTags=false"); verifier.executeGoal("verify"); // Then String log = getLog(verifier); assertThat(log).doesNotContain("[ERROR]", "[FATAL]"); String expectedVersion = "master-gitVersioning"; assertThat(log).contains("Building " + pomModel.getArtifactId() + " " + expectedVersion); Model gitVersionedPomModel = readModel(projectDir.resolve("target/").resolve(GIT_VERSIONING_POM_NAME).toFile()); assertThat(gitVersionedPomModel).satisfies(it -> assertSoftly(softly -> { softly.assertThat(it.getModelVersion()).isEqualTo(pomModel.getModelVersion()); softly.assertThat(it.getGroupId()).isEqualTo(pomModel.getGroupId()); softly.assertThat(it.getArtifactId()).isEqualTo(pomModel.getArtifactId()); softly.assertThat(it.getVersion()).isEqualTo(expectedVersion); softly.assertThat(it.getProperties()).doesNotContainKeys( "git.commit", "git.ref", "git.tag" ); })); }