本文整理匯總了Java中org.apache.maven.model.Model.getParent方法的典型用法代碼示例。如果您正苦於以下問題:Java Model.getParent方法的具體用法?Java Model.getParent怎麽用?Java Model.getParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.model.Model
的用法示例。
在下文中一共展示了Model.getParent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isParentOf
import org.apache.maven.model.Model; //導入方法依賴的package包/類
@SuppressWarnings("PMD.SimplifyBooleanReturns")
private boolean isParentOf(Model model) {
if (model.getParent() == null) {
return false;
}
if (!this.model.getGroupId().equals(model.getParent().getGroupId())) return false;
if (!this.model.getArtifactId().equals(model.getParent().getArtifactId())) return false;
if (!this.model.getVersion().equals(model.getParent().getVersion())) return false;
return true;
}
示例2: pomExecution
import org.apache.maven.model.Model; //導入方法依賴的package包/類
@Override
protected TOExecutionResult pomExecution(String relativePomFile, Model model) {
String details;
Parent parent = model.getParent();
if (parent == null) {
String message = String.format("Pom file %s does not have a parent", getRelativePath());
switch (ifNotPresent) {
case Warn:
return TOExecutionResult.warning(this, new TransformationOperationException(message));
case NoOp:
return TOExecutionResult.noOp(this, message);
case Fail:
// Fail is the default
default:
return TOExecutionResult.error(this, new TransformationOperationException(message));
}
}
if(groupId != null && artifactId != null && version != null) {
parent.setGroupId(groupId);
parent.setArtifactId(artifactId);
parent.setVersion(version);
String newParent = parent.toString();
details = String.format("Parent for POM file (%s) has been set to %s", relativePomFile, newParent);
} else if (groupId == null && artifactId == null && version != null) {
String oldVersion = parent.getVersion();
parent.setVersion(version);
details = String.format("Parent's version for POM file (%s) has been changed from %s to %s", relativePomFile, oldVersion, version);
} else {
// FIXME this should be in a pre-validation
return TOExecutionResult.error(this, new TransformationOperationException("Invalid POM parent transformation operation"));
}
return TOExecutionResult.success(this, details);
}
示例3: updateParentIfPossible
import org.apache.maven.model.Model; //導入方法依賴的package包/類
private List<VersionChange> updateParentIfPossible(ModelWrapper wrapper, Versions versions,
Model model, List<VersionChange> sourceChanges) {
String rootProjectName = wrapper.projectName();
String rootProjectGroupId = wrapper.groupId();
List<VersionChange> changes = new ArrayList<>(sourceChanges);
if (model.getParent() == null || isEmpty(model.getParent().getVersion())) {
log.debug("Can't set the value for parent... Will return {}", sourceChanges);
return changes;
}
if (model.getGroupId() != null && !model.getGroupId().equals(rootProjectGroupId)) {
log.info("Will not update the project's [{}] parent [{}] since its group id [{}] is not equal the parent group id [{}]",
model.getArtifactId(), model.getParent().getArtifactId(), model.getGroupId(), rootProjectGroupId);
return changes;
}
String parentGroupId = model.getParent().getGroupId();
String parentArtifactId = model.getParent().getArtifactId();
log.debug("Searching for a version of parent [{}:{}]", parentGroupId, parentArtifactId);
String oldVersion = model.getParent().getVersion();
String version = versions.versionForProject(parentArtifactId);
log.debug("Found version is [{}]", version);
if (isEmpty(version)) {
if (hasText(model.getParent().getRelativePath())) {
version = versions.versionForProject(rootProjectName);
} else {
log.warn("There is no info on the [{}:{}] version", parentGroupId, parentArtifactId);
return changes;
}
}
if (oldVersion.equals(version)) {
log.debug("Won't update the version of parent [{}:{}] since you're already using the proper one", parentGroupId, parentArtifactId);
return changes;
}
log.info("Setting version of parent [{}] to [{}] for module [{}]", parentArtifactId,
version, model.getArtifactId());
if (hasText(version)) {
changes.add(new VersionChange(parentGroupId, parentArtifactId, oldVersion, version));
}
return changes;
}
示例4: groupId
import org.apache.maven.model.Model; //導入方法依賴的package包/類
private String groupId(Model model) {
if (hasText(model.getGroupId())) {
return model.getGroupId();
}
if (model.getParent() != null) {
return model.getParent().getGroupId();
}
return "";
}
示例5: checkParametersPassed
import org.apache.maven.model.Model; //導入方法依賴的package包/類
@Test
public void checkParametersPassed() throws Exception {
CommandController controller = uiTestHarness
.createCommandController(SetupProjectCommand.class, project.getRoot());
controller.initialize();
// Checks the command metadata
assertTrue(controller.getCommand() instanceof SetupProjectCommand);
SpringBootDependencyDTO securityDTO = new SpringBootDependencyDTO("Core","security","Security","Secure your application via spring-security");
SpringBootDependencyDTO actuatorDTO = new SpringBootDependencyDTO("Ops","actuator","Actuator","Production ready features to help you monitor and manage your application");
Iterable<SpringBootDependencyDTO> deps = Arrays.asList(securityDTO, actuatorDTO);
controller.setValueFor("dependencies", deps);
final String askedVersion = "2.0.0.M1";
controller.setValueFor("springBootVersion", askedVersion);
assertEquals(askedVersion, controller.getValueFor("springBootVersion"));
Result result = controller.execute();
MavenFacet mavenFacet = project.getFacet(MavenFacet.class);
MavenModelResource modelResource = mavenFacet.getModelResource();
Model model = modelResource.getCurrentModel();
assertEquals("empty-project",model.getArtifactId());
assertEquals("unknown",model.getGroupId());
assertEquals("0",model.getVersion());
// Check if the parent contains the Spring Boot Artifact & version specified
Parent parent = model.getParent();
assertEquals("org.springframework.boot",parent.getGroupId());
assertEquals("spring-boot-starter-parent",parent.getArtifactId());
assertEquals(askedVersion, parent.getVersion());
Node contents = modelResource.getXmlSource();
List<Node> dependenciesNodes = contents.get("dependencies").get(0).getChildren();
// Check Spring Boot Actuator Dependency
List<Node> dependencyActuator = dependenciesNodes.get(0).getChildren();
assertEquals("org.springframework.boot",dependencyActuator.get(0).getText());
assertEquals("spring-boot-starter-actuator",dependencyActuator.get(1).getText());
// Check Spring Boot Security Dependency
List<Node> dependencySecurity = dependenciesNodes.get(1).getChildren();
assertEquals("org.springframework.boot",dependencySecurity.get(0).getText());
assertEquals("spring-boot-starter-security",dependencySecurity.get(1).getText());
assertTrue("Created new Spring Boot", result.getMessage().contains("Created new Spring Boot"));
}