mirror of https://github.com/apache/maven.git
Remove unused class (#1866)
This commit is contained in:
parent
75258afcc6
commit
51123f3abc
|
@ -22,7 +22,6 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@ -30,14 +29,11 @@ import org.apache.maven.api.RemoteRepository;
|
||||||
import org.apache.maven.api.Session;
|
import org.apache.maven.api.Session;
|
||||||
import org.apache.maven.api.SessionData;
|
import org.apache.maven.api.SessionData;
|
||||||
import org.apache.maven.api.model.Model;
|
import org.apache.maven.api.model.Model;
|
||||||
import org.apache.maven.api.model.Parent;
|
|
||||||
import org.apache.maven.api.services.ModelBuilder;
|
import org.apache.maven.api.services.ModelBuilder;
|
||||||
import org.apache.maven.api.services.ModelBuilderRequest;
|
import org.apache.maven.api.services.ModelBuilderRequest;
|
||||||
import org.apache.maven.api.services.ModelSource;
|
import org.apache.maven.api.services.ModelSource;
|
||||||
import org.apache.maven.api.services.model.ModelResolver;
|
import org.apache.maven.api.services.model.ModelResolver;
|
||||||
import org.apache.maven.api.services.model.ModelResolverException;
|
import org.apache.maven.api.services.model.ModelResolverException;
|
||||||
import org.apache.maven.api.spi.ModelTransformer;
|
|
||||||
import org.apache.maven.api.spi.ModelTransformerException;
|
|
||||||
import org.apache.maven.di.Injector;
|
import org.apache.maven.di.Injector;
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
import org.apache.maven.internal.impl.InternalMavenSession;
|
import org.apache.maven.internal.impl.InternalMavenSession;
|
||||||
|
@ -60,15 +56,7 @@ public class ConsumerPomBuilderTest extends AbstractRepositoryTestCase {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setupTransformerContext() throws Exception {
|
void setupTransformerContext() throws Exception {
|
||||||
// We need to hack things a bit here to get the transformer context to work
|
// We need bind the model resolver explicitly to avoid going to maven central
|
||||||
// * we cannot use the CIFriendlyVersionModelTransformer directly because
|
|
||||||
// it's a session scoped bean and all tests using a model builder would have
|
|
||||||
// to use a session and initialize the scope in order for DI to start
|
|
||||||
// * the transformer context is supposed to be immutable but in this case
|
|
||||||
// we don't build the full projects before, so we need to pass a mutable
|
|
||||||
// context to the model builder
|
|
||||||
// * we also need to bind the model resolver explicitly to avoid going
|
|
||||||
// to maven central
|
|
||||||
getContainer().lookup(Injector.class).bindImplicit(MyModelResolver.class);
|
getContainer().lookup(Injector.class).bindImplicit(MyModelResolver.class);
|
||||||
InternalSession iSession = InternalSession.from(session);
|
InternalSession iSession = InternalSession.from(session);
|
||||||
// set up the model resolver
|
// set up the model resolver
|
||||||
|
@ -150,39 +138,4 @@ public class ConsumerPomBuilderTest extends AbstractRepositoryTestCase {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CIFriendlyVersionModelTransformer implements ModelTransformer {
|
|
||||||
private static final String SHA1_PROPERTY = "sha1";
|
|
||||||
private static final String CHANGELIST_PROPERTY = "changelist";
|
|
||||||
private static final String REVISION_PROPERTY = "revision";
|
|
||||||
private final Session session;
|
|
||||||
|
|
||||||
CIFriendlyVersionModelTransformer(Session session) {
|
|
||||||
this.session = session;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Model transformFileModel(Model model) throws ModelTransformerException {
|
|
||||||
return model.with()
|
|
||||||
.version(replaceCiFriendlyVersion(model.getVersion()))
|
|
||||||
.parent(replaceParent(model.getParent()))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
Parent replaceParent(Parent parent) {
|
|
||||||
return parent != null ? parent.withVersion(replaceCiFriendlyVersion(parent.getVersion())) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String replaceCiFriendlyVersion(String version) {
|
|
||||||
if (version != null) {
|
|
||||||
for (String key : Arrays.asList(SHA1_PROPERTY, CHANGELIST_PROPERTY, REVISION_PROPERTY)) {
|
|
||||||
String val = session.getUserProperties().get(key);
|
|
||||||
if (val != null) {
|
|
||||||
version = version.replace("${" + key + "}", val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.apache.maven.api.annotations.Nonnull;
|
||||||
* <p>
|
* <p>
|
||||||
* The cache implementation could be annotated with {@code SessionScoped} to be created once per session, but
|
* The cache implementation could be annotated with {@code SessionScoped} to be created once per session, but
|
||||||
* this would make tests more complicated to write as they would all need to enter the session scope.
|
* this would make tests more complicated to write as they would all need to enter the session scope.
|
||||||
* This is similar to the {@code CIFriendlyVersionModelTransformer}.
|
|
||||||
*
|
*
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue