new DefaultMetadata( pluginGroup, "maven-metadata.xml", DefaultMetadata.Nature.RELEASE_OR_SNAPSHOT );
new DefaultMetadata( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(), MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT );
private PluginVersionResult resolveFromRepository( PluginVersionRequest request ) throws PluginVersionResolutionException { RequestTrace trace = RequestTrace.newChild( null, request ); DefaultPluginVersionResult result = new DefaultPluginVersionResult(); org.eclipse.aether.metadata.Metadata metadata = new DefaultMetadata( request.getGroupId(), request.getArtifactId(), "maven-metadata.xml", DefaultMetadata.Nature.RELEASE_OR_SNAPSHOT ); List<MetadataRequest> requests = new ArrayList<>(); requests.add( new MetadataRequest( metadata, null, REPOSITORY_CONTEXT ).setTrace( trace ) ); for ( RemoteRepository repository : request.getRepositories() ) { requests.add( new MetadataRequest( metadata, repository, REPOSITORY_CONTEXT ).setTrace( trace ) ); } List<MetadataResult> results = repositorySystem.resolveMetadata( request.getRepositorySession(), requests ); Versions versions = new Versions(); for ( MetadataResult res : results ) { ArtifactRepository repository = res.getRequest().getRepository(); if ( repository == null ) { repository = request.getRepositorySession().getLocalRepository(); } mergeMetadata( request.getRepositorySession(), trace, versions, res.getMetadata(), repository ); } selectVersion( result, request, versions ); return result; }
metadata = new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML, Metadata.Nature.RELEASE ); metadata = new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT ); new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), version, MAVEN_METADATA_XML, Metadata.Nature.SNAPSHOT );
/** * Converts the path of the request to {@link Metadata}. * * @param path The request path, following the format: {@code <groupId>/<artifactId>/<version>/<artifactId>-<version>-[<classifier>].extension} * @return * @throws InvalidMavenArtifactRequest */ protected Metadata convertPathToMetadata(String path) throws InvalidMavenArtifactRequest { DefaultMetadata metadata = null; if (path == null) { throw new InvalidMavenArtifactRequest("Cannot match request path to maven url, request path is empty."); } Matcher pathMatcher = ARTIFACT_METADATA_URL_REGEX.matcher(path); if (pathMatcher.matches()) { String groupId = pathMatcher.group(1).replaceAll("/", "."); String artifactId = pathMatcher.group(2); String version = pathMatcher.group(3); String type = pathMatcher.group(9); if (type == null) { type = "maven-metadata.xml"; } else { type = "maven-metadata.xml." + type; } metadata = new DefaultMetadata(groupId, artifactId, version, type, Metadata.Nature.RELEASE_OR_SNAPSHOT); } return metadata; }
Metadata metadata = new DefaultMetadata("testGroup", "testArtifact", (i + 1) + "-test", "jar", Metadata.Nature.RELEASE_OR_SNAPSHOT, file); obj = new MetadataUpload(metadata, file); } else if (cls.isAssignableFrom(MetadataDownload.class)) { try { Metadata metadata = new DefaultMetadata("testGroup", "testArtifact", (i + 1) + "-test", "jar", Metadata.Nature.RELEASE_OR_SNAPSHOT, file); obj = new MetadataDownload(metadata, context, safeFile(file), checksumPolicy); } catch (IOException e) {
public void testFileHandleLeakage() throws IOException, NoRepositoryConnectorException { Artifact artifact = new DefaultArtifact("testGroup", "testArtifact", "", "jar", "1-test"); Metadata metadata = new DefaultMetadata("testGroup", "testArtifact", "1-test", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT); RepositoryConnector connector = factory.newInstance(session, repository); File tmpFile = TestFileUtils.createTempFile("testFileHandleLeakage"); ArtifactUpload artUp = new ArtifactUpload(artifact, tmpFile); connector.put(Arrays.asList(artUp), null); assertTrue("Leaking file handle in artifact upload", tmpFile.delete()); tmpFile = TestFileUtils.createTempFile("testFileHandleLeakage"); MetadataUpload metaUp = new MetadataUpload(metadata, tmpFile); connector.put(null, Arrays.asList(metaUp)); assertTrue("Leaking file handle in metadata upload", tmpFile.delete()); tmpFile = TestFileUtils.createTempFile("testFileHandleLeakage"); ArtifactDownload artDown = new ArtifactDownload(artifact, null, tmpFile, null); connector.get(Arrays.asList(artDown), null); new File(tmpFile.getAbsolutePath() + ".sha1").deleteOnExit(); assertTrue("Leaking file handle in artifact download", tmpFile.delete()); tmpFile = TestFileUtils.createTempFile("testFileHandleLeakage"); MetadataDownload metaDown = new MetadataDownload(metadata, null, tmpFile, null); connector.get(null, Arrays.asList(metaDown)); new File(tmpFile.getAbsolutePath() + ".sha1").deleteOnExit(); assertTrue("Leaking file handle in metadata download", tmpFile.delete()); connector.close(); }
private Metadata newInstance( Map<String, String> properties, File file ) { return new DefaultMetadata( getGroupId(), getArtifactId(), getVersion(), getType(), getNature(), file, properties ); }
private Metadata newInstance( Map<String, String> properties, File file ) { return new DefaultMetadata( getGroupId(), getArtifactId(), getVersion(), getType(), getNature(), file, properties ); }
/** * See https://issues.sonatype.org/browse/AETHER-8 */ public void testTransferZeroBytesFile() throws IOException, NoRepositoryConnectorException { File emptyFile = TestFileUtils.createTempFile(""); Artifact artifact = new DefaultArtifact("gid:aid:ext:ver"); ArtifactUpload upA = new ArtifactUpload(artifact, emptyFile); File dir = TestFileUtils.createTempDir("con-test"); File downAFile = new File(dir, "downA.file"); downAFile.deleteOnExit(); ArtifactDownload downA = new ArtifactDownload(artifact, "", downAFile, RepositoryPolicy.CHECKSUM_POLICY_FAIL); Metadata metadata = new DefaultMetadata("gid", "aid", "ver", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT); MetadataUpload upM = new MetadataUpload(metadata, emptyFile); File downMFile = new File(dir, "downM.file"); downMFile.deleteOnExit(); MetadataDownload downM = new MetadataDownload(metadata, "", downMFile, RepositoryPolicy.CHECKSUM_POLICY_FAIL); RepositoryConnector connector = factory.newInstance(session, repository); connector.put(Arrays.asList(upA), Arrays.asList(upM)); connector.get(Arrays.asList(downA), Arrays.asList(downM)); assertNull(String.valueOf(upA.getException()), upA.getException()); assertNull(String.valueOf(upM.getException()), upM.getException()); assertNull(String.valueOf(downA.getException()), downA.getException()); assertNull(String.valueOf(downM.getException()), downM.getException()); assertEquals(0, downAFile.length()); assertEquals(0, downMFile.length()); connector.close(); }
Metadata meta = new DefaultMetadata("testGroup", "testArtifact", i + "-test", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT); Metadata meta = new DefaultMetadata("testGroup", "testArtifact", i + "-test", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT);
ArtifactDownload downA = new ArtifactDownload(artifact, "", downAFile, RepositoryPolicy.CHECKSUM_POLICY_FAIL); Metadata metadata = new DefaultMetadata("gid", "aid", "ver", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT); MetadataUpload upM = new MetadataUpload(metadata, file); File downMFile = new File(dir, "downM.file");
@Override public String getPathForLocalMetadata( ProjectBuildingRequest buildingRequest, ArtifactMetadata metadata ) { Metadata aetherMetadata = new DefaultMetadata( metadata.getGroupId(), metadata.storedInGroupDirectory() ? null : metadata.getArtifactId(), metadata.storedInArtifactVersionDirectory() ? metadata.getBaseVersion() : null, "maven-metadata.xml", Nature.RELEASE_OR_SNAPSHOT ); RepositorySystemSession session; try { session = (RepositorySystemSession) Invoker.invoke( buildingRequest, "getRepositorySession" ); } catch ( RepositoryManagerException e ) { throw new RuntimeException( e.getMessage(), e ); } return session.getLocalRepositoryManager().getPathForLocalMetadata( aetherMetadata ); }
repositorySystem = MavenRepositoryUtilities.newRepositorySystem(); session = MavenRepositoryUtilities.newSession(repositorySystem, LOCAL_REPO); requestMetadata = new DefaultMetadata(a.getGroupId(), a.getArtifactId(), a.getVersion(), "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT);
new DefaultMetadata( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(), MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT );
new DefaultMetadata( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(), MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT );
new DefaultMetadata( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(), MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT );
new DefaultMetadata( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(), MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT );
metadata = new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML, Metadata.Nature.RELEASE ); metadata = new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT ); new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), version, MAVEN_METADATA_XML, Metadata.Nature.SNAPSHOT );
metadata = new DefaultMetadata("gid", "aid", "version", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT, null);