-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expanded Addons Addon to Full layout
- Loading branch information
1 parent
ae39a11
commit c66df4c
Showing
29 changed files
with
926 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>forge-parent</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>addons</artifactId> | ||
<name>Forge - Addon Development Addons</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>forge-addon-container-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>ui</artifactId> | ||
<classifier>forge-addon</classifier> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>maven</artifactId> | ||
<classifier>forge-addon</classifier> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>projects</artifactId> | ||
<classifier>forge-addon</classifier> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>forge-test-harness</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>arquillian-forge-classpath</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>create-forge-addon</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
<inherited>false</inherited> | ||
<configuration> | ||
<classifier>forge-addon</classifier> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>addons-parent</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>addons</artifactId> | ||
<name>Forge - Addon Development Addon</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>addons-api</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>addons-impl</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>ui</artifactId> | ||
<classifier>forge-addon</classifier> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>maven</artifactId> | ||
<classifier>forge-addon</classifier> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>projects</artifactId> | ||
<classifier>forge-addon</classifier> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>create-forge-addon</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
<inherited>false</inherited> | ||
<configuration> | ||
<classifier>forge-addon</classifier> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
</project> |
7 changes: 7 additions & 0 deletions
7
addons/addon/src/main/java/org/jboss/forge/addons/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright 2013 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.jboss.forge.addons; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>addons-parent</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>addons-api</artifactId> | ||
<name>Forge - Addon Development Addon API</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>forge-addon-container-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>addons-parent</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>addons-impl</artifactId> | ||
<name>Forge - Addon Development Addon Impl</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>forge-addon-container-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>addons-api</artifactId> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>ui-api</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>dependencies-api</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>maven-api</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>projects-api</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.forge</groupId> | ||
<artifactId>resources-api</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
146 changes: 146 additions & 0 deletions
146
addons/impl/src/main/java/org/jboss/forge/addons/AddonProjectFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
* Copyright 2013 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.addons; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.logging.Logger; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.jboss.forge.addons.facets.ForgeAddonAPIFacet; | ||
import org.jboss.forge.addons.facets.ForgeAddonFacet; | ||
import org.jboss.forge.addons.facets.ForgeAddonImplFacet; | ||
import org.jboss.forge.addons.facets.ForgeAddonSPIFacet; | ||
import org.jboss.forge.addons.facets.ForgeAddonTestFacet; | ||
import org.jboss.forge.addons.facets.ForgeSimpleAddonFacet; | ||
import org.jboss.forge.container.addons.AddonId; | ||
import org.jboss.forge.container.versions.Version; | ||
import org.jboss.forge.dependencies.builder.DependencyBuilder; | ||
import org.jboss.forge.facets.FacetFactory; | ||
import org.jboss.forge.projects.Project; | ||
import org.jboss.forge.projects.ProjectFacet; | ||
import org.jboss.forge.projects.ProjectFactory; | ||
import org.jboss.forge.projects.dependencies.DependencyInstaller; | ||
import org.jboss.forge.projects.facets.MetadataFacet; | ||
import org.jboss.forge.resource.DirectoryResource; | ||
|
||
/** | ||
* Creates Forge Addon projects | ||
* | ||
* @author <a href="mailto:ggastald@redhat.com">George Gastaldi</a> | ||
* | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
class AddonProjectFactory | ||
{ | ||
|
||
private Logger log = Logger.getLogger(getClass().getName()); | ||
|
||
@Inject | ||
private FacetFactory facetFactory; | ||
|
||
@Inject | ||
private ProjectFactory projectFactory; | ||
|
||
@Inject | ||
private DependencyInstaller dependencyInstaller; | ||
|
||
public Project createSimpleAddonProject(Project project, Version forgeVersion, Iterable<AddonId> dependencyAddons) | ||
{ | ||
configureAddonProject(project); | ||
installSelectedAddons(project, dependencyAddons, false); | ||
return project; | ||
} | ||
|
||
/** | ||
* Create a Forge Project with the full structure (api,impl,tests,spi and addon) | ||
* | ||
* @param project | ||
* @param forgeVersion | ||
* @param dependencyAddons | ||
* @return the project root | ||
*/ | ||
public Project createAddonProject(Project project, Version forgeVersion, Iterable<AddonId> dependencyAddons) | ||
{ | ||
// Project is the parent project | ||
MetadataFacet metadata = project.getFacet(MetadataFacet.class); | ||
// TODO: Verify nomenclature | ||
String projectName = metadata.getProjectName(); | ||
metadata.setProjectName(projectName + "-parent"); | ||
DirectoryResource newRoot = project.getProjectRoot().getParent().getChildDirectory(metadata.getProjectName()); | ||
// FORGE-877: there's an eclipse (not m2e) limitation that says if a project is located directly in the workspace | ||
// folder, then the project name must match the project folder name | ||
if (!newRoot.exists() && !project.getProjectRoot().renameTo(newRoot)) | ||
{ | ||
log.warning("Could not rename project root"); | ||
} | ||
installSelectedAddons(project, dependencyAddons, true); | ||
|
||
// Create ADDON Project | ||
createSubmoduleProject(project, "addon", projectName, ForgeAddonFacet.class); | ||
// Create API Project | ||
createSubmoduleProject(project, "api", projectName + "-api", ForgeAddonAPIFacet.class); | ||
// Create IMPL Project | ||
createSubmoduleProject(project, "impl", projectName + "-impl", ForgeAddonImplFacet.class); | ||
// Create SPI Project | ||
createSubmoduleProject(project, "spi", projectName + "-spi", ForgeAddonSPIFacet.class); | ||
// Create TESTS Project | ||
createSubmoduleProject(project, "tests", projectName + "-tests", ForgeAddonTestFacet.class); | ||
|
||
project.getProjectRoot().getChild("src").delete(true); | ||
return project; | ||
} | ||
|
||
/** | ||
* Configure addon | ||
* | ||
* @param project | ||
* @return | ||
*/ | ||
private void configureAddonProject(final Project project) | ||
{ | ||
project.install(facetFactory.create(ForgeAddonFacet.class, project)); | ||
} | ||
|
||
private void installSelectedAddons(final Project project, Iterable<AddonId> addons, boolean managed) | ||
{ | ||
for (AddonId addon : addons) | ||
{ | ||
String[] mavenCoords = addon.getName().split(":"); | ||
DependencyBuilder dependency = DependencyBuilder.create().setGroupId(mavenCoords[0]) | ||
.setArtifactId(mavenCoords[1]) | ||
.setVersion(addon.getVersion().getVersionString()).setClassifier("forge-addon"); | ||
if (managed) | ||
{ | ||
dependencyInstaller.installManaged(project, dependency); | ||
} | ||
else | ||
{ | ||
dependencyInstaller.install(project, dependency); | ||
} | ||
} | ||
} | ||
|
||
private Project createSubmoduleProject(final Project parent, String moduleName, String artifactId, | ||
Class<? extends ProjectFacet>... requiredProjectFacets) | ||
{ | ||
DirectoryResource location = parent.getProjectRoot().getOrCreateChildDirectory(moduleName); | ||
|
||
Set<Class<? extends ProjectFacet>> facets = new HashSet<Class<? extends ProjectFacet>>(); | ||
facets.addAll(Arrays.asList(requiredProjectFacets)); | ||
facets.add(ForgeSimpleAddonFacet.class); | ||
|
||
Project project = projectFactory.createProject(location, facets); | ||
|
||
MetadataFacet metadata = project.getFacet(MetadataFacet.class); | ||
metadata.setProjectName(artifactId); | ||
return project; | ||
} | ||
} |
Oops, something went wrong.