Skip to content

Commit

Permalink
#81 tested and fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Sep 26, 2024
1 parent 67b05b2 commit ccfb7df
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .rultor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
docker:
image: yegor256/rultor-image:1.23.1
image: yegor256/rultor-java
assets:
settings.xml: yegor256/home#assets/farea/settings.xml
pubring.gpg: yegor256/home#assets/pubring.gpg
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/yegor256/farea/Execution.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ public Execution phase(final String value) throws IOException {
* @throws IOException If fails
*/
public Execution goals(final String... values) throws IOException {
final Directives dirs = this.into().add("goals");
final Directives dirs = this.into()
.addIf("goals")
.up()
.xpath("goals");
for (final String goal : values) {
dirs.add("goal").set(goal).up();
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/yegor256/farea/ConfigurationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void setsArrayAsParam(@TempDir final Path dir) throws IOException {
void setsMapAsParam(@TempDir final Path dir) throws IOException {
final Path xml = dir.resolve("pom-3.xml");
final Pom pom = new Pom(xml);
final Map<String, Integer> map = new HashMap<>();
final Map<String, Integer> map = new HashMap<>(0);
map.put("test", 42);
new Plugins(pom).append("bbb", "1.2.3")
.execution("foo")
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/com/yegor256/farea/PluginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package com.yegor256.farea;

import com.jcabi.matchers.XhtmlMatchers;
import java.io.IOException;
import java.nio.file.Path;
import org.hamcrest.MatcherAssert;
Expand Down Expand Up @@ -84,4 +85,27 @@ void addsConfiguration(@TempDir final Path dir) throws IOException {
);
}

@Test
void addsGoalsAndConfiguration(@TempDir final Path dir) throws IOException {
final Path xml = dir.resolve("pom.xml");
final Pom pom = new Pom(xml).init();
new Plugins(pom)
.appendItself()
.execution("default")
.phase("process-classes")
.goals("build", "optimize")
.goals("test")
.configuration()
.set("foo", "bar");
MatcherAssert.assertThat(
"Sets plugin configuration and goals",
XhtmlMatchers.xhtml(pom.xml()),
XhtmlMatchers.hasXPaths(
"/project/build/plugins/plugin/executions/execution[count(goals) = 1]",
"/project/build/plugins/plugin/executions/execution/goals[count(goal) = 3]",
"/project/build/plugins/plugin/executions/execution/configuration/foo[text() = 'bar']"
)
);
}

}
32 changes: 32 additions & 0 deletions src/test/resources/META-INF/maven/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License (MIT)
Copyright (c) 2023 Yegor Bugayenko
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<plugin>
<name>hone-maven-plugin</name>
<description>Optimisation of Java Bytecode via EOLANG</description>
<groupId>org.eolang</groupId>
<artifactId>hone-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<goalPrefix>hone</goalPrefix>
</plugin>

0 comments on commit ccfb7df

Please sign in to comment.