use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class CreatorOperationsImpl method writeAssemblyFile.
private void writeAssemblyFile(JavaPackage topLevelPackage, String templateName, String destinationFolder) {
final InputStream templateInputStream = FileUtils.getInputStream(getClass(), "xml/" + templateName);
final Document assemblyDoc = XmlUtils.readXml(templateInputStream);
final Element root = assemblyDoc.getDocumentElement();
String projectFolder = topLevelPackage.getFullyQualifiedPackageName().replaceAll("\\.", "/");
XmlUtils.findRequiredElement("/assembly/moduleSets/moduleSet/binaries/outputDirectory", root).setTextContent(projectFolder + "/${module.artifactId}/${module.version}");
// Add includes
Element includes = XmlUtils.findFirstElement("moduleSets/moduleSet/includes", root);
if (includes != null) {
// Adding addon-advanced include
Element includeAdvancedElement = assemblyDoc.createElement("include");
includeAdvancedElement.setTextContent(topLevelPackage.getFullyQualifiedPackageName() + ":" + topLevelPackage.getFullyQualifiedPackageName() + ".addon-advanced");
// Adding addon-simple include
Element includeSimpleElement = assemblyDoc.createElement("include");
includeSimpleElement.setTextContent(topLevelPackage.getFullyQualifiedPackageName() + ":" + topLevelPackage.getFullyQualifiedPackageName() + ".addon-simple");
// Adding roo-addon-suite include
Element includeSuiteElement = assemblyDoc.createElement("include");
includeSuiteElement.setTextContent(topLevelPackage.getFullyQualifiedPackageName() + ":" + topLevelPackage.getFullyQualifiedPackageName() + ".roo-addon-suite");
includes.appendChild(includeAdvancedElement);
includes.appendChild(includeSimpleElement);
includes.appendChild(includeSuiteElement);
}
LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, "");
MutableFile assemblyFile = fileManager.createFile(pathResolver.getIdentifier(rootPath, "src/main/assembly/repo-assembly.xml"));
XmlUtils.writeXml(assemblyFile.getOutputStream(), assemblyDoc);
}
use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class CreatorOperationsImpl method copyFile.
private void copyFile(String fileName, String folder) {
String file;
LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, "");
if (folder != null) {
file = pathResolver.getIdentifier(rootPath, folder + "/src/main/resources/" + fileName);
} else {
file = pathResolver.getIdentifier(rootPath, fileName);
}
InputStream inputStream = null;
OutputStream outputStream = null;
try {
inputStream = FileUtils.getInputStream(getClass(), "resources/" + fileName);
if (!fileManager.exists(file)) {
outputStream = fileManager.createFile(file).getOutputStream();
}
if (outputStream != null) {
IOUtils.copy(inputStream, outputStream);
}
} catch (final IOException ioe) {
throw new IllegalStateException(ioe);
} finally {
IOUtils.closeQuietly(inputStream);
if (outputStream != null) {
IOUtils.closeQuietly(outputStream);
}
}
}
use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class ConfigurableMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.
@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
final JavaType javaType = ConfigurableMetadata.getJavaType(metadataIdentificationString);
final LogicalPath path = ConfigurableMetadata.getPath(metadataIdentificationString);
return PhysicalTypeIdentifier.createIdentifier(javaType, path);
}
use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class DtoMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.
@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
final JavaType javaType = DtoMetadata.getJavaType(metadataIdentificationString);
final LogicalPath path = DtoMetadata.getPath(metadataIdentificationString);
return PhysicalTypeIdentifier.createIdentifier(javaType, path);
}
use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class AbstractItdMetadataProvider method getIdForPhysicalJavaType.
public final String getIdForPhysicalJavaType(final String physicalJavaTypeIdentifier) {
Validate.isTrue(MetadataIdentificationUtils.getMetadataClass(physicalJavaTypeIdentifier).equals(MetadataIdentificationUtils.getMetadataClass(PhysicalTypeIdentifier.getMetadataIdentiferType())), "Expected a valid physical Java type instance identifier (not '%s')", physicalJavaTypeIdentifier);
final JavaType javaType = PhysicalTypeIdentifier.getJavaType(physicalJavaTypeIdentifier);
final LogicalPath path = PhysicalTypeIdentifier.getPath(physicalJavaTypeIdentifier);
return createLocalIdentifier(javaType, path);
}
Aggregations