/** @return Returns the full path of created runner.jar file */ public File getRunnerFile() { return new File( project.getBuild().getDirectory(), finalName + ".jar" ); }
private String completeCalculatedFileName(String file) throws MojoExecutionException { return project.getBuild().getDirectory() + "/" + file.replace("/","-"); }
@SuppressWarnings("unchecked") public List<URL> build() throws MalformedURLException { List<URL> cp = new ArrayList<>(); cp.addAll(resources(project.getResources())); cp.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL()); cp.addAll(jars(project.getArtifacts())); return cp; }
@SuppressWarnings("unchecked") private static Watcher setupCompiler(final MavenProject project, final String compiler, final List<String> srcExtensions, final Consumer<String> task) throws MojoFailureException { File eclipseClasspath = new File(project.getBasedir(), ".classpath"); if ("off".equalsIgnoreCase(compiler) || eclipseClasspath.exists()) { return null; resources.add(0, new File(project.getBuild().getSourceDirectory())); List<Path> paths = resources.stream() .filter(File::exists)
ClassLoader projectCL = getProjectClassLoader(); if (usesDataCollectorAPI(projectCL)) { File file = new File(project.getBuild().getOutputDirectory(), BUNDLES_TO_GEN_FILE); if (file.exists() && file.isFile()) { Map<String, File> bundles = new HashMap<>(); bundles.put(bundleName, bundleFile); File jarFile = new File(project.getBuild().getDirectory(), project.getArtifactId() + "-" + project.getVersion() + "-bundles.jar"); getLog().info("Building bundles jar: " + jarFile.getAbsolutePath());
public List getSystemClasspathElements() 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_SYSTEM.equals( a.getScope() ) ) { addArtifactPath( a, list ); } } } return list; }
Build build = project.getBuild(); if ( !objectEquals( oBuild.getDirectory(), build.getDirectory() ) ) if ( !objectEquals( oBuild.getOutputDirectory(), build.getOutputDirectory() ) )
protected File getBuildTimestampFile() { return new File(project.getBuild().getDirectory(), DOCKER_BUILD_TIMESTAMP); }
@SuppressWarnings("unchecked") protected final ClassLoader getClassLoader() throws MojoExecutionException, DependencyResolutionRequiredException { final MavenProject project = project(); final List<String> classpathElements = new ArrayList<>(); classpathElements.addAll(project.getCompileClasspathElements()); classpathElements.addAll(project.getRuntimeClasspathElements()); classpathElements.add(project.getBuild().getOutputDirectory()); final List<URL> projectClasspathList = new ArrayList<>(); for (final String element : classpathElements) { try { projectClasspathList.add(new File(element).toURI().toURL()); } catch (final MalformedURLException ex) { throw new MojoExecutionException( element + " is an invalid classpath element", ex ); } } return new URLClassLoader( projectClasspathList.toArray(new URL[projectClasspathList.size()]), Thread.currentThread().getContextClassLoader() ); }
protected JavaExecGenerator(GeneratorContext context, String name) { super(context, name, new FromSelector.Default(context, "java")); fatJarDetector = new FatJarDetector(getProject().getBuild().getDirectory()); mainClassDetector = new MainClassDetector(getConfig(Config.mainClass), new File(getProject().getBuild().getOutputDirectory()), context.getLogger()); }
public List getTestClasspathElements() throws DependencyResolutionRequiredException { List list = new ArrayList( getArtifacts().size() + 1 ); list.add( getBuild().getTestOutputDirectory() ); 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 // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform // this check... // if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) || // Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) // { // } File file = a.getFile(); if ( file == null ) { throw new DependencyResolutionRequiredException( a ); } list.add( file.getPath() ); } } return list; }
throws ModelInterpolationException Build changedBuild = project.getBuild(); Build dynamicBuild = project.getDynamicBuild(); Build originalInterpolatedBuild = project.getOriginalInterpolatedBuild(); debugMessages ) ); dynamicBuild.setOutputDirectory( restoreString( dynamicBuild.getOutputDirectory(), originalInterpolatedBuild.getOutputDirectory(), changedBuild.getOutputDirectory(), project, config, debugMessages ) ); dynamicBuild.setDirectory( restoreString( dynamicBuild.getDirectory(), originalInterpolatedBuild.getDirectory(), changedBuild.getDirectory(), project, config,
public String getProjectTestOutputJarPath() { return Utils.forceSlashOnDir( project.getBuild().getDirectory() ) + project.getBuild().getFinalName() + "-tests.jar"; }
private File getAndEnsureOutputDirectory() { File outputDir = new File(new File(project.getBuild().getDirectory()), DOCKER_EXTRA_DIR); if (!outputDir.exists()) { outputDir.mkdirs(); } return outputDir; }
@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); } } }
private List<String> findModifiedClassNames() throws MojoExecutionException { final File sourceRoot = new File(this.project.getBuild() .getSourceDirectory()); final List<String> modifiedPaths = FCollection.map(findModifiedPaths(), pathByScmDir()); return FCollection.flatMap(modifiedPaths, new PathToJavaClassConverter( sourceRoot.getAbsolutePath())); }
protected JavaExecGenerator(GeneratorContext context, String name) { super(context, name, new FromSelector.Default(context, "java")); fatJarDetector = new FatJarDetector(getProject().getBuild().getDirectory()); mainClassDetector = new MainClassDetector(getConfig(Config.mainClass), new File(getProject().getBuild().getOutputDirectory()), context.getLogger()); }
public List<String> getTestClasspathElements() throws DependencyResolutionRequiredException { List<String> list = new ArrayList<>( getArtifacts().size() + 2 ); String d = getBuild().getTestOutputDirectory(); if ( d != null ) { list.add( d ); } d = getBuild().getOutputDirectory(); if ( d != null ) { list.add( d ); } for ( Artifact a : getArtifacts() ) { if ( a.getArtifactHandler().isAddedToClasspath() ) { addArtifactPath( a, list ); } } return list; }
protected void repackage() throws MojoExecutionException { buildDirectory = project.getBuild().getDirectory(); outputDirectory = project.getBuild().getOutputDirectory(); finalName = project.getBuild().getFinalName(); checkPrecoditions(); copyDependencies("classes/lib"); unpackDependencies(); packageJar(); renameJars(); }