77import com .github .lombrozo .xnav .Filter ;
88import com .github .lombrozo .xnav .Xnav ;
99import com .jcabi .log .Logger ;
10- import java .io .FileNotFoundException ;
1110import java .io .IOException ;
1211import java .nio .file .Path ;
1312import java .util .Collection ;
1615import java .util .stream .Stream ;
1716import org .apache .maven .plugins .annotations .LifecyclePhase ;
1817import org .apache .maven .plugins .annotations .Mojo ;
19- import org .cactoos .iterable .Filtered ;
2018import org .cactoos .iterable .IterableOf ;
2119import org .cactoos .iterable .Mapped ;
2220import org .cactoos .list .ListOf ;
@@ -89,9 +87,7 @@ private void probe() throws IOException {
8987 continue ;
9088 }
9189 ++count ;
92- this .scopedTojos ()
93- .add (object )
94- .withDiscoveredAt (src );
90+ this .scopedTojos ().add (object ).withDiscoveredAt (src );
9591 probed .add (object );
9692 }
9793 tojo .withProbed (count );
@@ -123,17 +119,13 @@ private void probe() throws IOException {
123119 *
124120 * @param file The .xmir file
125121 * @return List of foreign objects found
126- * @throws FileNotFoundException If not found
127122 */
128- private Collection <String > probes (final Path file ) throws FileNotFoundException {
123+ private Collection <String > probes (final Path file ) {
129124 final long start = System .currentTimeMillis ();
130125 final Collection <String > objects = new ListOf <>(
131126 new Mapped <>(
132127 ProbeMojo ::noPrefix ,
133- new Filtered <>(
134- obj -> !obj .isEmpty (),
135- ProbeMojo .probeMetas (file )
136- )
128+ ProbeMojo .metas (file )
137129 ).iterator ()
138130 );
139131 if (objects .isEmpty ()) {
@@ -151,12 +143,13 @@ private Collection<String> probes(final Path file) throws FileNotFoundException
151143 }
152144
153145 /**
154- * Return probe metas.
155- * The equivalent xpath is: "/program/metas/meta[head/text() = 'probe']/tail/text()"
146+ * Return metas for probing.
147+ * The equivalent xpath is:
148+ * "/program/metas/meta[head/text()='probe' or head/text()='also']/tail[not(text()='')]/text()"
156149 * @param file XML file
157150 * @return Metas to probe
158151 */
159- private static Iterable <String > probeMetas (final Path file ) {
152+ private static Iterable <String > metas (final Path file ) {
160153 return new IterableOf <>(
161154 new Xnav (file )
162155 .element ("program" )
@@ -170,11 +163,14 @@ private static Iterable<String> probeMetas(final Path file) {
170163 final Optional <String > head = new Xnav (meta )
171164 .element ("head" )
172165 .text ();
173- return head .isPresent () && "probe" .equals (head .get ());
166+ return head .map (
167+ text -> "probe" .equals (text ) || "also" .equals (text )
168+ ).orElse (false );
174169 }
175170 )
176171 )
177172 .map (meta -> meta .element ("tail" ).text ().get ())
173+ .filter (meta -> !meta .isEmpty ())
178174 )
179175 .orElse (Stream .of ())
180176 .iterator ()
0 commit comments