Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused class #1866

Merged
merged 1 commit into from
Nov 5, 2024
Merged
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 @@ -22,22 +22,18 @@

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

import org.apache.maven.api.RemoteRepository;
import org.apache.maven.api.Session;
import org.apache.maven.api.SessionData;
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.ModelBuilderRequest;
import org.apache.maven.api.services.ModelSource;
import org.apache.maven.api.services.model.ModelResolver;
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.execution.MavenExecutionRequest;
import org.apache.maven.internal.impl.InternalMavenSession;
Expand All @@ -60,15 +56,7 @@ public class ConsumerPomBuilderTest extends AbstractRepositoryTestCase {

@BeforeEach
void setupTransformerContext() throws Exception {
// We need to hack things a bit here to get the transformer context to work
// * 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
// We need bind the model resolver explicitly to avoid going to maven central
getContainer().lookup(Injector.class).bindImplicit(MyModelResolver.class);
InternalSession iSession = InternalSession.from(session);
// set up the model resolver
Expand Down Expand Up @@ -150,39 +138,4 @@ public ModelSource resolveModel(
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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* <p>
* 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 is similar to the {@code CIFriendlyVersionModelTransformer}.
*
* @since 4.0.0
*/
Expand Down