/** * Assemble the command line for starting the emulator based on the parameters supplied in the pom file and on the * command line. It should not be that painful to do work with command line and pom supplied values but evidently * it is. * * @return * @throws MojoExecutionException * @see com.simpligility.maven.plugins.android.configuration.Emulator */ private String assembleStartCommandLine() throws MojoExecutionException { String emulatorPath = new File ( getAndroidSdk().getToolsPath(), parsedExecutable ).getAbsolutePath(); StringBuilder startCommandline = new StringBuilder( "\"\"" ).append( emulatorPath ).append( "\"\"" ) .append( " -avd " ).append( parsedAvd ).append( " " ); if ( !StringUtils.isEmpty( parsedOptions ) ) { startCommandline.append( parsedOptions ); } getLog().info( "Android emulator command: " + startCommandline ); return startCommandline.toString(); }
log.info("Skipping execution because 'dockerfile.build.skip' is set"); return; log.info("dockerfile: " + dockerfile); log.info("contextDirectory: " + contextDirectory); log.warn("Docker build was successful, but no image was built"); } else { log.info(MessageFormat.format("Detected build of image with id {0}", imageId)); writeMetadata(Metadata.IMAGE_ID, imageId); log.info(MessageFormat.format("Successfully built {0}", imageId)); } else { log.info(MessageFormat.format("Successfully built {0}", formatImageName(repository, tag)));
public void doWithDevice( final IDevice device ) throws MojoExecutionException { String deviceLogLinePrefix = DeviceHelper.getDeviceLogLinePrefix( device ); try { device.installPackage( apkFile.getAbsolutePath(), true ); getLog().info( deviceLogLinePrefix + "Successfully installed " + apkFile.getAbsolutePath() ); getLog().debug( " to " + DeviceHelper.getDescriptiveName( device ) ); } catch ( InstallException e ) { throw new MojoExecutionException( deviceLogLinePrefix + "Install of " + apkFile.getAbsolutePath() + " failed.", e ); } } } );
/** * Deploy the apk built with the current projects to all attached devices and emulators. * Skips other projects in a multi-module build without terminating. * * @throws MojoExecutionException * @throws MojoFailureException */ protected void deployBuiltApk() throws MojoExecutionException, MojoFailureException { if ( project.getPackaging().equals( APK ) ) { File apkFile = new File( targetDirectory, finalName + "." + APK ); deployApk( apkFile ); } else { getLog().info( "Project packaging is not apk, skipping deployment." ); } }
protected String findMainClass(MavenProject project) { List<String> mainClasses = U.list(); try { for (String path : project.getCompileClasspathElements()) { if (new File(path).isDirectory()) { getLog().info("Scanning classpath directory: " + path); scanForMainClass(path, mainClasses); } else if (!path.endsWith(".jar")) { getLog().warn("Ignoring classpath entry: " + path); } } } catch (Exception e) { throw U.rte(e); } switch (mainClasses.size()) { case 0: getLog().warn("Couldn't find the main class!"); return null; case 1: return U.first(mainClasses); default: getLog().warn("Found multiple main classes, trying to pick the right one: " + mainClasses); return pickMainClass(mainClasses, project); } }
getLog().info(getGeneratedDirectory().getAbsolutePath()); if (!getGeneratedDirectory().exists()) { if (!getGeneratedDirectory().mkdirs()) { getLog().info("Could not create output directory " + getOutputDirectory().getAbsolutePath()); return; if (!getGeneratedDirectory().exists()) { getLog().info("Exiting hk2-config-generator because could not find generated directory " + getGeneratedDirectory().getAbsolutePath()); return; getLog().info("No source file"); return; getLog().info(""); getLog().info("-- AnnotationProcessing Command Line --"); getLog().info(""); getLog().info(options.toString()); getLog().info(classNames.toString()); getLog().info(""); getLog().info("Result: " + (compilationResult ? "OK" : "!!! failed !!!")); getLog().info("Source directory: " + outputPath + " added.");
@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); }
getLog().debug( "DexMechanism set to " + parsedDexMechanism ); if ( parsedDexMechanism != DexMechanism.D8 ) getLog().info( "Not executing D8Mojo because DexMechanism set to " + parsedDexMechanism ); return; File jarFile = new File( targetDirectory + File.separator + finalName + ".jar" ); projectHelper.attachArtifact( project, "jar", project.getArtifact().getClassifier(), jarFile );
!localCache.exists() || new Date().getTime() - localCache.lastModified() < STALE_MS; if (session.isOffline() && localCache.exists() && isStale) { getLog().info("Using stale manifest because offline mode is enabled"); return; getLog().debug("Manifest is up to date, skipping manifest download"); return; getLog().debug("Downloading fresh manifest");
@Override public void execute(Speedment speedment) throws MojoExecutionException, MojoFailureException { getLog().info("Generating code using JSON configuration file: '" + configLocation().toAbsolutePath() + "'."); if (hasConfigFile()) { try { final Project project = speedment.getOrThrow(ProjectComponent.class).getProject(); speedment.getOrThrow(TranslatorManager.class).accept(project); // after generating the speedment code, the package location needs to be added as a source folder if (!mavenProject.getCompileSourceRoots().contains(mavenProject.getBasedir().getAbsolutePath() + "/" + project.getPackageLocation())) { System.out.println("adding new source location"); mavenProject.addCompileSourceRoot(mavenProject.getBasedir().getAbsolutePath() + "/" + project.getPackageLocation()); } } catch (final Exception ex) { final String err = "Error parsing configFile file."; LOGGER.error(ex, err); getLog().error(err); throw new MojoExecutionException(err, ex); } } else { final String err = "To run speedment:generate a valid configFile needs to be specified."; getLog().error(err); throw new MojoExecutionException(err); } }
getLog().info( "Setting " + ATTR_VERSION_NAME + " to " + parsedVersionName ); manifestElement.setAttribute( ATTR_VERSION_NAME, parsedVersionName ); dirty = true; getLog().info( "Setting " + ATTR_VERSION_CODE + " to " + parsedVersionCode ); manifestElement.setAttribute( ATTR_VERSION_CODE, String.valueOf( parsedVersionCode ) ); dirty = true; getLog().info( "Setting " + ATTR_SHARED_USER_ID + " to " + parsedSharedUserId ); manifestElement.setAttribute( ATTR_SHARED_USER_ID, parsedSharedUserId ); dirty = true; getLog().info( "Testing if node " + node.getNodeName() + " is application" ); if ( node.getNodeType() == Node.ELEMENT_NODE ) getLog().info( "Setting " + ATTR_DEBUGGABLE + " to " + parsedDebuggable ); element.setAttribute( ATTR_DEBUGGABLE, String.valueOf( parsedDebuggable ) ); dirty = true; getLog().info( "Setting " + ELEM_COMPATIBLE_SCREENS ); updateCompatibleScreens( doc, manifestElement ); dirty = true; getLog().info( "Made changes to manifest file, updating " + manifestFile ); writeManifest( manifestFile, doc ); getLog().info( "No changes found to write to manifest file" );
public void execute() throws MojoExecutionException, MojoFailureException getLog().info( "Skipping OpenAPI specification resolution" ); return; getLog().info( "Resolving OpenAPI specification.." ); if (StringUtils.isNotBlank(openapiFilePath)) { Path openapiPath = Paths.get(openapiFilePath); if (openapiPath.toFile().exists() && openapiPath.toFile().isFile()) { String openapiFileContent = new String(Files.readAllBytes(openapiPath), encoding); if (StringUtils.isNotBlank(openapiFileContent)) { } catch (IOException e) { getLog().error( "Error writing API specification" , e); throw new MojoExecutionException("Failed to write API definition", e); } catch (Exception e) { getLog().error( "Error resolving API specification" , e); throw new MojoExecutionException(e.getMessage(), e);
@Override public void execute() throws MojoExecutionException, MojoFailureException { if ( getJack().isEnabled() ) { //proguard is handled by Jack return; } ConfigHandler configHandler = new ConfigHandler( this, this.session, this.execution ); configHandler.parseConfiguration(); if ( !parsedSkip ) { if ( parsedConfig.exists() ) { // TODO: make the property name a constant sometime after switching to @Mojo project.getProperties().setProperty( "android.proguard.obfuscatedJar", obfuscatedJar ); executeProguard(); } else { getLog().info( String .format( "Proguard skipped because the configuration file doesn't exist: %s", parsedConfig ) ); } } }
@Override protected void execute(Speedment speedment) throws MojoExecutionException, MojoFailureException { getLog().info("Saving default configuration from database to '" + configLocation().toAbsolutePath() + "'."); final ConfigFileHelper helper = speedment.getOrThrow(ConfigFileHelper.class); try { helper.setCurrentlyOpenFile(configLocation().toFile()); helper.loadFromDatabaseAndSaveToFile(); } catch (final Exception ex) { final String err = "An error occured while reloading."; getLog().error(err); throw new MojoExecutionException(err, ex); } }
public void doWithDevice( final IDevice device ) throws MojoExecutionException { String deviceLogLinePrefix = DeviceHelper.getDeviceLogLinePrefix( device ); try { device.uninstallPackage( packageName ); getLog().info( deviceLogLinePrefix + "Successfully uninstalled " + packageName ); getLog().debug( " from " + DeviceHelper.getDescriptiveName( device ) ); result.set( true ); } catch ( InstallException e ) { result.set( false ); throw new MojoExecutionException( deviceLogLinePrefix + "Uninstall of " + packageName + " failed.", e ); } } } );
getLog().info( "Waiting for the device to go online..." ); throw new MojoExecutionException( "Interrupted waiting for device to become ready" ); BOOT_INDICATOR_PROP_WAIT_FOR[indicatorProp] ? targetStateReached : true; getLog().debug( BOOT_INDICATOR_PROP_NAMES[indicatorProp] + " : " + bootIndicatorPropValues[indicatorProp] + ( targetStateReached ? " == " : " != " ) throw new MojoExecutionException( "IO error during status request" , e ); getLog().info( "Waiting for the device to finish booting..." ); throw new MojoExecutionException( "Interrupted while waiting for the device to finish booting" ); if ( sysBootCompleted && remainingTime < START_TIMEOUT_REMAINING_TIME_WARNING_THRESHOLD ) getLog().warn( "Boot indicators have been signalled, but remaining time was " + remainingTime + " ms" );
throws MojoExecutionException, MojoFailureException { log.info(MessageFormat.format("Building Docker context {0}", contextDirectory)); dockerClient.pull(image); log.info(MessageFormat.format("Build will use image {0} for cache-from", image)); cacheFromExistLocally.add(image); } catch (ImageNotFoundException e) { log.warn(MessageFormat.format( "Image {0} not found, build will not use it for cache-from", image)); } catch (DockerException | InterruptedException e) { throw new MojoExecutionException("Could not pull cache-from image", e); log.info(""); // Spacing around build progress try { if (repository != null) { final String name = formatImageName(repository, tag); log.info(MessageFormat.format("Image will be built as {0}", name)); log.info(""); // Spacing around build progress dockerClient.build(contextDirectory, name, progressHandler, buildParametersArray); } else { log.info("Image will be built without a name"); log.info(""); // Spacing around build progress dockerClient.build(contextDirectory, progressHandler, buildParametersArray); log.info(""); // Spacing around build progress
/** * Copy the Ndk GdbServer into the architecture output folder if the folder exists but the GdbServer doesn't. */ private void copyGdbServer( File destinationDirectory, String architecture ) throws MojoExecutionException { try { final File destDir = new File( destinationDirectory, architecture ); if ( destDir.exists() ) { // Copy the gdbserver binary to libs/<architecture>/ final File gdbServerFile = getAndroidNdk().getGdbServer( architecture ); final File destFile = new File( destDir, "gdbserver" ); if ( ! destFile.exists() ) { getLog().debug( "Copying gdbServer to " + destFile ); FileUtils.copyFile( gdbServerFile, destFile ); } else { getLog().info( "Note: gdbserver binary already exists at destination, will not copy over" ); } } } catch ( Exception e ) { getLog().error( "Error while copying gdbserver: " + e.getMessage(), e ); throw new MojoExecutionException( "Error while copying gdbserver: " + e.getMessage(), e ); } }
FileUtils.forceMkdir( new File ( directory ) ); final StringBuilder b = new StringBuilder( directory ).append( "/TEST-" ) .append( DeviceHelper.getDescriptiveName( device ) ); final File reportFile = new File( b.append( ".xml" ).toString() ); final JAXBContext jaxbContext = JAXBContext.newInstance( ObjectFactory.class ); final Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.marshal( report, reportFile ); getLog().info( deviceLogLinePrefix + "Report file written to " + reportFile.getAbsolutePath() );