Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
release project maven support
Browse files Browse the repository at this point in the history
  • Loading branch information
awisniew90 committed Mar 16, 2019
1 parent 5826eee commit bdd1d21
Show file tree
Hide file tree
Showing 15 changed files with 628 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class BoosterConfigurator {
* take a list of pom boost dependency strings and map to liberty features
* for config. return a list of feature configuration objects for each found
* dependency.
*
* @param dependencies
* @param logger
* @return
Expand All @@ -41,31 +42,33 @@ public class BoosterConfigurator {
* @throws SecurityException
*/
public static List<AbstractBoosterConfig> getBoosterPackConfigurators(Map<String, String> dependencies,
BoostLoggerI logger) throws BoostException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
BoostLoggerI logger) throws BoostException, InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {

List<AbstractBoosterConfig> boosterPackConfigList = new ArrayList<AbstractBoosterConfig>();

Reflections reflections = new Reflections("io.openliberty.boost.common.boosters");

Set<Class<? extends AbstractBoosterConfig>> allClasses = reflections.getSubTypesOf(AbstractBoosterConfig.class);
for(Class<? extends AbstractBoosterConfig> boosterClass : allClasses) {
for (Class<? extends AbstractBoosterConfig> boosterClass : allClasses) {
if (dependencies.containsKey(AbstractBoosterConfig.getCoordindates(boosterClass))) {
Constructor<?> cons = boosterClass.getConstructor(Map.class, BoostLoggerI.class);
Object o = cons.newInstance(dependencies, logger);
if(o instanceof AbstractBoosterConfig) {
boosterPackConfigList.add((AbstractBoosterConfig)o);
}
else {
throw new BoostException("Found a class in io.openliberty.boost.common.boosters that did not extend AbstractBoosterConfig. This should never happen.");
if (o instanceof AbstractBoosterConfig) {
boosterPackConfigList.add((AbstractBoosterConfig) o);
} else {
throw new BoostException(
"Found a class in io.openliberty.boost.common.boosters that did not extend AbstractBoosterConfig. This should never happen.");
}
}
}

return boosterPackConfigList;
}

public static void generateLibertyServerConfig(String libertyServerPath,
List<AbstractBoosterConfig> boosterPackConfigurators, String warName, BoostLoggerI logger) throws Exception {
List<AbstractBoosterConfig> boosterPackConfigurators, List<String> warNames, BoostLoggerI logger)
throws Exception {

LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator(libertyServerPath, logger);

Expand All @@ -77,11 +80,13 @@ public static void generateLibertyServerConfig(String libertyServerPath,
}

// Add war configuration is necessary
if (warName != null) {
serverConfig.addApplication(warName);
if (!warNames.isEmpty()) {
for (String warName : warNames) {
serverConfig.addApplication(warName);
}
} else {
throw new Exception(
"Unsupported packaging type - Liberty Boost currently supports WAR packaging type only.");
"No war files were found. The project must have a war packaging type or specify war dependencies.");
}

serverConfig.writeToServer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public final class ConfigConstants {
public static final String VERSION = "version";
public static final String WAR_PKG_TYPE = "war";

public static final String SPRING_BOOT_PROJ = "spring-boot-project";
public static final String NORMAL_PROJ = "project";
public static final String INSTALL_PACKAGE_SPRING = "spring-boot-project";
public static final String INSTALL_PACKAGE_ALL= "all";
public static final String INSTALL_PACKAGE_DEP= "dependencies";

public static final String FEATURE_MANAGER = "featureManager";
public static final String HTTP_ENDPOINT = "httpEndpoint";
Expand Down
5 changes: 5 additions & 0 deletions boost-maven/boost-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
<artifactId>docker-client</artifactId>
<version>8.11.7</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<version>0.9.0.M2</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>plugin-support</artifactId>
Expand Down
55 changes: 55 additions & 0 deletions boost-maven/boost-maven-plugin/src/it/test-dev-release/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<modelVersion>4.0.0</modelVersion>

<groupId>io.openliberty.boost.test</groupId>
<artifactId>test-dev-release</artifactId>
<version>@pom.version@</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<goals>
<goal>install</goal>
</goals>
<projectsDirectory>src/it</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<streamLogs>true</streamLogs>
<setupIncludes>
<setupInclude>dev-project/pom.xml</setupInclude>
</setupIncludes>
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
</pomIncludes>
<properties>
<runtimeGroupId>${runtimeGroupId}</runtimeGroupId>
<runtimeArtifactId>${runtimeArtifactId}</runtimeArtifactId>
<runtimeVersion>${runtimeVersion}</runtimeVersion>
</properties>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.openliberty.boost</groupId>
<artifactId>dev-project</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<pluginRepositories>
<!-- Configure Sonatype OSS Maven snapshots repository -->
<pluginRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.openliberty.boosters</groupId>
<artifactId>ee8-bom</artifactId>
<version>@pom.version@</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>io.openliberty.boosters</groupId>
<artifactId>mp20-bom</artifactId>
<version>@pom.version@</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.openliberty.boosters</groupId>
<artifactId>jdbc</artifactId>
</dependency>
<dependency>
<groupId>io.openliberty.boosters</groupId>
<artifactId>jaxrs</artifactId>
</dependency>
<dependency>
<groupId>io.openliberty.boosters</groupId>
<artifactId>mpHealth</artifactId>
</dependency>
<dependency>
<groupId>io.openliberty.boosters</groupId>
<artifactId>cdi</artifactId>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.openliberty.boost</groupId>
<artifactId>boost-maven-plugin</artifactId>
<version>@pom.version@</version>
<configuration>
<runtimeArtifact>
<groupId>${runtimeGroupId}</groupId>
<artifactId>${runtimeArtifactId}</artifactId>
<version>${runtimeVersion}</version>
<type>zip</type>
</runtimeArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package application;

import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.enterprise.context.ApplicationScoped;
import javax.annotation.Resource;
import javax.sql.DataSource;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

/**
* Servlet implementation class JdbcServlet
*/
@Path("/population")
@ApplicationScoped
public class PopulationResource {

@Resource
DataSource ds1;

@GET
@Produces("text/plain")
public String getInformation() throws Exception, IOException {

String returnValue = null;
Statement stmt = null;
Connection con = null;

try {
con = ds1.getConnection();

stmt = con.createStatement();
// create a table
stmt.executeUpdate(
"create table cities (name varchar(50) not null primary key, population int, county varchar(30))");
// insert a test record
stmt.executeUpdate("insert into cities values ('New York City', 8550405, 'Unitest States')");
// select a record
ResultSet result = stmt.executeQuery("select population from cities where name='New York City'");
result.next();

returnValue = "The population of NYC is " + result.getString(1);

} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
// drop the table to clean up and to be able to rerun the test.
stmt.executeUpdate("drop table cities");
} catch (SQLException e) {
e.printStackTrace();
}
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

return returnValue;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>Java REST Sample</display-name>
<servlet>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Binary file not shown.
Loading

0 comments on commit bdd1d21

Please sign in to comment.