@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); }
private Set<File> refbasedir(final MavenProject project, final Set<Artifact> references) { Set<File> cp = new LinkedHashSet<>(); for (Artifact reference : references) { File basedir = project.getParent().getBasedir(); cp.add(new File(basedir, reference.getArtifactId())); } return cp; }
public Artifact create( MavenProject project ) { ArtifactHandler handler = getArtifactHandlerManager().getArtifactHandler( project.getPackaging() ); return new DefaultArtifact( project.getGroupId(), project.getArtifactId(), VersionRange.createFromVersion( project.getVersion() ), null, project.getPackaging(), null, handler, false ); }
public ArtifactRepository getDistributionManagementArtifactRepository() { return getArtifact().isSnapshot() && ( getSnapshotArtifactRepository() != null ) ? getSnapshotArtifactRepository() : getReleaseArtifactRepository(); }
public void addProjectReference( MavenProject project ) { projectReferences.put( getProjectReferenceId( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project ); }
public String getName() { // TODO this should not be allowed to be null. if ( getModel().getName() != null ) { return getModel().getName(); } else { return getArtifactId(); } }
public void preserveProperties() { Properties p = getProperties(); if ( p != null ) { preservedProperties = new Properties(); for( Enumeration e = p.propertyNames(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); preservedProperties.setProperty( key, p.getProperty( key ) ); } } }
@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);
private String getConfiguredFileName() { Properties[] propsList = new Properties[] { System.getProperties(), project.getProperties() }; for (String key : new String[] { "docker.save.file", "docker.file", "file" }) { for (Properties props : propsList) { if (props.containsKey(key)) { return props.getProperty(key); } } } return saveFile; }
public void execute() throws MojoExecutionException, MojoFailureException getLog().info( "Skipping OpenAPI specification resolution" ); return; getLog().info( "Resolving OpenAPI specification.." ); String pEnc = project.getProperties().getProperty("project.build.sourceEncoding"); if (StringUtils.isNotBlank(pEnc)) { projectEncoding = pEnc; openAPIInput = Yaml.mapper().readValue(openapiFileContent, OpenAPI.class); } catch (Exception e1) { getLog().error( "Error reading/deserializing openapi file" , e); throw new MojoFailureException(e.getMessage(), e); getLog().error( "Error reading/deserializing openapi file" , e); throw new MojoFailureException(e.getMessage(), e); getLog().error( "Error resolving API specification" , e); throw new MojoFailureException(e.getMessage(), e); } 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);
public Jack( Map pluginContext ) { MavenProject project = ( MavenProject ) pluginContext.get( "project" ); mavenCompilerId = project.getProperties().getProperty( "maven.compiler.compilerId", "" ); }
@Override public void execute() throws MojoExecutionException, MojoFailureException { if(project !=null) { projectEncoding = project.getProperties().getProperty("project.build.sourceEncoding"); getLog().info("Swagger generation is skipped."); return; throw new MojoFailureException("You must configure at least one apiSources element"); throw new MojoExecutionException("You may use an old version of swagger which is not supported by swagger-maven-plugin 2.0+\n" + "swagger-maven-plugin 2.0+ only supports swagger-core 1.3.x"); throw new MojoExecutionException("You may use an old version of swagger which is not supported by swagger-maven-plugin 3.0+\n" + "swagger-maven-plugin 3.0+ only supports swagger spec 2.0"); getLog().debug(apiSources.toString()); throw new MojoFailureException(e.getMessage(), e); } catch (Exception 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 ) ); } } }
/** * If the specified version name cannot be properly parsed then fall back to * an automatic method. * If the version can be parsed then generate a version code from the * version components. In an effort to preseve uniqueness two digits * are allowed for both the minor and incremental versions. * @throws MojoExecutionException */ private void performVersionCodeUpdateFromVersion( Element manifestElement ) throws MojoExecutionException { String verString = project.getVersion(); getLog().debug( "Generating versionCode for " + verString ); String verCode = generateVersionCodeFromVersionName( verString ); getLog().info( "Setting " + ATTR_VERSION_CODE + " to " + verCode ); manifestElement.setAttribute( ATTR_VERSION_CODE, verCode ); project.getProperties().setProperty( "android.manifest.versionCode", String.valueOf( verCode ) ); }
@Override public void execute() throws MojoExecutionException { try { SCM scm = determineSCM(); project.getProperties().setProperty(buildTimeProperty, getBuildTime()); project.getProperties().setProperty(scmUriProperty, getSCMUri(scm)); project.getProperties().setProperty(scmBranchProperty, getSCMBranch(scm)); project.getProperties().setProperty(scmCommitProperty, getSCMCommit(scm)); project.getProperties().setProperty(md5Property, computeMD5()); } catch (Throwable ex) { throw new MojoExecutionException(ex.toString(), ex); } }
parsedVersionName = project.getVersion(); getLog().info( "Setting " + ATTR_VERSION_NAME + " to " + parsedVersionName ); manifestElement.setAttribute( ATTR_VERSION_NAME, parsedVersionName ); dirty = true; || ( parsedVersionCodeAutoIncrement && parsedVersionCodeUpdateFromVersion ) ) throw new MojoFailureException( "versionCodeAutoIncrement, versionCodeUpdateFromVersion and versionCode " + "are mutual exclusive. They cannot be specified at the same time. Please specify either " + "versionCodeAutoIncrement, versionCodeUpdateFromVersion or versionCode!" ); getLog().info( "Setting " + ATTR_VERSION_CODE + " to " + parsedVersionCode ); manifestElement.setAttribute( ATTR_VERSION_CODE, String.valueOf( parsedVersionCode ) ); dirty = true; project.getProperties().setProperty( "android.manifest.versionCode", String.valueOf( parsedVersionCode ) ); project.getProperties() .setProperty( "android.manifest.applicationIcon", String.valueOf( parsedApplicationIcon ) ); project.getProperties() .setProperty( "android.manifest.applicationLabel", String.valueOf( parsedApplicationLabel ) ); project.getProperties() .setProperty( "android.manifest.applicationTheme", String.valueOf( parsedApplicationTheme ) ); .equals( parsedSharedUserId, sharedUserIdAttrib.getValue() ) )
private void performVersioCodeAutoIncrement( Element manifestElement ) { Attr versionCode = manifestElement.getAttributeNode( ATTR_VERSION_CODE ); int currentVersionCode = 0; if ( versionCode != null ) { currentVersionCode = NumberUtils.toInt( versionCode.getValue(), 0 ); } currentVersionCode++; manifestElement.setAttribute( ATTR_VERSION_CODE, String.valueOf( currentVersionCode ) ); project.getProperties().setProperty( "android.manifest.versionCode", String.valueOf( currentVersionCode ) ); }
public void execute() throws MojoExecutionException, MojoFailureException { final Properties projectProperties = this.project.getProperties(); final File agentJarFile = pluginArtifactMap.get(SCOTT_ARTIFACT_NAME).getFile(); String arguments = getArgument(agentJarFile); getLog().info(ARG_LINE + " set to " + arguments); projectProperties.setProperty(ARG_LINE, arguments); }
outputDir = new File(this.getProject().getBuild().getDirectory()); engine.writeReports(p.getName(), p.getGroupId(), p.getArtifactId(), p.getVersion(), outputDir, getFormat()); } catch (ReportException ex) { if (exCol == null) { throw new MojoExecutionException("One or more exceptions occurred during dependency-check analysis", exCol); } else { getLog().debug("Error writing the report", ex); checkForFailure(engine.getDependencies()); if (exCol != null && this.isFailOnError()) { throw new MojoExecutionException("One or more exceptions occurred during dependency-check analysis", exCol); if (getLog().isDebugEnabled()) { getLog().debug("Database connection error", ex); throw new MojoExecutionException(msg, ex); getLog().error(msg, ex);
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (mainClass == null) { throw new MojoExecutionException("main class not configured"); } try (URLClassLoader loader = new Classpath(mavenProject).toClassLoader()) { Path srcdir = new File(mavenProject.getBuild().getSourceDirectory()).toPath(); Path bindir = new File(mavenProject.getBuild().getOutputDirectory()).toPath(); getLog().debug("Using classloader " + loader); getLog().debug(" source: " + srcdir); getLog().debug(" bin: " + bindir); Path output = new ApiParser(srcdir) .with(loader) .export(bindir, mainClass); getLog().info("API file: " + output); } catch (Exception x) { throw new MojoFailureException("ApiTool resulted in exception: ", x); } } }