Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public interface Language extends ExtensibleEnum {
*
* @deprecated Use {@link #RESOURCES} instead.
*/
@Deprecated
@Deprecated(since = "4.0.0-alpha", forRemoval = false)
Language SCRIPT = language("script");

// TODO: this should be moved out from here to Java Support (builtin into core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,48 +54,85 @@
@Immutable
public interface XmlNode {

/**
* @deprecated Use {@link XmlService#CHILDREN_COMBINATION_MODE_ATTRIBUTE} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
String CHILDREN_COMBINATION_MODE_ATTRIBUTE = XmlService.CHILDREN_COMBINATION_MODE_ATTRIBUTE;

/**
* @deprecated since 4.0.0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we need to say "since 4.0.0." Will the annotation add this?

* Use {@link XmlService#CHILDREN_COMBINATION_MODE_ATTRIBUTE} instead.
* Use {@link XmlService#CHILDREN_COMBINATION_MERGE} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
String CHILDREN_COMBINATION_MODE_ATTRIBUTE = XmlService.CHILDREN_COMBINATION_MODE_ATTRIBUTE;

@Deprecated(since = "4.0.0", forRemoval = true)
String CHILDREN_COMBINATION_MERGE = XmlService.CHILDREN_COMBINATION_MERGE;


/**
* @deprecated since 4.0.0.
* Use {@link XmlService#CHILDREN_COMBINATION_APPEND} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
String CHILDREN_COMBINATION_APPEND = XmlService.CHILDREN_COMBINATION_APPEND;


/**
* This default mode for combining children DOMs during merge means that where element names match, the process will
* try to merge the element data, rather than putting the dominant and recessive elements (which share the same
* element name) as siblings in the resulting DOM.
*
* @deprecated since 4.0.0.
* Use {@link XmlService#DEFAULT_CHILDREN_COMBINATION_MODE} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
String DEFAULT_CHILDREN_COMBINATION_MODE = XmlService.DEFAULT_CHILDREN_COMBINATION_MODE;

/**
* @deprecated since 4.0.0.
* Use {@link XmlService#SELF_COMBINATION_MODE_ATTRIBUTE} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
String SELF_COMBINATION_MODE_ATTRIBUTE = XmlService.SELF_COMBINATION_MODE_ATTRIBUTE;

/**
* @deprecated since 4.0.0.
* Use {@link XmlService#SELF_COMBINATION_OVERRIDE} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
String SELF_COMBINATION_OVERRIDE = XmlService.SELF_COMBINATION_OVERRIDE;

/**
* @deprecated since 4.0.0.
* Use {@link XmlService#SELF_COMBINATION_MERGE} instead.
*/

@Deprecated(since = "4.0.0", forRemoval = true)
String SELF_COMBINATION_MERGE = XmlService.SELF_COMBINATION_MERGE;
/**
* @deprecated since 4.0.0.
* Use {@link XmlService#SELF_COMBINATION_REMOVE} instead.
*/

@Deprecated(since = "4.0.0", forRemoval = true)
String SELF_COMBINATION_REMOVE = XmlService.SELF_COMBINATION_REMOVE;

/**
* In case of complex XML structures, combining can be done based on id.
*
* @deprecated since 4.0.0.
* Use {@link XmlService#ID_COMBINATION_MODE_ATTRIBUTE} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
String ID_COMBINATION_MODE_ATTRIBUTE = XmlService.ID_COMBINATION_MODE_ATTRIBUTE;

/**
* In case of complex XML structures, combining can be done based on keys.
* This is a comma separated list of attribute names.
*
* @deprecated since 4.0.0.
* Use {@link XmlService#KEYS_COMBINATION_MODE_ATTRIBUTE} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
String KEYS_COMBINATION_MODE_ATTRIBUTE = XmlService.KEYS_COMBINATION_MODE_ATTRIBUTE;
Expand All @@ -105,6 +142,9 @@ public interface XmlNode {
* try to merge the element attributes and values, rather than overriding the recessive element completely with the
* dominant one. This means that wherever the dominant element doesn't provide the value or a particular attribute,
* that value or attribute will be set from the recessive DOM node.
*
* @deprecated since 4.0.0.
* Use {@link XmlService#DEFAULT_SELF_COMBINATION_MODE} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
String DEFAULT_SELF_COMBINATION_MODE = XmlService.DEFAULT_SELF_COMBINATION_MODE;
Expand Down Expand Up @@ -185,77 +225,110 @@ public interface XmlNode {
@Nullable
Object inputLocation();

// Deprecated methods that delegate to new ones
@Deprecated(since = "4.0.0", forRemoval = true)
@Nonnull
default String getName() {
return name();
}

/**
* @deprecated since 4.0.0.
* Use {@link #namespaceUri()} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
@Nonnull
default String getNamespaceUri() {
return namespaceUri();
}

/**
* @deprecated since 4.0.0.
* Use {@link #prefix()} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
@Nonnull
default String getPrefix() {
return prefix();
}

/**
* @deprecated since 4.0.0.
* Use {@link #value()} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
@Nullable
default String getValue() {
return value();
}

/**
* @deprecated since 4.0.0.
* Use {@link #attributes()} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
@Nonnull
default Map<String, String> getAttributes() {
return attributes();
}

/**
* @deprecated since 4.0.0.
* Use {@link #attribute(String)} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
@Nullable
default String getAttribute(@Nonnull String name) {
return attribute(name);
}

/**
* @deprecated since 4.0.0.
* Use {@link #children()} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
@Nonnull
default List<XmlNode> getChildren() {
return children();
}

/**
* @deprecated since 4.0.0.
* Use {@link #child(String)} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
@Nullable
default XmlNode getChild(String name) {
return child(name);
}

/**
* @deprecated since 4.0.0.
* Use {@link #inputLocation()} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
@Nullable
default Object getInputLocation() {
return inputLocation();
}

/**
* @deprecated use {@link XmlService#merge(XmlNode, XmlNode, Boolean)} instead
* @deprecated since 4.0.0.
* Use {@link XmlService#merge(XmlNode, XmlNode, Boolean)} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
default XmlNode merge(@Nullable XmlNode source) {
return XmlService.merge(this, source);
}

/**
* @deprecated use {@link XmlService#merge(XmlNode, XmlNode, Boolean)} instead
* @deprecated since 4.0.0.
* Use {@link XmlService#merge(XmlNode, XmlNode, Boolean)} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
default XmlNode merge(@Nullable XmlNode source, @Nullable Boolean childMergeOverride) {
return XmlService.merge(this, source, childMergeOverride);
}


/**
* Merge recessive into dominant and return either {@code dominant}
* with merged information or a clone of {@code recessive} if
Expand All @@ -265,7 +338,8 @@ default XmlNode merge(@Nullable XmlNode source, @Nullable Boolean childMergeOver
* @param recessive if {@code null}, nothing will happen
* @return the merged node
*
* @deprecated use {@link XmlService#merge(XmlNode, XmlNode, Boolean)} instead
* @deprecated since 4.0.0.
* Use {@link XmlService#merge(XmlNode, XmlNode, Boolean)} instead.
*/
@Deprecated(since = "4.0.0", forRemoval = true)
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,19 @@
*/
public interface Artifact extends Comparable<Artifact> {

/**
* @deprecated
* The use of the {@code RELEASE} version is discouraged because it results in non-reproducible builds.
* Use explicit versions instead.
*/
@Deprecated(since = "4.0.0")
String RELEASE_VERSION = "RELEASE";

/**
* @deprecated
* The use of the {@code LATEST} version is discouraged because it results in non-reproducible builds.
* Use explicit versions instead.
*/
@Deprecated(since = "4.0.0")
String LATEST_VERSION = "LATEST";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,55 @@ public void attachArtifact(@Nonnull Project project, @Nonnull ProducedArtifact a
artifact.getExtension(),
null);
}
if (!Objects.equals(project.getGroupId(), artifact.getGroupId())
|| !Objects.equals(project.getArtifactId(), artifact.getArtifactId())
|| !Objects.equals(
project.getVersion(), artifact.getBaseVersion().toString())) {
throw new IllegalArgumentException(
"The produced artifact must have the same groupId/artifactId/version than the project it is attached to. Expecting "
+ project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion()
+ " but received " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":"
+ artifact.getBaseVersion());
// Verify groupId and version, intentionally allow artifactId to differ as Maven project may be
// multi-module with modular sources structure that provide module names used as artifactIds.
String g1 = project.getGroupId();
String a1 = project.getArtifactId();
String v1 = project.getVersion();
String g2 = artifact.getGroupId();
String a2 = artifact.getArtifactId();
String v2 = artifact.getBaseVersion().toString();

// ArtifactId may differ only for multi-module projects, in which case
// it must match the module name from a source root in modular sources.
boolean isMultiModule = false;
boolean validArtifactId = Objects.equals(a1, a2);
for (SourceRoot sr : getSourceRoots(project)) {
Optional<String> moduleName = sr.module();
if (moduleName.isPresent()) {
isMultiModule = true;
if (moduleName.get().equals(a2)) {
validArtifactId = true;
break;
}
}
}
boolean isSameGroupAndVersion = Objects.equals(g1, g2) && Objects.equals(v1, v2);
if (!(isSameGroupAndVersion && validArtifactId)) {
String message;
if (isMultiModule) {
// Multi-module project: artifactId may match any declared module name
message = String.format(
"Cannot attach artifact to project: groupId and version must match the project, "
+ "and artifactId must match either the project or a declared module name.%n"
+ " Project coordinates: %s:%s:%s%n"
+ " Artifact coordinates: %s:%s:%s%n",
g1, a1, v1, g2, a2, v2);
if (isSameGroupAndVersion) {
message += String.format(
" Hint: The artifactId '%s' does not match the project artifactId '%s' "
+ "nor any declared module name in source roots.",
a2, a1);
}
} else {
// Non-modular project: artifactId must match exactly
message = String.format(
"Cannot attach artifact to project: groupId, artifactId and version must match the project.%n"
+ " Project coordinates: %s:%s:%s%n"
+ " Artifact coordinates: %s:%s:%s",
g1, a1, v1, g2, a2, v2);
}
throw new IllegalArgumentException(message);
}
getMavenProject(project)
.addAttachedArtifact(
Expand Down
Loading