Skip to content

Commit d27413a

Browse files
author
Vincent Potucek
committed
Pull #2293: Modernize codebase with Java improvements - remove dead code
1 parent d65c375 commit d27413a

File tree

3 files changed

+0
-100
lines changed

3 files changed

+0
-100
lines changed

api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyResolverResult.java

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@
1818
*/
1919
package org.apache.maven.api.services;
2020

21-
import java.io.IOException;
22-
import java.lang.module.ModuleDescriptor;
2321
import java.nio.file.Path;
2422
import java.util.List;
2523
import java.util.Map;
26-
import java.util.Optional;
2724

2825
import org.apache.maven.api.Dependency;
29-
import org.apache.maven.api.DependencyScope;
30-
import org.apache.maven.api.JavaPathType;
3126
import org.apache.maven.api.Node;
3227
import org.apache.maven.api.PathType;
3328
import org.apache.maven.api.annotations.Experimental;
@@ -102,45 +97,4 @@ public interface DependencyResolverResult extends Result<DependencyResolverReque
10297
*/
10398
@Nonnull
10499
Map<Dependency, Path> getDependencies();
105-
106-
/**
107-
* Returns the Java module name of the dependency at the given path.
108-
* The given dependency should be one of the paths returned by {@link #getDependencies()}.
109-
* The module name is extracted from the {@code module-info.class} file if present, otherwise from
110-
* the {@code "Automatic-Module-Name"} attribute of the {@code META-INF/MANIFEST.MF} file if present.
111-
*
112-
* <p>A typical usage is to invoke this method for all dependencies having a
113-
* {@link DependencyScope#TEST TEST} or {@link DependencyScope#TEST_ONLY TEST_ONLY}
114-
* {@linkplain Dependency#getScope() scope}. An {@code --add-reads} option may need
115-
* to be generated for compiling and running the test classes that use such dependencies.</p>
116-
*
117-
* @param dependency path to the dependency for which to get the module name
118-
* @return module name of the dependency at the given path, or empty if the dependency is not modular
119-
* @throws IOException if the module information of the specified dependency cannot be read
120-
*/
121-
Optional<String> getModuleName(@Nonnull Path dependency) throws IOException;
122-
123-
/**
124-
* Returns the Java module descriptor of the dependency at the given path.
125-
* The given dependency should be one of the paths returned by {@link #getDependencies()}.
126-
* The module descriptor is extracted from the {@code module-info.class} file if present.
127-
*
128-
* <p>{@link #getModuleName(Path)} is preferred when only the module name is desired,
129-
* because a name may be present even if the descriptor is absent. This method is for
130-
* cases when more information is desired, such as the set of exported packages.</p>
131-
*
132-
* @param dependency path to the dependency for which to get the module name
133-
* @return module name of the dependency at the given path, or empty if the dependency is not modular
134-
* @throws IOException if the module information of the specified dependency cannot be read
135-
*/
136-
Optional<ModuleDescriptor> getModuleDescriptor(@Nonnull Path dependency) throws IOException;
137-
138-
/**
139-
* If the module path contains at least one filename-based auto-module, prepares a warning message.
140-
* The module path is the collection of dependencies associated with {@link JavaPathType#MODULES}.
141-
* It is caller's responsibility to send the message to a logger.
142-
*
143-
* @return warning message if at least one filename-based auto-module was found
144-
*/
145-
Optional<String> warningForFilenameBasedAutomodules();
146100
}

impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultDependencyResolverResult.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@
2727
import java.util.LinkedHashMap;
2828
import java.util.List;
2929
import java.util.Map;
30-
import java.util.Optional;
3130
import java.util.Set;
3231
import java.util.function.Predicate;
3332

3433
import org.apache.maven.api.Dependency;
3534
import org.apache.maven.api.JavaPathType;
3635
import org.apache.maven.api.Node;
3736
import org.apache.maven.api.PathType;
38-
import org.apache.maven.api.services.DependencyResolverException;
3937
import org.apache.maven.api.services.DependencyResolverRequest;
4038
import org.apache.maven.api.services.DependencyResolverResult;
4139

@@ -378,18 +376,6 @@ public Map<Dependency, Path> getDependencies() {
378376
return dependencies;
379377
}
380378

381-
@Override
382-
public Optional<ModuleDescriptor> getModuleDescriptor(Path dependency) throws IOException {
383-
Object value = cache.getModuleInfo(dependency).descriptors.get(dependency);
384-
return (value instanceof ModuleDescriptor moduleDescriptor) ? Optional.of(moduleDescriptor) : Optional.empty();
385-
}
386-
387-
@Override
388-
public Optional<String> getModuleName(Path dependency) throws IOException {
389-
return Optional.ofNullable(
390-
name(cache.getModuleInfo(dependency).descriptors.get(dependency)));
391-
}
392-
393379
/**
394380
* Returns the module name for the given value of the {@link PathModularization#descriptors} map.
395381
*/
@@ -402,13 +388,4 @@ private static String name(final Object value) {
402388
return null;
403389
}
404390
}
405-
406-
@Override
407-
public Optional<String> warningForFilenameBasedAutomodules() {
408-
try {
409-
return cache.warningForFilenameBasedAutomodules(dispatchedPaths.get(JavaPathType.MODULES));
410-
} catch (IOException e) {
411-
throw new DependencyResolverException("Cannot read module information.", e);
412-
}
413-
}
414391
}

impl/maven-impl/src/main/java/org/apache/maven/impl/PathModularizationCache.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@
2020

2121
import java.io.IOException;
2222
import java.nio.file.Path;
23-
import java.util.ArrayList;
24-
import java.util.Collection;
2523
import java.util.HashMap;
2624
import java.util.Map;
2725
import java.util.Optional;
2826
import java.util.Set;
29-
import java.util.StringJoiner;
3027
import java.util.function.Predicate;
3128

3229
import org.apache.maven.api.JavaPathType;
@@ -158,32 +155,4 @@ Optional<PathType> selectPathType(Set<PathType> types, Predicate<PathType> filte
158155
}
159156
return Optional.ofNullable(selected);
160157
}
161-
162-
/**
163-
* If the module-path contains a filename-based auto-module, prepares a warning message.
164-
* It is caller's responsibility to send the message to a logger.
165-
*
166-
* @param modulePaths content of the module path, or {@code null} if none
167-
* @return warning message if at least one filename-based auto-module was found
168-
* @throws IOException if an error occurred while reading module information
169-
*/
170-
Optional<String> warningForFilenameBasedAutomodules(Collection<Path> modulePaths) throws IOException {
171-
if (modulePaths == null) {
172-
return Optional.empty();
173-
}
174-
var automodulesDetected = new ArrayList<String>();
175-
for (Path p : modulePaths) {
176-
getModuleInfo(p).addIfFilenameBasedAutomodules(automodulesDetected);
177-
}
178-
if (automodulesDetected.isEmpty()) {
179-
return Optional.empty();
180-
}
181-
String lineSeparator = System.lineSeparator();
182-
var joiner = new StringJoiner(
183-
lineSeparator + " - ",
184-
"Filename-based automodules detected on the module path: " + lineSeparator + " - ",
185-
lineSeparator + "Please don't publish this project to a public artifact repository.");
186-
automodulesDetected.forEach(joiner::add);
187-
return Optional.of(joiner.toString());
188-
}
189158
}

0 commit comments

Comments
 (0)