Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c0a838d
[MNG-8015] Control the type of path where each dependency can be placed
desruisseaux Jan 7, 2024
c8b754c
[MNG-8015] Control the type of path where each dependency can be placed
desruisseaux Jan 7, 2024
74baea1
[MNG-8015] Control the type of path where each dependency can be placed
desruisseaux Jan 7, 2024
b709b5f
[MNG-8015] Control the type of path where each dependency can be placed
desruisseaux Jan 8, 2024
9c5e9ff
[MNG-8015] Control the type of path where each dependency can be placed
desruisseaux Jan 8, 2024
a646ab4
[MNG-8015] Control the type of path where each dependency can be placed
desruisseaux Jan 8, 2024
de2d353
First round of pull request comments resolution: typos and minor chan…
desruisseaux Jan 20, 2024
ab8782f
Remove the deprecated `FLAG_CLASS_PATH_CONSTITUENT` key and the `Type…
desruisseaux Jan 20, 2024
3ae371a
Makes `PathType` an interface, `JavaPathType` an enumeration implemen…
desruisseaux Jan 20, 2024
67bd4b9
Replace `PathType[]` by `Set<PathType>` for the property value of `De…
desruisseaux Jan 21, 2024
3d55f24
Replace HTML headings by paragraph and bold characters for avoiding c…
desruisseaux Jan 21, 2024
943fb04
Step 2:
cstamas Jan 24, 2024
37fb446
Step2b
cstamas Jan 24, 2024
944c391
Remove unrelated
cstamas Jan 24, 2024
dcc0498
Remove unused
cstamas Jan 24, 2024
22b31ad
Add TODO
cstamas Jan 24, 2024
dc4b1e7
Undo ArtifactProperties and Artifact#isSnapshot changes for now
gnodet Jan 31, 2024
3e3aa04
Fix UT
gnodet Jan 31, 2024
2536929
Introduce "extensible enum" and provides registries, SPI providers, e…
gnodet Jan 31, 2024
cf08727
Use the new scopes
gnodet Jan 31, 2024
ff413ae
Fix UT
gnodet Jan 31, 2024
56b6b5a
Remove DependencyProperties interface
gnodet Jan 31, 2024
734910a
Use a plain enum for DependencyScope which is not extensible
gnodet Jan 31, 2024
3d2df72
Remove unused BuildPath
gnodet Jan 31, 2024
3b2bc64
Rename BuildPathScope -> PathScope
gnodet Jan 31, 2024
e40f20f
Rename BuildPathScope -> PathScope
gnodet Jan 31, 2024
c535260
[MNG-8015] Control the type of path where each dependency can be placed
desruisseaux Jan 7, 2024
7933d19
Merge branch 'MNG-8026' into explicit-module-path
gnodet Jan 31, 2024
fe3975f
Fix javadoc
gnodet Feb 1, 2024
dd87384
Add Javadoc in `Session` interface and some `@Nonnull` annotations.
desruisseaux Feb 4, 2024
cb2386c
Add `Session.resolveDependencies(..., Collection<PathType>) convenien…
desruisseaux Feb 4, 2024
b72d1ce
Remove @todo tags not recognized by Javadoc.
desruisseaux Feb 4, 2024
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 @@ -30,16 +30,8 @@ public interface Dependency extends Artifact {
@Nonnull
Type getType();

/**
* The dependency properties.
*
* @return the dependency properties, never {@code null}
*/
@Nonnull
DependencyProperties getDependencyProperties();

@Nonnull
Scope getScope();
DependencyScope getScope();

boolean isOptional();

Expand All @@ -49,5 +41,6 @@ public interface Dependency extends Artifact {
* @return a {@link DependencyCoordinate}
*/
@Nonnull
@Override
DependencyCoordinate toCoordinate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public interface DependencyCoordinate extends ArtifactCoordinate {
Type getType();

@Nonnull
Scope getScope();
DependencyScope getScope();

@Nullable
Boolean getOptional();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.api;

import java.util.Collections;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Immutable;
import org.apache.maven.api.annotations.Nonnull;

/**
* Dependency scope.
* <p>
* Implementation must have {@code equals()} and {@code hashCode()} implemented, so implementations of this interface
* can be used as keys.
*
* @since 4.0.0
*/
@Experimental
@Immutable
public enum DependencyScope {

/**
* None. Allows you to declare dependencies (for example to alter reactor build order) but in reality dependencies
* in this scope are not part of any build path scope.
*/
NONE("none", false),

/**
* Empty scope.
*/
EMPTY("", false),

/**
* Compile only.
*/
COMPILE_ONLY("compile-only", false),

/**
* Compile.
*/
COMPILE("compile", true),

/**
* Runtime.
*/
RUNTIME("runtime", true),

/**
* Provided.
*/
PROVIDED("provided", false),

/**
* Test compile only.
*/
TEST_ONLY("test-only", false),

/**
* Test.
*/
TEST("test", false),

/**
* Test runtime.
*/
TEST_RUNTIME("test-runtime", true),

/**
* System scope.
* <p>
* Important: this scope {@code id} MUST BE KEPT in sync with label in
* {@code org.eclipse.aether.util.artifact.Scopes#SYSTEM}.
*/
SYSTEM("system", false);

private static final Map<String, DependencyScope> IDS = Collections.unmodifiableMap(
Stream.of(DependencyScope.values()).collect(Collectors.toMap(s -> s.id, s -> s)));

public static DependencyScope forId(String id) {
return IDS.get(id);
}

private final String id;
private final boolean transitive;

DependencyScope(String id, boolean transitive) {
this.id = id;
this.transitive = transitive;
}

/**
* The {@code id} uniquely represents a value for this extensible enum.
* This id should be used to compute the equality and hash code for the instance.
*
* @return the id
*/
@Nonnull
public String id() {
return id;
}

public boolean isTransitive() {
return transitive;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.api;

import org.apache.maven.api.annotations.Nonnull;

/**
* Interface that defines some kind of enums that can be extended by Maven plugins or extensions.
*
* Implementation must have {@code equals()} and {@code hashCode()} implemented, so implementations of this interface
* can be used as keys.
*/
public interface ExtensibleEnum {

/**
* The {@code id} uniquely represents a value for this extensible enum.
* This id should be used to compute the equality and hash code for the instance.
*
* @return the id
*/
@Nonnull
String id();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.api;

import java.util.*;

abstract class ExtensibleEnums {

static Language language(String id) {
return new DefaultLanguage(id);
}

static PathScope pathScope(String id, ProjectScope projectScope, DependencyScope... dependencyScopes) {
return new DefaultPathScope(id, projectScope, dependencyScopes);
}

static ProjectScope projectScope(String id) {
return new DefaultProjectScope(id);
}

private static class DefaultExtensibleEnum implements ExtensibleEnum {

private final String id;

DefaultExtensibleEnum(String id) {
this.id = Objects.requireNonNull(id);
}

public String id() {
return id;
}

@Override
public int hashCode() {
return id().hashCode();
}

@Override
public boolean equals(Object obj) {
return obj != null && getClass() == obj.getClass() && id().equals(((DefaultExtensibleEnum) obj).id());
}

@Override
public String toString() {
return getClass().getSimpleName() + "[" + id() + "]";
}
}

private static class DefaultPathScope extends DefaultExtensibleEnum implements PathScope {
private final ProjectScope projectScope;
private final Set<DependencyScope> dependencyScopes;

DefaultPathScope(String id, ProjectScope projectScope, DependencyScope... dependencyScopes) {
super(id);
this.projectScope = Objects.requireNonNull(projectScope);
this.dependencyScopes =
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(Objects.requireNonNull(dependencyScopes))));
}

@Override
public ProjectScope projectScope() {
return projectScope;
}

@Override
public Set<DependencyScope> dependencyScopes() {
return dependencyScopes;
}
}

private static class DefaultProjectScope extends DefaultExtensibleEnum implements ProjectScope {

DefaultProjectScope(String id) {
super(id);
}
}

private static class DefaultLanguage extends DefaultExtensibleEnum implements Language {

DefaultLanguage(String id) {
super(id);
}
}
}
Loading