Skip to content

Commit

Permalink
For now keep it simple
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Oct 29, 2024
1 parent 7c24435 commit 800fc91
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@
<artifactId>plexus-utils</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xml</artifactId>
<version>3.0.1</version>
</dependency>

<!-- Maven Indexer -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,13 @@
import java.util.function.BiFunction;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.InputSource;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3WriterEx;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.search.api.MAVEN;
import org.apache.maven.search.api.SearchBackend;
import org.apache.maven.search.api.SearchRequest;
import org.apache.maven.search.api.SearchResponse;
import org.apache.maven.search.api.request.Query;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
Expand Down Expand Up @@ -858,27 +855,9 @@ public Result<Model> effectiveModel(ResolutionRoot resolutionRoot) throws Except
ModelResponse response = toolboxResolver.readModel(resolutionRoot.getArtifact());

ByteArrayOutputStream baos = new ByteArrayOutputStream();
MavenXpp3WriterEx mavenXpp3WriterEx = new MavenXpp3WriterEx();
mavenXpp3WriterEx.setStringFormatter(new InputLocation.StringFormatter() {
@Override
public String toString(InputLocation inputLocation) {
InputSource source = inputLocation.getSource();

String s = source.getModelId(); // by default, display modelId

if (StringUtils.isBlank(s) || s.contains("[unknown-version]")) {
// unless it is blank or does not provide version information
s = source.toString();
}

return '}'
+ s
+ ((inputLocation.getLineNumber() >= 0) ? ", line " + inputLocation.getLineNumber() : "")
+ " ";
}
});
mavenXpp3WriterEx.write(baos, response.getEffectiveModel());
output.doTell(baos.toString(StandardCharsets.UTF_8));
MavenXpp3Writer mavenXpp3Writer = new MavenXpp3Writer();
mavenXpp3Writer.write(baos, response.getEffectiveModel());
output.doTell("Effective model:\n{}", baos.toString(StandardCharsets.UTF_8));

return Result.success(response.getEffectiveModel());
}
Expand Down
7 changes: 6 additions & 1 deletion toolbox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<scope>provided</scope>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xml</artifactId>
<scope>compile</scope>
</dependency>

<!-- Resolver (provided by runtime) -->
Expand Down

0 comments on commit 800fc91

Please sign in to comment.