File getTouchfile( Artifact artifact ) { StringBuilder sb = new StringBuilder( 128 ); sb.append( artifact.getArtifactId() ); sb.append( '-' ).append( artifact.getBaseVersion() ); if ( artifact.getClassifier() != null ) { sb.append( '-' ).append( artifact.getClassifier() ); } sb.append( '.' ).append( artifact.getType() ).append( LAST_UPDATE_TAG ); return new File( artifact.getFile().getParentFile(), sb.toString() ); }
public ArtifactNotFoundException( String message, Artifact artifact ) { this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), null, artifact.getDownloadUrl(), artifact.getDependencyTrail() ); }
public AttachedArtifact( Artifact parent, String type, String classifier, ArtifactHandler artifactHandler ) { super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type, classifier, artifactHandler, parent.isOptional() ); setDependencyTrail( Collections.singletonList( parent.getId() ) ); this.parent = parent; if ( getId().equals( parent.getId() ) ) { throw new InvalidArtifactRTException( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parent.getType(), "An attached artifact must have a different ID than its corresponding main artifact." ); } }
private String getRelocationKey( Artifact artifact ) { return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion(); }
public ActiveProjectArtifact( MavenProject project, Artifact artifact ) { this.artifact = artifact; this.project = project; artifact.setFile( project.getArtifact().getFile() ); artifact.setResolved( true ); }
public List getRuntimeDependencies() { Set artifacts = getArtifacts(); if ( artifacts == null || artifacts.isEmpty() ) { return Collections.EMPTY_LIST; } List list = new ArrayList( artifacts.size() ); for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return list; }
@Override public void execute() throws MojoExecutionException { final Log log = getLog(); try { if (log.isDebugEnabled()) { log.debug("classPath: " + classPath); log.debug("classPaths: " + Arrays.deepToString(classPaths)); log.debug("buildPath: " + buildPath); log.debug("buildPaths: " + Arrays.deepToString(buildPaths)); project.addCompileSourceRoot(targetDirectory); v.length() == 0 || v.endsWith(separator) ? v + s : v + separator + s); properties.setProperty("platform.artifacts", project.getBuild().getOutputDirectory()); for (Artifact a : plugin.getArtifacts()) { String s = a.getFile().getCanonicalPath(); String v = properties.getProperty("platform.artifacts", ""); properties.setProperty("platform.artifacts", v.length() == 0 || v.endsWith(separator) ? v + s : v + separator + s); Properties projectProperties = project.getProperties(); for (String key : properties.stringPropertyNames()) { projectProperties.setProperty("javacpp." + key, properties.getProperty(key)); log.error("Failed to execute JavaCPP Builder: " + e.getMessage()); throw new MojoExecutionException("Failed to execute JavaCPP Builder", e);
@SuppressWarnings({ "unchecked" }) @Override public void execute() throws MojoExecutionException, MojoFailureException { if (!CommonUtils.initSaturnHome()) throw new MojoExecutionException("The ${user.home}/.saturn/caches is not exists"); Log log = getLog(); MavenProject project = (MavenProject) getPluginContext().get("project"); String version = getSaturnVersion(project); log.info("Packing the saturn job into a zip file: version:" + version); List<File> runtimeLibFiles = new ArrayList<File>(); List<Artifact> runtimeArtifacts = project.getRuntimeArtifacts(); for (Artifact artifact : runtimeArtifacts) { runtimeLibFiles.add(artifact.getFile()); } runtimeLibFiles.add(new File(project.getBuild().getDirectory(), project.getBuild().getFinalName() + "." + project.getPackaging())); File zipFile = new File(project.getBuild().getDirectory(), project.getArtifactId() + "-" + project.getVersion() + "-" + "app.zip"); try { CommonUtils.zip(runtimeLibFiles, null, zipFile); } catch (Exception e) { e.printStackTrace(); throw new MojoExecutionException("zip " + zipFile + " failed", e); } projectHelper.attachArtifact(project, "zip", "executor", zipFile); }
try { urls.add( file.toURI().toURL() ); getLog().debug( "Adding classpath entry for classes root " + file.getAbsolutePath() ); throw new MojoExecutionException( msg, e ); getLog().warn( msg ); Set<Artifact> artifacts = project.getArtifacts(); if ( artifacts != null) { for ( Artifact a : artifacts ) { if ( !Artifact.SCOPE_TEST.equals( a.getScope() ) ) { try { urls.add( a.getFile().toURI().toURL() ); getLog().debug( "Adding classpath entry for dependency " + a.getId() ); String msg = "Unable to resolve URL for dependency " + a.getId() + " at " + a.getFile().getAbsolutePath(); if ( failOnError ) { throw new MojoExecutionException( msg, e ); getLog().warn( msg );
private void generateR() throws MojoExecutionException getLog().info( "Generating R file for " + project.getArtifact() ); .makeResourcesNonConstant( AAR.equals( project.getArtifact().getType() ) ) .addExtraArguments( aaptExtraArgs ); getLog().debug( getAndroidSdk().getAaptPath() + " " + commandBuilder.toString() ); try executor.setCaptureStdOut( true ); final List<String> commands = commandBuilder.build(); executor.executeCommand( getAndroidSdk().getAaptPath(), commands, project.getBasedir(), false ); throw new MojoExecutionException( "", e ); generateCorrectRJavaForAarDependencies( resGenerator ); getLog().info( "Adding R gen folder to compile classpath: " + genDirectory ); project.addCompileSourceRoot( genDirectory.getAbsolutePath() );
appcp.addAll(resources(mavenProject.getResources())); Set<Artifact> artifacts = new LinkedHashSet<Artifact>(mavenProject.getArtifacts()); if (!"pom".equals(artifact.getType())) { appcp.add(new File(artifact.getFile().getAbsolutePath())); watchDirs.add(mavenProject.getBasedir()); watchDirs.addAll(refbasedir); if (this.watchDirs != null) { cmd.setWorkdir(mavenProject.getBasedir()); getLog().debug("cmd: " + cmd.debug()); getLog().debug("Starting process: " + cmd.debug()); cmd.execute(); } catch (Exception ex) { throw new MojoFailureException("Execution of " + cmd + " resulted in error", ex);
boolean signWithDebugKeyStore ) throws MojoExecutionException getLog().debug( "Building APK with internal APKBuilder" ); artifactSet.getExcludes() ) ) getLog().debug( "Found artifact for APK :" + artifact ); if ( extractDuplicates ) computeDuplicateFiles( artifact.getFile() ); getLog().warn( "Cannot compute duplicates files from " + artifact.getFile().getAbsolutePath(), e ); jarFiles.add( artifact.getFile() ); throw new MojoExecutionException( e.getMessage(), e ); throw new MojoExecutionException( msg, e );
private void copyNativeLibraryArtifact( Artifact artifact, File destinationDirectory, String ndkArchitecture ) throws MojoExecutionException { final File artifactFile = getArtifactResolverHelper().resolveArtifactToFile( artifact ); try { final String artifactId = artifact.getArtifactId(); String filename = artifactId.startsWith( "lib" ) ? artifactId + ".so" : "lib" + artifactId + ".so"; if ( ndkFinalLibraryName != null && artifact.getFile().getName().startsWith( "lib" + ndkFinalLibraryName ) ) { // The artifact looks like one we built with the NDK in this module // preserve the name from the NDK build filename = artifact.getFile().getName(); } final File folder = new File( destinationDirectory, ndkArchitecture ); final File file = new File( folder, filename ); getLog().debug( "Copying native dependency " + artifactId + " (" + artifact.getGroupId() + ") to " + file ); FileUtils.copyFile( artifactFile, file ); } catch ( IOException e ) { throw new MojoExecutionException( "Could not copy native dependency.", e ); } }
@Override public void execute() throws MojoExecutionException { if (getMavenProject().getArtifact().getType().equals("pom")) { getLog().info("Cannot post process domain for pom projects"); return; } try { URLClassLoader loader = DmlMojoUtils.augmentClassLoader(getLog(), getClasspathElements()); FullPostProcessDomainClasses.apply(getMavenProject().getArtifactId(), this.getClassesDirectory(), loader); } catch (Exception e) { getLog().error(e); throw new MojoExecutionException("Something went wrong with the Post-Processing", e); } } }
getLog().debug( "Generating incomplete R file for apklib: " + apklibArtifact.getGroupId() + ":" + apklibArtifact.getArtifactId() ); final File apklibManifest = new File( unpackDir, "AndroidManifest.xml" ); final File apklibResDir = new File( unpackDir, "res" ); final Set<Artifact> apklibDeps = getDependencyResolver() .getLibraryDependenciesFor( this.session, this.repositorySystem, apklibArtifact ); getLog().debug( "apklib=" + apklibArtifact + " dependencies=" + apklibDeps ); for ( Artifact dependency : apklibDeps ) final String extension = dependency.getType(); final File dependencyResDir = getUnpackedLibResourceFolder( dependency ); if ( ( extension.equals( APKLIB ) || extension.equals( AAR ) ) && dependencyResDir.exists() ) final String extension = dependency.getType(); final File dependencyAssetsDir = getUnpackedLibAssetsFolder( dependency ); if ( ( extension.equals( APKLIB ) || extension.equals( AAR ) ) ) getLog().debug( getAndroidSdk().getAaptPath() + " " + commandBuilder.toString() ); try executor.executeCommand( getAndroidSdk().getAaptPath(), commands, project.getBasedir(), false ); throw new MojoExecutionException( "", e );
private void generateBuildConfig() throws MojoExecutionException { getLog().debug( "Generating BuildConfig file" ); // Create the BuildConfig for our package. String packageName = extractPackageNameFromAndroidManifest( destinationManifestFile ); if ( StringUtils.isNotBlank( customPackage ) ) { packageName = customPackage; } generateBuildConfigForPackage( packageName ); // Skip BuildConfig generation for dependencies if this is an AAR project if ( project.getPackaging().equals( AAR ) ) { return; } // Generate the BuildConfig for any APKLIB and some AAR dependencies. // Need to generate for AAR, because some old AARs like ActionBarSherlock do not have BuildConfig (or R) for ( Artifact artifact : getTransitiveDependencyArtifacts( APKLIB, AAR ) ) { if ( skipBuildConfigGeneration( artifact ) ) { getLog().info( "Skip BuildConfig.java generation for " + artifact.getGroupId() + " " + artifact.getArtifactId() ); continue; } final String depPackageName = extractPackageNameFromAndroidArtifact( artifact ); generateBuildConfigForPackage( depPackageName ); } }
public List getCompileClasspathElements() throws DependencyResolutionRequiredException { List list = new ArrayList( getArtifacts().size() ); list.add( getBuild().getOutputDirectory() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { addArtifactPath( a, list ); } } } return list; }
getLog().debug( "Adding dex input (obfuscatedJar) : " + obfuscatedJar ); inputs.add( obfuscatedJar ); getLog().debug( "Using non-obfuscated input" ); getLog().debug( "Adding dex input : " + project.getBuild().getOutputDirectory() ); for ( Artifact artifact : filterArtifacts( getTransitiveDependencyArtifacts(), skipDependencies, artifactTypeSet.getIncludes(), artifactTypeSet.getExcludes(), artifactSet.getIncludes(), artifactSet.getExcludes() ) ) if ( artifact.getType().equals( Const.ArtifactType.NATIVE_SYMBOL_OBJECT ) || artifact.getType().equals( Const.ArtifactType.NATIVE_IMPLEMENTATION_ARCHIVE ) ) else if ( artifact.getType().equals( APKLIB ) ) else if ( artifact.getType().equals( AAR ) ) else if ( artifact.getType().equals( APK ) ) getLog().debug( "Extracting APK classes to target/classes : " + artifact.getArtifactId() ); final File apkClassesJar = getUnpackedLibHelper().getJarFileForApk( artifact ); getLog().debug( "Extracting APK : " + apkClassesJar + " to " + targetDirectory ); getLog().debug( "Adding dex input : " + artifact.getFile() ); inputs.add( artifact.getFile().getAbsoluteFile() );
throws MojoExecutionException { File targetFolderFile = new File( targetFolder ); for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); ) { Artifact artifact = ( Artifact ) it.next(); File f = artifact.getFile(); throw new MojoExecutionException( "Cannot locate artifact file of " + artifact.getArtifactId() ); FileUtils.getFileNames( targetFolderFile, artifact.getArtifactId() + "-*.jar", null, false ); existing.get( 0 ).split( "(" + artifact.getArtifactId() + "-)" )[1].split( "(.jar)" )[0]; DefaultArtifactVersion existingVersion = new DefaultArtifactVersion( version ); DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion( artifact.getVersion() ); LOG.info( "Artifact " + artifact.getArtifactId() + " with the same or higher " + "version already exists in lib folder, skipping copy" ); continue; throw new MojoExecutionException( "Error while copying artifact file of " + artifact.getArtifactId(), e );
if ( lazyLibraryUnpack && outputDirectory.exists() ) getLog().info( "skip library unpacking due to lazyLibraryUnpack policy" ); if ( artifact.getFile().isDirectory() ) FileUtils.copyDirectory( artifact.getFile(), outputDirectory ); throw new MojoExecutionException( "IOException while copying " + artifact.getFile().getAbsolutePath() + " into " + outputDirectory.getAbsolutePath() , e ); JarHelper.unjar( new JarFile( artifact.getFile() ), outputDirectory, new JarHelper.UnjarListener() throw new MojoExecutionException( "IOException while unjarring " + artifact.getFile().getAbsolutePath() + " into " + outputDirectory.getAbsolutePath() , e ); throw new MojoExecutionException( "IOException while copying " + sourceDirectory.getAbsolutePath() + " into " + outputDirectory.getAbsolutePath(), e );