use of org.apache.maven.project.MavenProject in project yeoman-maven-plugin by trecloux.
the class YeomanMojoTest method test_should_skip_tests_when_flag_set.
public void test_should_skip_tests_when_flag_set() throws Exception {
MavenProject project = getMavenProject("src/test/resources/test-mojo-default-pom.xml");
YeomanMojo yeomanMojo = (YeomanMojo) lookupConfiguredMojo(project, "build");
yeomanMojo.skipTests = true;
List<String> commands = executeMojoAndCaptureCommands(yeomanMojo);
assertThat(commands).containsExactly("node --version", "npm --version", "npm install", "bower --version", "bower install --no-color", "grunt --version", "grunt build --no-color");
}
use of org.apache.maven.project.MavenProject in project flyway by flyway.
the class AbstractFlywayMojoSmallTest method skipExecute.
@Test
public void skipExecute() throws Exception {
AbstractFlywayMojo mojo = new AbstractFlywayMojo() {
@Override
protected void doExecute(Flyway flyway) throws Exception {
assertNull(flyway.getDataSource());
}
};
mojo.skip = true;
mojo.url = "jdbc:h2:mem:dummy";
mojo.mavenProject = new MavenProject();
mojo.execute();
}
use of org.apache.maven.project.MavenProject in project intellij-community by JetBrains.
the class MavenEmbedder method readProject.
@NotNull
private MavenExecutionResult readProject(@NotNull final MavenExecutionRequest request) {
ProfileManager globalProfileManager = request.getGlobalProfileManager();
globalProfileManager.loadSettingsProfiles(request.getSettings());
MavenProject rootProject = null;
final List<Exception> exceptions = new ArrayList<Exception>();
Object result = null;
try {
final File pomFile = new File(request.getPomFile());
if (!pomFile.exists()) {
throw new FileNotFoundException("File doesn't exist: " + pomFile.getPath());
}
final Method getProjectsMethod = DefaultMaven.class.getDeclaredMethod("getProjects", MavenExecutionRequest.class);
getProjectsMethod.setAccessible(true);
Maven maven = getComponent(Maven.class);
result = getProjectsMethod.invoke(maven, request);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
return handleException(e.getTargetException());
} catch (Exception e) {
return handleException(e);
}
if (result != null) {
MavenProjectBuilder builder = getComponent(MavenProjectBuilder.class);
for (Object p : (List) result) {
MavenProject project = (MavenProject) p;
try {
builder.calculateConcreteState(project, request.getProjectBuilderConfiguration(), false);
} catch (ModelInterpolationException e) {
exceptions.add(e);
}
if (project.isExecutionRoot()) {
rootProject = project;
}
}
if (rootProject == null && exceptions.isEmpty()) {
throw new RuntimeException("Could't build project for unknown reason");
}
}
return new MavenExecutionResult(rootProject, exceptions);
}
use of org.apache.maven.project.MavenProject in project jangaroo-tools by CoreMedia.
the class PackageApplicationMojo method getDependencies.
private List<String> getDependencies(Artifact artifact) throws ProjectBuildingException {
MavenProject mp = mavenProjectBuilder.buildFromRepository(artifact, remoteRepositories, localRepository, true);
List<String> deps = new LinkedList<String>();
for (Dependency dep : getDependencies(mp)) {
if ("jar".equals(dep.getType()) && (dep.getScope().equals("compile") || dep.getScope().equals("runtime"))) {
deps.add(getInternalId(dep));
}
}
return deps;
}
use of org.apache.maven.project.MavenProject in project asterixdb by apache.
the class LicenseMojo method addDependencyToLicenseMap.
private void addDependencyToLicenseMap(MavenProject depProject, List<Pair<String, String>> depLicenses, String depLocation) {
final String depGav = toGav(depProject);
getLog().debug("adding " + depGav + ", location: " + depLocation);
final MutableBoolean usedMetric = new MutableBoolean(false);
if (depLicenses.size() > 1) {
Collections.sort(depLicenses, (o1, o2) -> {
final int metric1 = getLicenseMetric(o1.getLeft());
final int metric2 = getLicenseMetric(o2.getLeft());
usedMetric.setValue(usedMetric.booleanValue() || metric1 != LicenseSpec.UNDEFINED_LICENSE_METRIC || metric2 != LicenseSpec.UNDEFINED_LICENSE_METRIC);
return Integer.compare(metric1, metric2);
});
if (usedMetric.booleanValue()) {
getLog().info("Multiple licenses for " + depGav + ": " + depLicenses + "; taking lowest metric: " + depLicenses.get(0));
} else {
getLog().warn("Multiple licenses for " + depGav + ": " + depLicenses + "; taking first listed: " + depLicenses.get(0));
}
} else if (depLicenses.isEmpty()) {
getLog().info("no license defined in model for " + depGav);
depLicenses.add(new ImmutablePair<>("MISSING_LICENSE", null));
}
Pair<String, String> key = depLicenses.get(0);
String licenseUrl = key.getLeft();
final String displayName = key.getRight();
if (!urlToLicenseMap.containsKey(licenseUrl)) {
// assuming we've not already mapped it, annotate the URL with artifact info, if not an actual URL
try {
getLog().debug("- URL: " + new URL(licenseUrl));
// life is good
} catch (MalformedURLException e) {
// we encounter this a lot. Log a warning, and use an annotated key
final String fakeLicenseUrl = depGav.replaceAll(":", "--") + "_" + licenseUrl;
getLog().info("- URL for " + depGav + " is malformed: " + licenseUrl + "; using: " + fakeLicenseUrl);
licenseUrl = fakeLicenseUrl;
}
}
addProject(new Project(depProject, depLocation, depProject.getArtifact().getFile()), new LicenseSpec(licenseUrl, displayName), true);
}
Aggregations