use of org.springframework.roo.project.Dependency in project spring-roo by spring-projects.
the class JpaOperationsImpl method isInstalledInModule.
/**
* FEATURE Methods
*/
public boolean isInstalledInModule(final String moduleName) {
Pom pom = getProjectOperations().getPomFromModuleName(moduleName);
if (pom == null) {
return false;
}
// Check if spring-boot-starter-data-jpa has been included
Set<Dependency> dependencies = pom.getDependencies();
Dependency starter = new Dependency("org.springframework.boot", "spring-boot-starter-data-jpa", "");
boolean hasStarter = dependencies.contains(starter);
// Check existing application profiles
boolean existsSpringConfigProfileInModule = false;
List<String> applicationProfiles = getApplicationConfigService().getApplicationProfiles(moduleName);
for (String profile : applicationProfiles) {
if (getApplicationConfigService().existsSpringConfigFile(moduleName, profile)) {
existsSpringConfigProfileInModule = true;
break;
}
}
return existsSpringConfigProfileInModule && hasStarter;
}
use of org.springframework.roo.project.Dependency in project spring-roo by spring-projects.
the class JpaOperationsImpl method getDependencies.
private List<Dependency> getDependencies(final String xPathExpression, final Element configuration) {
final List<Dependency> dependencies = new ArrayList<Dependency>();
for (final Element dependencyElement : XmlUtils.findElements(xPathExpression + "/dependencies/dependency", configuration)) {
final Dependency dependency = new Dependency(dependencyElement);
dependencies.add(dependency);
}
return dependencies;
}
use of org.springframework.roo.project.Dependency in project spring-roo by spring-projects.
the class TypeManagementServiceImpl method addField.
public void addField(final FieldMetadata field, boolean evict) {
Validate.notNull(field, "Field metadata not provided");
// Obtain the physical type and ITD mutable details
PhysicalTypeMetadata ptm = null;
if (evict) {
ptm = (PhysicalTypeMetadata) metadataService.evictAndGet(field.getDeclaredByMetadataId());
} else {
ptm = (PhysicalTypeMetadata) metadataService.get(field.getDeclaredByMetadataId());
}
Validate.notNull(ptm, "Java source code unavailable for type %s", PhysicalTypeIdentifier.getFriendlyName(field.getDeclaredByMetadataId()));
final PhysicalTypeDetails ptd = ptm.getMemberHoldingTypeDetails();
Validate.notNull(ptd, "Java source code details unavailable for type %s", PhysicalTypeIdentifier.getFriendlyName(field.getDeclaredByMetadataId()));
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder((ClassOrInterfaceTypeDetails) ptd);
// Automatically add JSR 303 (Bean Validation API) support if there is
// no current JSR 303 support but a JSR 303 annotation is present
boolean jsr303Required = false;
for (final AnnotationMetadata annotation : field.getAnnotations()) {
if (annotation.getAnnotationType().getFullyQualifiedTypeName().startsWith("javax.validation")) {
jsr303Required = true;
break;
}
}
final LogicalPath path = PhysicalTypeIdentifier.getPath(cidBuilder.getDeclaredByMetadataId());
if (jsr303Required) {
// It's more likely the version below represents a later version
// than any specified in the user's own dependency list
projectOperations.addDependency(path.getModule(), new Dependency("javax.validation", "validation-api", null));
}
cidBuilder.addField(field);
createOrUpdateTypeOnDisk(cidBuilder.build());
}
use of org.springframework.roo.project.Dependency in project spring-roo by spring-projects.
the class ThymeleafMVCViewResponseService method addWebJars.
/**
* Configure WebJar dependencies in required pom's.
*
* @param module the module where Thymeleaf is going to be installed
*/
private void addWebJars(Pom module) {
String rootModuleName = "";
List<Dependency> dependencies = new ArrayList<Dependency>();
// Add WebJar locator dependency
dependencies.add(new Dependency("org.webjars", "webjars-locator", null));
// Add Bootstrap WebJar
getProjectOperations().addProperty(rootModuleName, new Property("bootstrap.version", "3.3.6"));
dependencies.add(new Dependency("org.webjars.bower", "bootstrap", "${bootstrap.version}"));
// Add Datatables and Datatables related WebJars
getProjectOperations().addProperty(rootModuleName, new Property("datatables.version", "1.10.12"));
dependencies.add(new Dependency("org.webjars.bower", "datatables", "${datatables.version}"));
getProjectOperations().addProperty(rootModuleName, new Property("datatables-bs.version", "1.10.11"));
dependencies.add(new Dependency("org.webjars.bower", "datatables.net-bs", "${datatables-bs.version}"));
getProjectOperations().addProperty(rootModuleName, new Property("datatables-buttons.version", "1.1.2"));
dependencies.add(new Dependency("org.webjars.bower", "datatables.net-buttons", "${datatables-buttons.version}"));
getProjectOperations().addProperty(rootModuleName, new Property("datatables-buttons-bs.version", "1.1.2"));
dependencies.add(new Dependency("org.webjars.bower", "datatables.net-buttons-bs", "${datatables-buttons-bs.version}"));
getProjectOperations().addProperty(rootModuleName, new Property("datatables-responsive.version", "2.0.2"));
dependencies.add(new Dependency("org.webjars.bower", "datatables.net-responsive", "${datatables-responsive.version}"));
getProjectOperations().addProperty(rootModuleName, new Property("datatables-responsive-bs.version", "2.0.2"));
dependencies.add(new Dependency("org.webjars.bower", "datatables.net-responsive-bs", "${datatables-responsive-bs.version}"));
getProjectOperations().addProperty(rootModuleName, new Property("datatables-select.version", "1.1.2"));
dependencies.add(new Dependency("org.webjars.bower", "datatables.net-select", "${datatables-select.version}"));
getProjectOperations().addProperty(rootModuleName, new Property("datatables-select-bs.version", "1.1.2"));
dependencies.add(new Dependency("org.webjars.bower", "datatables.net-select-bs", "${datatables-select-bs.version}"));
getProjectOperations().addProperty(rootModuleName, new Property("datatables-checkboxes.version", "1.1.2"));
getProjectOperations().addProperty(rootModuleName, new Property("datatables-mark.version", "2.0.0"));
// Add exclusions to avoid conflicts with Bower dependencies
List<Dependency> exclusions = new ArrayList<Dependency>();
exclusions.add(new Dependency("org.webjars.npm", "jquery", null));
exclusions.add(new Dependency("org.webjars.npm", "datatables.net", null));
dependencies.add(new Dependency("org.webjars.npm", "jquery-datatables-checkboxes", "${datatables-checkboxes.version}", exclusions));
// Add Datatables mark WebJar
dependencies.add(new Dependency("org.webjars.bower", "github-com-julmot-datatables-mark-js", "${datatables-mark.version}"));
// Add DatetimePicker WebJar
getProjectOperations().addProperty(rootModuleName, new Property("datetimepicker.version", "2.5.4"));
dependencies.add(new Dependency("org.webjars.bower", "datetimepicker", "${datetimepicker.version}"));
// Add FontAwesome WebJar
getProjectOperations().addProperty(rootModuleName, new Property("fontawesome.version", "4.6.2"));
dependencies.add(new Dependency("org.webjars.bower", "font-awesome", "${fontawesome.version}"));
// Add jQuery WebJar
getProjectOperations().addProperty(rootModuleName, new Property("jquery.version", "1.12.3"));
dependencies.add(new Dependency("org.webjars.bower", "jquery", "${jquery.version}"));
// Add jQuery InputMask WebJar
getProjectOperations().addProperty(rootModuleName, new Property("jquery-inputmask.version", "3.3.1"));
// Add exclusions to avoid conflicts with Bower dependencies
exclusions = new ArrayList<Dependency>();
exclusions.add(new Dependency("org.webjars", "jquery", null));
dependencies.add(new Dependency("org.webjars", "jquery.inputmask", "${jquery-inputmask.version}", exclusions));
// Add jQuery InputMask WebJar
getProjectOperations().addProperty(rootModuleName, new Property("jquery-validation.version", "1.15.0"));
dependencies.add(new Dependency("org.webjars.bower", "jquery-validation", "${jquery-validation.version}"));
// Add MomentJS WebJar
getProjectOperations().addProperty(rootModuleName, new Property("momentjs.version", "2.13.0"));
dependencies.add(new Dependency("org.webjars.bower", "momentjs", "${momentjs.version}"));
// Add Select2 WebJar
getProjectOperations().addProperty(rootModuleName, new Property("select2.version", "4.0.3"));
dependencies.add(new Dependency("org.webjars.bower", "select2", "${select2.version}"));
// Add Select2 Bootstrap Theme WebJar
getProjectOperations().addProperty(rootModuleName, new Property("select2-bootstrap-theme.version", "0.1.0-beta.7"));
dependencies.add(new Dependency("org.webjars.bower", "select2-bootstrap-theme", "${select2-bootstrap-theme.version}"));
// Add respond WebJar
getProjectOperations().addProperty(rootModuleName, new Property("respond.version", "1.4.2"));
dependencies.add(new Dependency("org.webjars", "respond", "${respond.version}"));
// Add html5shiv WebJar
getProjectOperations().addProperty(rootModuleName, new Property("html5shiv.version", "3.7.3"));
dependencies.add(new Dependency("org.webjars", "html5shiv", "${html5shiv.version}"));
// Add ie10-viewport-bug-workaround WebJar
getProjectOperations().addProperty(rootModuleName, new Property("bootstrap.ie10-viewport-bug-workaround.version", "1.0.3"));
dependencies.add(new Dependency("org.webjars.bower", "ie10-viewport-bug-workaround", "${bootstrap.ie10-viewport-bug-workaround.version}"));
getProjectOperations().addDependencies(module.getModuleName(), dependencies);
}
use of org.springframework.roo.project.Dependency in project spring-roo by spring-projects.
the class RepositoryJpaOperationsImpl method generateConfiguration.
@SuppressWarnings({ "unchecked", "rawtypes" })
private void generateConfiguration(JavaType interfaceType, JavaType domainType) {
final Element configuration = XmlUtils.getConfiguration(getClass());
// Add querydsl dependency
final List<Element> dependencies;
final List<Element> plugins;
if (getProjectOperations().isMultimoduleProject()) {
dependencies = XmlUtils.findElements("/configuration/multimodule/dependencies/dependency", configuration);
plugins = XmlUtils.findElements("/configuration/multimodule/plugins/plugin", configuration);
// Add database test dependency
getJpaOperations().addDatabaseDependencyWithTestScope(interfaceType.getModule(), null, null);
} else {
dependencies = XmlUtils.findElements("/configuration/monomodule/dependencies/dependency", configuration);
plugins = XmlUtils.findElements("/configuration/monomodule/plugins/plugin", configuration);
}
for (final Element dependencyElement : dependencies) {
getProjectOperations().addDependency(interfaceType.getModule(), new Dependency(dependencyElement));
}
// Add querydsl plugin
Plugin queryDslPlugin = null;
for (final Element pluginElement : plugins) {
Plugin plugin = new Plugin(pluginElement);
if (plugin.getArtifactId().equals("querydsl-maven-plugin")) {
queryDslPlugin = plugin;
}
getProjectOperations().addBuildPlugin(interfaceType.getModule(), plugin);
}
if (getProjectOperations().isMultimoduleProject()) {
if (queryDslPlugin == null) {
throw new RuntimeException("Error: Missing QueryDSL plugin");
}
// Add entity package to find Q classes.
Set<String> packages = new HashSet();
for (ClassOrInterfaceTypeDetails cid : getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_REPOSITORY_JPA)) {
if (cid.getType().getModule().equals(interfaceType.getModule())) {
JavaType relatedEntity = (JavaType) cid.getAnnotation(RooJavaType.ROO_REPOSITORY_JPA).getAttribute("entity").getValue();
String module = getTypeLocationService().getTypeDetails(relatedEntity).getType().getModule();
if (!packages.contains(module)) {
packages.add(module);
getProjectOperations().addPackageToPluginExecution(interfaceType.getModule(), queryDslPlugin, "generate-qtypes", getProjectOperations().getTopLevelPackage(module).getFullyQualifiedPackageName());
}
}
}
getProjectOperations().addPackageToPluginExecution(interfaceType.getModule(), queryDslPlugin, "generate-qtypes", getProjectOperations().getTopLevelPackage(domainType.getModule()).getFullyQualifiedPackageName());
} else {
// Add querydsl processor repository
List<Element> repositories = XmlUtils.findElements("/configuration/monomodule/repositories/repository", configuration);
for (final Element repositoryElement : repositories) {
getProjectOperations().addRepository(interfaceType.getModule(), new Repository(repositoryElement));
}
}
}
Aggregations