public static Artifact toArtifact( org.apache.maven.artifact.Artifact artifact ) { if ( artifact == null ) { return null; } String version = artifact.getVersion(); if ( version == null && artifact.getVersionRange() != null ) { version = artifact.getVersionRange().toString(); } Map<String, String> props = null; if ( org.apache.maven.artifact.Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) { String localPath = ( artifact.getFile() != null ) ? artifact.getFile().getPath() : ""; props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, localPath ); } Artifact result = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getArtifactHandler().getExtension(), version, props, newArtifactType( artifact.getType(), artifact.getArtifactHandler() ) ); result = result.setFile( artifact.getFile() ); return result; }
art = art.setFile( null ).setVersion( art.getBaseVersion() ); dep = dep.setArtifact( art );
@Override public Artifact setFile(File file) { return artifact.setFile(file); }
@Override public Artifact setFile(File file) { delegate = delegate.setFile(file); return this; }
public Artifact setFile( File file ) { Artifact artifact = delegate.setFile( file ); if ( artifact != delegate ) { return newInstance( artifact ); } return this; }
public Artifact setFile( File file ) { Artifact artifact = delegate.setFile( file ); if ( artifact != delegate ) { return newInstance( artifact ); } return this; }
public Artifact setFile(File file) { Artifact artifact = delegate.setFile(file); if (artifact != delegate) { return newInstance(artifact); } return this; }
public Artifact toAetherArtifact() { Artifact result = new DefaultArtifact(String.format("%s:%s:jar:%s", groupId, artifactId,version)); return result.setFile(file); }
private Artifact artifact(String content) throws IOException { Artifact artifact = new DefaultArtifact("gid", "aid", "classifier", "extension", "version", null); artifact.setFile(TestFileUtils.createTempFile(content)); return artifact; }
private static Artifact findProjectArtifact(MavenProject project) { String extension = project.getArtifact().getArtifactHandler().getExtension(); String fileName = project.getModel().getBuild().getFinalName() + "." + extension; File f = new File(new File(project.getBasedir(), "target"), fileName); if (f.exists()) { Artifact ret = RepositoryUtils.toArtifact(project.getArtifact()); return ret.setFile(f); } else { return null; } }
protected Artifact artifact(String content) throws IOException { return artifact().setFile(TestFileUtils.createTempFile(content)); }
/** * Deploys a file as artifact to a remote repository. * * @param spec <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version> * @param file artifact file * @throws DeploymentException */ public void deploy(String spec, File file) throws DeploymentException { DeployRequest request = new DeployRequest(); Artifact artifact = new DefaultArtifact(spec); artifact.setFile(file); request.setArtifacts(ImmutableList.of(artifact)); repositorySystem.deploy(session, request); }
private void deployPom(final GAV gav, final File pomFile) { //POM Artifact Artifact pomArtifact = new DefaultArtifact(gav.getGroupId(), gav.getArtifactId(), "pom", gav.getVersion()); pomArtifact = pomArtifact.setFile(pomFile); final Artifact finalPomArtifact = pomArtifact; this.pomRepositories.forEach(artifactRepository -> { artifactRepository.deploy(null, finalPomArtifact); }); }
private void deployPom(final GAV gav, final File pomFile) { //POM Artifact Artifact pomArtifact = new DefaultArtifact(gav.getGroupId(), gav.getArtifactId(), "pom", gav.getVersion()); pomArtifact = pomArtifact.setFile(pomFile); final Artifact finalPomArtifact = pomArtifact; this.pomRepositories.forEach(artifactRepository -> { artifactRepository.deploy(null, finalPomArtifact); }); }
private void deployPom(final GAV gav, final File pomFile) { //POM Artifact Artifact pomArtifact = new DefaultArtifact(gav.getGroupId(), gav.getArtifactId(), "pom", gav.getVersion()); pomArtifact = pomArtifact.setFile(pomFile); final Artifact finalPomArtifact = pomArtifact; this.pomRepositories.forEach(artifactRepository -> { artifactRepository.deploy(null, finalPomArtifact); }); }
protected Artifact resolve(final Artifact dep, final String classifier, final String type) { final LocalRepositoryManager lrm = repositorySystemSession.getLocalRepositoryManager(); final Artifact artifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), classifier, type, dep.getVersion()); final File location = new File(lrm.getRepository().getBasedir(), lrm.getPathForLocalArtifact(artifact)); if (!location.exists()) { return resolve(artifact); } return artifact.setFile(location); }
public void installArtifact(String groupId, String artifactId, String ext, String classifier, String version, File artifactFile, File pomFile) throws Exception { Artifact jarArtifact = new DefaultArtifact(groupId, artifactId, classifier, ext, version); jarArtifact = jarArtifact.setFile(artifactFile); Artifact pomArtifact = new SubArtifact(jarArtifact, "", "pom"); pomArtifact = pomArtifact.setFile(pomFile); InstallRequest installRequest = new InstallRequest(); installRequest.addArtifact(jarArtifact ).addArtifact( pomArtifact ); InstallResult result = system.install(session, installRequest); if (!result.getArtifacts().contains(jarArtifact)) { throw new AssertionError("Could not install jar " + jarArtifact); } if (!result.getArtifacts().contains(pomArtifact)) { throw new AssertionError("Could not install pom " + jarArtifact); } }
@BeforeClass public static void init() { OrienteerClassLoaderUtil.deleteMetadataFile(); Artifact artifact = new DefaultArtifact("org.company:artifact:1.0"); artifact = artifact.setFile(new File("module.jar")); metadata = new OArtifact(); metadata.setArtifactReference(OArtifactReference.valueOf(artifact)); metadata.setLoad(true); metadata.setTrusted(true); OrienteerClassLoaderUtil.createOArtifactsMetadata(Lists.newArrayList(metadata)); OArtifact oArtifact = OrienteerClassLoaderUtil.getOArtifactsMetadataAsList().get(0); testArtifact(metadata, oArtifact); }