-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract the caching part into plexus-components
- Loading branch information
Showing
8 changed files
with
193 additions
and
113 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
...aven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/DefaultHttpCacheConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.p2maven.transport; | ||
|
||
import java.io.File; | ||
|
||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.plugin.LegacySupport; | ||
import org.apache.maven.repository.RepositorySystem; | ||
import org.codehaus.plexus.component.annotations.Component; | ||
import org.codehaus.plexus.component.annotations.Requirement; | ||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; | ||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; | ||
|
||
@Component(role = HttpCacheConfig.class) | ||
public class DefaultHttpCacheConfig implements HttpCacheConfig, Initializable { | ||
|
||
private boolean offline; | ||
private boolean update; | ||
|
||
@Requirement | ||
private LegacySupport legacySupport; | ||
private File cacheLocation; | ||
|
||
@Override | ||
public void initialize() throws InitializationException { | ||
File repoDir; | ||
MavenSession session = legacySupport.getSession(); | ||
if (session == null) { | ||
repoDir = RepositorySystem.defaultUserLocalRepository; | ||
offline = false; | ||
update = false; | ||
} else { | ||
offline = session.isOffline(); | ||
repoDir = new File(session.getLocalRepository().getBasedir()); | ||
update = session.getRequest().isUpdateSnapshots(); | ||
} | ||
|
||
cacheLocation = new File(repoDir, ".cache/tycho"); | ||
cacheLocation.mkdirs(); | ||
} | ||
|
||
@Override | ||
public boolean isOffline() { | ||
return offline; | ||
} | ||
|
||
@Override | ||
public boolean isUpdate() { | ||
return update; | ||
} | ||
|
||
@Override | ||
public File getCacheLocation() { | ||
return cacheLocation; | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/HttpCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.p2maven.transport; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.net.URI; | ||
|
||
import org.codehaus.plexus.logging.Logger; | ||
|
||
public interface HttpCache { | ||
|
||
/** | ||
* Fetches the cache entry for this URI | ||
* | ||
* @param uri | ||
* @return | ||
* @throws FileNotFoundException | ||
* if the URI is know to be not found | ||
*/ | ||
CacheEntry getCacheEntry(URI uri, Logger logger) throws FileNotFoundException; | ||
|
||
HttpCacheConfig getCacheConfig(); | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/HttpCacheConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.p2maven.transport; | ||
|
||
import java.io.File; | ||
|
||
public interface HttpCacheConfig { | ||
|
||
boolean isOffline(); | ||
|
||
boolean isUpdate(); | ||
|
||
File getCacheLocation(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.