diff --git a/api/maven-api-toolchain/src/main/mdo/toolchains.mdo b/api/maven-api-toolchain/src/main/mdo/toolchains.mdo
index 6a9bd87860..49c1b2f6b4 100644
--- a/api/maven-api-toolchain/src/main/mdo/toolchains.mdo
+++ b/api/maven-api-toolchain/src/main/mdo/toolchains.mdo
@@ -199,6 +199,51 @@
+
+
+ InputLocation
+ 1.2.0+
+
+
+
+
+
+ 1.2.0+
+
+
+ @Override
+ public String toString() {
+ return getLineNumber() + " : " + getColumnNumber() + ", " + getSource();
+ }
+
+
+
+
+
+ InputSource
+ 1.2.0+
+
+
+ location
+ 1.2.0+
+ String
+
+ The path/URL of the settings definition or {@code null} if unknown.
+
+
+
+
+
+ 1.2.0+
+
+ @Override
+ public String toString() {
+ return getLocation();
+ }
+
+
+
+
diff --git a/maven-api-impl/pom.xml b/maven-api-impl/pom.xml
index e0a0968cfd..7e00b5782f 100644
--- a/maven-api-impl/pom.xml
+++ b/maven-api-impl/pom.xml
@@ -196,7 +196,7 @@ under the License.
generate-sources
- 1.1.0
+ 1.2.0
${project.basedir}/../api/maven-api-toolchain
${project.basedir}/../src/mdo
@@ -212,6 +212,8 @@ under the License.
packageModelV3=org.apache.maven.toolchain.model
packageModelV4=org.apache.maven.api.toolchain
packageToolV4=org.apache.maven.toolchain.v4
+ locationTracking=true
+ generateLocationClasses=true
diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultToolchainsXmlFactory.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultToolchainsXmlFactory.java
index e20990bb0f..cb6f44add7 100644
--- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultToolchainsXmlFactory.java
+++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultToolchainsXmlFactory.java
@@ -32,6 +32,7 @@ import org.apache.maven.api.services.xml.XmlReaderException;
import org.apache.maven.api.services.xml.XmlReaderRequest;
import org.apache.maven.api.services.xml.XmlWriterException;
import org.apache.maven.api.services.xml.XmlWriterRequest;
+import org.apache.maven.api.toolchain.InputSource;
import org.apache.maven.api.toolchain.PersistedToolchains;
import org.apache.maven.toolchain.v4.MavenToolchainsStaxReader;
import org.apache.maven.toolchain.v4.MavenToolchainsStaxWriter;
@@ -52,12 +53,16 @@ public class DefaultToolchainsXmlFactory implements ToolchainsXmlFactory {
throw new IllegalArgumentException("reader or inputStream must be non null");
}
try {
+ InputSource source = null;
+ if (request.getModelId() != null || request.getLocation() != null) {
+ source = new InputSource(request.getLocation());
+ }
MavenToolchainsStaxReader xml = new MavenToolchainsStaxReader();
xml.setAddDefaultEntities(request.isAddDefaultEntities());
if (reader != null) {
- return xml.read(reader, request.isStrict());
+ return xml.read(reader, request.isStrict(), source);
} else {
- return xml.read(inputStream, request.isStrict());
+ return xml.read(inputStream, request.isStrict(), source);
}
} catch (Exception e) {
throw new XmlReaderException("Unable to read toolchains: " + getMessage(e), getLocation(e), e);
diff --git a/maven-toolchain-builder/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java b/maven-toolchain-builder/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java
index f474b9ca56..bda71b077d 100644
--- a/maven-toolchain-builder/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java
+++ b/maven-toolchain-builder/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java
@@ -30,6 +30,7 @@ import java.nio.file.Files;
import java.util.Map;
import java.util.Objects;
+import org.apache.maven.api.toolchain.InputSource;
import org.apache.maven.toolchain.model.PersistedToolchains;
import org.apache.maven.toolchain.v4.MavenToolchainsStaxReader;
@@ -47,7 +48,8 @@ public class DefaultToolchainsReader implements ToolchainsReader {
Objects.requireNonNull(input, "input cannot be null");
try (InputStream in = Files.newInputStream(input.toPath())) {
- return new PersistedToolchains(new MavenToolchainsStaxReader().read(in, isStrict(options)));
+ InputSource source = new InputSource(input.toString());
+ return new PersistedToolchains(new MavenToolchainsStaxReader().read(in, isStrict(options), source));
} catch (XMLStreamException e) {
throw new ToolchainsParseException(
e.getMessage(),
@@ -62,7 +64,8 @@ public class DefaultToolchainsReader implements ToolchainsReader {
Objects.requireNonNull(input, "input cannot be null");
try (Reader in = input) {
- return new PersistedToolchains(new MavenToolchainsStaxReader().read(in, isStrict(options)));
+ InputSource source = (InputSource) options.get(InputSource.class.getName());
+ return new PersistedToolchains(new MavenToolchainsStaxReader().read(in, isStrict(options), source));
} catch (XMLStreamException e) {
throw new ToolchainsParseException(
e.getMessage(),
@@ -77,7 +80,8 @@ public class DefaultToolchainsReader implements ToolchainsReader {
Objects.requireNonNull(input, "input cannot be null");
try (InputStream in = input) {
- return new PersistedToolchains(new MavenToolchainsStaxReader().read(in, isStrict(options)));
+ InputSource source = (InputSource) options.get(InputSource.class.getName());
+ return new PersistedToolchains(new MavenToolchainsStaxReader().read(in, isStrict(options), source));
} catch (XMLStreamException e) {
throw new ToolchainsParseException(
e.getMessage(),
diff --git a/src/mdo/reader-stax.vm b/src/mdo/reader-stax.vm
index 692bd2a8a6..0d3136d9f9 100644
--- a/src/mdo/reader-stax.vm
+++ b/src/mdo/reader-stax.vm
@@ -662,7 +662,13 @@ public class ${className} {
#end
break;
#elseif ( $field.to && $field.multiplicity == "*" && $Helper.isFlatItems( $field ) )
+ #if ( $locationTracking )
+ ${field.name}.add(parse${field.toClass.name}(parser, strict, source));
+ #elseif ( $needXmlContext )
+ ${field.name}.add(parse${field.toClass.name}(parser, strict, context));
+ #else
${field.name}.add(parse${field.toClass.name}(parser, strict));
+ #end
break;
#elseif ( $field.to && $field.multiplicity == "*" )
List<$field.to> ${field.name} = new ArrayList<>();