Rename ...cache.impl.Cli* to ...cache.invalidating.Invalidating*,

move CacheFactory implementations to org.mvndaemon.mvnd.cache.impl
This commit is contained in:
Peter Palaga
2021-01-24 15:22:24 +01:00
parent 3cd726b864
commit b2f50127f6
15 changed files with 68 additions and 59 deletions

View File

@@ -94,10 +94,10 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.transfer.TransferListener;
import org.mvndaemon.mvnd.cache.impl.CliExtensionRealmCache;
import org.mvndaemon.mvnd.cache.impl.CliPluginArtifactsCache;
import org.mvndaemon.mvnd.cache.impl.CliPluginRealmCache;
import org.mvndaemon.mvnd.cache.impl.CliProjectArtifactsCache;
import org.mvndaemon.mvnd.cache.invalidating.InvalidatingExtensionRealmCache;
import org.mvndaemon.mvnd.cache.invalidating.InvalidatingPluginArtifactsCache;
import org.mvndaemon.mvnd.cache.invalidating.InvalidatingPluginRealmCache;
import org.mvndaemon.mvnd.cache.invalidating.InvalidatingProjectArtifactsCache;
import org.mvndaemon.mvnd.common.Environment;
import org.mvndaemon.mvnd.logging.internal.Slf4jLoggerManager;
import org.mvndaemon.mvnd.logging.smart.BuildEventListener;
@@ -503,10 +503,10 @@ public class DaemonMavenCli {
protected void configure() {
bind(ILoggerFactory.class).toInstance(slf4jLoggerFactory);
bind(CoreExports.class).toInstance(exports);
bind(ExtensionRealmCache.class).to(CliExtensionRealmCache.class);
bind(PluginArtifactsCache.class).to(CliPluginArtifactsCache.class);
bind(PluginRealmCache.class).to(CliPluginRealmCache.class);
bind(ProjectArtifactsCache.class).to(CliProjectArtifactsCache.class);
bind(ExtensionRealmCache.class).to(InvalidatingExtensionRealmCache.class);
bind(PluginArtifactsCache.class).to(InvalidatingPluginArtifactsCache.class);
bind(PluginRealmCache.class).to(InvalidatingPluginRealmCache.class);
bind(ProjectArtifactsCache.class).to(InvalidatingProjectArtifactsCache.class);
bind(MavenPluginManager.class).to(CliMavenPluginManager.class);
}
});

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.factory;
package org.mvndaemon.mvnd.cache;
import java.util.function.BiPredicate;
import java.util.function.Function;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.factory;
package org.mvndaemon.mvnd.cache;
/**
* A factory for cache objects

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.factory;
package org.mvndaemon.mvnd.cache;
import java.nio.file.Path;
import java.util.stream.Stream;

View File

@@ -13,11 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.factory;
package org.mvndaemon.mvnd.cache.impl;
import javax.inject.Named;
import javax.inject.Singleton;
import org.eclipse.sisu.Priority;
import org.mvndaemon.mvnd.cache.Cache;
import org.mvndaemon.mvnd.cache.CacheFactory;
import org.mvndaemon.mvnd.cache.CacheRecord;
import org.mvndaemon.mvnd.common.Os;
@Named

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.factory;
package org.mvndaemon.mvnd.cache.impl;
import java.io.IOException;
import java.nio.file.Files;
@@ -29,6 +29,9 @@ import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.mvndaemon.mvnd.cache.Cache;
import org.mvndaemon.mvnd.cache.CacheFactory;
import org.mvndaemon.mvnd.cache.CacheRecord;
/**
* A factory for {@link Cache} objects invalidating its entries based on {@link BasicFileAttributes#lastModifiedTime()}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.factory;
package org.mvndaemon.mvnd.cache.impl;
import java.io.IOException;
import java.nio.file.FileSystems;
@@ -31,6 +31,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiPredicate;
import java.util.function.Function;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.mvndaemon.mvnd.cache.Cache;
import org.mvndaemon.mvnd.cache.CacheFactory;
import org.mvndaemon.mvnd.cache.CacheRecord;
/**
* A factory for {@link Cache} objects invalidating its entries based on events received from {@link WatchService}.

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.impl;
package org.mvndaemon.mvnd.cache.invalidating;
import java.nio.file.Path;
import java.util.List;
@@ -27,14 +27,14 @@ import org.apache.maven.project.ExtensionDescriptor;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
import org.mvndaemon.mvnd.cache.factory.Cache;
import org.mvndaemon.mvnd.cache.factory.CacheFactory;
import org.mvndaemon.mvnd.cache.Cache;
import org.mvndaemon.mvnd.cache.CacheFactory;
@Singleton
@Named
public class CliExtensionRealmCache extends DefaultExtensionRealmCache {
public class InvalidatingExtensionRealmCache extends DefaultExtensionRealmCache {
protected static class Record implements org.mvndaemon.mvnd.cache.factory.CacheRecord {
protected static class Record implements org.mvndaemon.mvnd.cache.CacheRecord {
private final CacheRecord record;
@@ -61,7 +61,7 @@ public class CliExtensionRealmCache extends DefaultExtensionRealmCache {
private final Cache<Key, Record> cache;
@Inject
public CliExtensionRealmCache(CacheFactory cacheFactory) {
public InvalidatingExtensionRealmCache(CacheFactory cacheFactory) {
cache = cacheFactory.newCache();
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.impl;
package org.mvndaemon.mvnd.cache.invalidating;
import java.nio.file.Path;
import java.util.List;
@@ -23,14 +23,14 @@ import javax.inject.Singleton;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.DefaultPluginArtifactsCache;
import org.apache.maven.plugin.PluginResolutionException;
import org.mvndaemon.mvnd.cache.factory.Cache;
import org.mvndaemon.mvnd.cache.factory.CacheFactory;
import org.mvndaemon.mvnd.cache.Cache;
import org.mvndaemon.mvnd.cache.CacheFactory;
@Singleton
@Named
public class CliPluginArtifactsCache extends DefaultPluginArtifactsCache {
public class InvalidatingPluginArtifactsCache extends DefaultPluginArtifactsCache {
protected static class Record implements org.mvndaemon.mvnd.cache.factory.CacheRecord {
protected static class Record implements org.mvndaemon.mvnd.cache.CacheRecord {
private final CacheRecord record;
@@ -50,7 +50,7 @@ public class CliPluginArtifactsCache extends DefaultPluginArtifactsCache {
final Cache<Key, Record> cache;
public CliPluginArtifactsCache(CacheFactory cacheFactory) {
public InvalidatingPluginArtifactsCache(CacheFactory cacheFactory) {
this.cache = cacheFactory.newCache();
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.impl;
package org.mvndaemon.mvnd.cache.invalidating;
import java.nio.file.Path;
import java.util.Collections;
@@ -33,13 +33,13 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;
import org.mvndaemon.mvnd.cache.factory.Cache;
import org.mvndaemon.mvnd.cache.factory.CacheFactory;
import org.mvndaemon.mvnd.cache.factory.CacheRecord;
import org.mvndaemon.mvnd.cache.Cache;
import org.mvndaemon.mvnd.cache.CacheFactory;
import org.mvndaemon.mvnd.cache.CacheRecord;
@Singleton
@Named
public class CliPluginDescriptorCache extends DefaultPluginDescriptorCache {
public class InvalidatingPluginDescriptorCache extends DefaultPluginDescriptorCache {
@FunctionalInterface
public interface PluginDescriptorSupplier {
@@ -75,7 +75,7 @@ public class CliPluginDescriptorCache extends DefaultPluginDescriptorCache {
final Cache<Key, Record> cache;
@Inject
public CliPluginDescriptorCache(CacheFactory cacheFactory) {
public InvalidatingPluginDescriptorCache(CacheFactory cacheFactory) {
this.cache = cacheFactory.newCache();
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.impl;
package org.mvndaemon.mvnd.cache.invalidating;
import java.nio.file.Path;
import java.util.List;
@@ -31,21 +31,21 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
import org.eclipse.sisu.Priority;
import org.eclipse.sisu.Typed;
import org.mvndaemon.mvnd.cache.factory.Cache;
import org.mvndaemon.mvnd.cache.factory.CacheFactory;
import org.mvndaemon.mvnd.cache.Cache;
import org.mvndaemon.mvnd.cache.CacheFactory;
@Singleton
@Named
@Priority(10)
@Typed(PluginRealmCache.class)
public class CliPluginRealmCache extends DefaultPluginRealmCache {
public class InvalidatingPluginRealmCache extends DefaultPluginRealmCache {
@FunctionalInterface
public interface PluginRealmSupplier {
CacheRecord load() throws PluginResolutionException, PluginContainerException;
}
protected static class Record implements org.mvndaemon.mvnd.cache.factory.CacheRecord {
protected static class Record implements org.mvndaemon.mvnd.cache.CacheRecord {
final CacheRecord record;
@@ -72,7 +72,7 @@ public class CliPluginRealmCache extends DefaultPluginRealmCache {
final Cache<Key, Record> cache;
@Inject
public CliPluginRealmCache(CacheFactory cacheFactory) {
public InvalidatingPluginRealmCache(CacheFactory cacheFactory) {
cache = cacheFactory.newCache();
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.impl;
package org.mvndaemon.mvnd.cache.invalidating;
import java.net.URISyntaxException;
import java.net.URL;
@@ -33,15 +33,15 @@ import org.slf4j.LoggerFactory;
@Named
@Singleton
@Typed(EventSpy.class)
public class CliPluginRealmCacheEventSpy extends AbstractEventSpy {
public class InvalidatingPluginRealmCacheEventSpy extends AbstractEventSpy {
private static final Logger LOG = LoggerFactory.getLogger(CliPluginRealmCacheEventSpy.class);
private static final Logger LOG = LoggerFactory.getLogger(InvalidatingPluginRealmCacheEventSpy.class);
private final CliPluginRealmCache cache;
private final InvalidatingPluginRealmCache cache;
private Path multiModuleProjectDirectory;
@Inject
public CliPluginRealmCacheEventSpy(CliPluginRealmCache cache) {
public InvalidatingPluginRealmCacheEventSpy(InvalidatingPluginRealmCache cache) {
this.cache = cache;
}
@@ -60,7 +60,7 @@ public class CliPluginRealmCacheEventSpy extends AbstractEventSpy {
}
}
private boolean shouldEvict(CliPluginRealmCache.Key k, CliPluginRealmCache.Record v) {
private boolean shouldEvict(InvalidatingPluginRealmCache.Key k, InvalidatingPluginRealmCache.Record v) {
try {
for (URL url : v.record.getRealm().getURLs()) {
if (url.getProtocol().equals("file")) {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.impl;
package org.mvndaemon.mvnd.cache.invalidating;
import java.io.File;
import java.nio.file.Path;
@@ -27,14 +27,14 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.DefaultProjectArtifactsCache;
import org.mvndaemon.mvnd.cache.factory.Cache;
import org.mvndaemon.mvnd.cache.factory.CacheFactory;
import org.mvndaemon.mvnd.cache.Cache;
import org.mvndaemon.mvnd.cache.CacheFactory;
@Singleton
@Named
public class CliProjectArtifactsCache extends DefaultProjectArtifactsCache {
public class InvalidatingProjectArtifactsCache extends DefaultProjectArtifactsCache {
static class Record implements org.mvndaemon.mvnd.cache.factory.CacheRecord {
static class Record implements org.mvndaemon.mvnd.cache.CacheRecord {
private final CacheRecord record;
public Record(CacheRecord record) {
@@ -57,7 +57,7 @@ public class CliProjectArtifactsCache extends DefaultProjectArtifactsCache {
final Cache<Key, Record> cache;
@Inject
public CliProjectArtifactsCache(CacheFactory cacheFactory) {
public InvalidatingProjectArtifactsCache(CacheFactory cacheFactory) {
this.cache = cacheFactory.newCache();
}

View File

@@ -108,8 +108,8 @@ import org.eclipse.aether.util.filter.AndDependencyFilter;
import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator;
import org.eclipse.sisu.Priority;
import org.eclipse.sisu.Typed;
import org.mvndaemon.mvnd.cache.impl.CliPluginDescriptorCache;
import org.mvndaemon.mvnd.cache.impl.CliPluginRealmCache;
import org.mvndaemon.mvnd.cache.invalidating.InvalidatingPluginDescriptorCache;
import org.mvndaemon.mvnd.cache.invalidating.InvalidatingPluginRealmCache;
/*
* gnodet: This file is based on maven DefaultMavenPluginManager and changed in order
@@ -154,10 +154,10 @@ public class CliMavenPluginManager
private ClassRealmManager classRealmManager;
@Inject
private CliPluginDescriptorCache pluginDescriptorCache;
private InvalidatingPluginDescriptorCache pluginDescriptorCache;
@Inject
private CliPluginRealmCache pluginRealmCache;
private InvalidatingPluginRealmCache pluginRealmCache;
@Inject
private PluginDependenciesResolver pluginDependenciesResolver;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvndaemon.mvnd.cache.impl;
package org.mvndaemon.mvnd.cache.factory.impl;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -25,9 +25,9 @@ import java.util.stream.Stream;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.mvndaemon.mvnd.cache.factory.Cache;
import org.mvndaemon.mvnd.cache.factory.CacheRecord;
import org.mvndaemon.mvnd.cache.factory.DefaultCacheFactory;
import org.mvndaemon.mvnd.cache.Cache;
import org.mvndaemon.mvnd.cache.CacheRecord;
import org.mvndaemon.mvnd.cache.impl.DefaultCacheFactory;
import org.mvndaemon.mvnd.common.Os;
public class TimestampCacheFactoryTest {
@@ -79,7 +79,7 @@ public class TimestampCacheFactoryTest {
Assertions.assertTrue(record2.invalidated);
}
static class SimpleCacheRecord implements org.mvndaemon.mvnd.cache.factory.CacheRecord {
static class SimpleCacheRecord implements org.mvndaemon.mvnd.cache.CacheRecord {
private final List<Path> paths;
private boolean invalidated = false;