| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.extension.repository.aether.internal; |
| 21 |
|
|
| 22 |
|
import java.io.File; |
| 23 |
|
import java.io.IOException; |
| 24 |
|
import java.util.Map; |
| 25 |
|
|
| 26 |
|
import org.apache.commons.io.FileUtils; |
| 27 |
|
import org.apache.maven.repository.internal.MavenRepositorySystemUtils; |
| 28 |
|
import org.eclipse.aether.AbstractForwardingRepositorySystemSession; |
| 29 |
|
import org.eclipse.aether.ConfigurationProperties; |
| 30 |
|
import org.eclipse.aether.DefaultRepositorySystemSession; |
| 31 |
|
import org.eclipse.aether.RepositorySystem; |
| 32 |
|
import org.eclipse.aether.RepositorySystemSession; |
| 33 |
|
import org.eclipse.aether.artifact.ArtifactTypeRegistry; |
| 34 |
|
import org.eclipse.aether.artifact.DefaultArtifactType; |
| 35 |
|
import org.eclipse.aether.repository.LocalRepository; |
| 36 |
|
import org.eclipse.aether.util.artifact.DefaultArtifactTypeRegistry; |
| 37 |
|
import org.eclipse.aether.util.repository.JreProxySelector; |
| 38 |
|
import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy; |
| 39 |
|
import org.xwiki.extension.internal.maven.MavenUtils; |
| 40 |
|
|
| 41 |
|
import com.google.common.io.Files; |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
@link |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
@version |
| 48 |
|
@since |
| 49 |
|
|
| |
|
| 93.3% |
Uncovered Elements: 2 (30) |
Complexity: 8 |
Complexity Density: 0.38 |
|
| 50 |
|
public class XWikiRepositorySystemSession extends AbstractForwardingRepositorySystemSession implements AutoCloseable |
| 51 |
|
{ |
| 52 |
|
static final JreProxySelector JREPROXYSELECTOR = new JreProxySelector(); |
| 53 |
|
|
| 54 |
|
private final DefaultRepositorySystemSession session; |
| 55 |
|
|
| 56 |
|
|
| 57 |
|
@param |
| 58 |
|
|
| |
|
| 93.3% |
Uncovered Elements: 1 (15) |
Complexity: 2 |
Complexity Density: 0.15 |
|
| 59 |
126 |
public XWikiRepositorySystemSession(RepositorySystem repositorySystem)... |
| 60 |
|
{ |
| 61 |
126 |
this.session = MavenRepositorySystemUtils.newSession(); |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
126 |
File localDir = Files.createTempDir(); |
| 66 |
126 |
LocalRepository localRepository = new LocalRepository(localDir); |
| 67 |
126 |
this.session |
| 68 |
|
.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(this.session, localRepository)); |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
126 |
this.session.setProxySelector(JREPROXYSELECTOR); |
| 73 |
|
|
| 74 |
|
|
| 75 |
126 |
this.session.setSystemProperty("version", null); |
| 76 |
126 |
this.session.setSystemProperty("groupId", null); |
| 77 |
|
|
| 78 |
|
|
| 79 |
126 |
ArtifactTypeRegistry artifactTypeRegistry = this.session.getArtifactTypeRegistry(); |
| 80 |
126 |
if (artifactTypeRegistry instanceof DefaultArtifactTypeRegistry) { |
| 81 |
126 |
DefaultArtifactTypeRegistry defaultArtifactTypeRegistry = |
| 82 |
|
(DefaultArtifactTypeRegistry) artifactTypeRegistry; |
| 83 |
126 |
defaultArtifactTypeRegistry |
| 84 |
|
.add(new DefaultArtifactType("bundle", MavenUtils.JAR_EXTENSION, "", MavenUtils.JAVA_LANGUAGE)); |
| 85 |
126 |
defaultArtifactTypeRegistry |
| 86 |
|
.add(new DefaultArtifactType("eclipse-plugin", MavenUtils.JAR_EXTENSION, "", MavenUtils.JAVA_LANGUAGE)); |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
|
| 90 |
126 |
this.session.setArtifactDescriptorPolicy(new SimpleArtifactDescriptorPolicy(false, false)); |
| 91 |
|
} |
| 92 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 93 |
11296 |
@Override... |
| 94 |
|
protected RepositorySystemSession getSession() |
| 95 |
|
{ |
| 96 |
11297 |
return this.session; |
| 97 |
|
} |
| 98 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 99 |
139 |
@Override... |
| 100 |
|
public void close() |
| 101 |
|
{ |
| 102 |
139 |
LocalRepository repository = this.session.getLocalRepository(); |
| 103 |
|
|
| 104 |
139 |
if (repository.getBasedir().exists()) { |
| 105 |
126 |
try { |
| 106 |
126 |
FileUtils.deleteDirectory(repository.getBasedir()); |
| 107 |
|
} catch (IOException e) { |
| 108 |
|
|
| 109 |
|
} |
| 110 |
|
} |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
|
| 114 |
|
@param |
| 115 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 116 |
126 |
public void setUserAgent(String userAgent)... |
| 117 |
|
{ |
| 118 |
126 |
this.session.setConfigProperty(ConfigurationProperties.USER_AGENT, userAgent); |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
@param |
| 123 |
|
|
| |
|
| 50% |
Uncovered Elements: 1 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 124 |
126 |
public void addConfigurationProperties(Map<String, String> properties)... |
| 125 |
|
{ |
| 126 |
126 |
for (Map.Entry<String, String> entry : properties.entrySet()) { |
| 127 |
0 |
this.session.setConfigProperty(entry.getKey(), entry.getValue()); |
| 128 |
|
} |
| 129 |
|
} |
| 130 |
|
} |