Skip to content

Commit

Permalink
Successfully Published!
Browse files Browse the repository at this point in the history
  • Loading branch information
johann8384 committed Mar 6, 2018
1 parent c2f79d8 commit 9a83dfb
Show file tree
Hide file tree
Showing 37 changed files with 347 additions and 377 deletions.
163 changes: 102 additions & 61 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
apply plugin: 'java'

buildscript {
repositories {
jcenter()
Expand All @@ -11,21 +9,31 @@ allprojects {
apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'distribution'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'distribution'

version = '0.1.1-SNAPSHOT'
group = 'io.tsdb.services'
version = "0.1.0"

sourceCompatibility = 1.8
targetCompatibility = 1.8
description = "TSDB.io Services Framework"

configurations {
providedCompile
compile.extendsFrom providedCompile
}
String pomGroup = project.group
String pomRepositoryUrl = 'scm:git:https://github.com/inst-tech/services-framework.git'
String pomScmUrl = 'https://github.com/inst-tech/services-framework'
String pomDescription = 'tsdb.io services framework'
String pomLicenseName = 'The Apache License, Version 2.0'
String pomLicenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
String pomDeveloperId = 'johann8384'
String pomDeveloperEmail = '[email protected]'
String pomDeveloperName = 'Jonathan Creasy'

String pomName = project.name
archivesBaseName = project.name

description = 'tsdb.io Services Framework'

ext {
jettyVersion = '9.4.8.v20171121'
Expand All @@ -38,16 +46,12 @@ allprojects {
shiroVersion = '1.4.0'
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

repositories {
flatDir {
dirs 'libs'
}
mavenLocal()
jcenter()
maven { url "http://repo.maven.apache.org/maven2" }
mavenCentral()
}

Expand All @@ -73,37 +77,100 @@ allprojects {
checkstyleMain.exclude '**/gensrc/**'
}


task('printVersion') {
doLast {
println project.version
}
}

task sourceJar(type: Jar) {
classifier "sources"
from sourceSets.main.allJava
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier "javadoc"
from javadoc.destinationDir
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives jar
archives sourceJar
archives javadocJar
archives javadocJar, sourcesJar
}

signing {
useGpgCmd()
sign configurations.archives
}

publishing {
publications {
mavenJava(MavenPublication) {
artifactId jar.baseName
from components.java
}
}
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

pom.project {
name pomName
description pomDescription
url pomRepositoryUrl
version version
groupId pomGroup
artifactId pomName
packaging 'jar'
scm {
connection pomScmUrl
developerConnection pomScmUrl
url pomScmUrl
}
licenses {
license {
name pomLicenseName
url pomLicenseUrl
distribution 'repo'
}
}

developers {
developer {
id pomDeveloperId
name pomDeveloperName
email pomDeveloperEmail
}
}
}
}
}
}
}

// Because if one does not want to release and
// therefore does not have gradle.properties
// the whole build will fail because the uploadArchives
// is being evaluated and sonatypeUsername
// and sonatypePassword is not going to be present
// using '<<' in uploadArchives could be an option,
// but it is deprecated in gradle 3.4
def getSonatypeProperty(String name) {
name = 'ossrh' + name.capitalize()
if (project.hasProperty(name)) {
return project.getProperties()[name]
} else {
return ''
}
}

task copyJars(type: Copy) {
Expand All @@ -116,7 +183,6 @@ task assembleBinary(type: Copy) {
into "${rootProject.buildDir}/install/bin/"
}


/*
* Note, do NOT remove the exclude *.properties, we do not want centralstation.properties or other random
* property files from our code getting deployed in a build.
Expand All @@ -125,18 +191,6 @@ task assembleBinary(type: Copy) {
*/

subprojects {
/*
task assembleDistWebRoot(type: Copy) {
from "${project.projectDir}/src/main/resources/webroot"
into "${rootProject.buildDir}/install/webroot/"
}
task assembleDistWebRootProjectDir(type: Copy) {
from "${project.projectDir}/src/main/resources/webroot/${project.name}"
into "${rootProject.buildDir}/install/webroot/${project.name}/"
}
*/

task assembleDistBin(dependsOn: assembleBinary, type: Copy) {
from "${project.buildDir}/install/${project.name}/bin/${project.name}"
into "${rootProject.buildDir}/install/bin/"
Expand All @@ -155,24 +209,11 @@ subprojects {
include '*.properties'
into "${rootProject.buildDir}/install/config/"
}
/*
Task assembleDistPKI(type: Copy) {
from "${project.buildDir}/install/${project.name}/"
include 'stunnel.infra.perspica.io.key.pkcs8'
include 'stunnel.infra.perspica.io.key.pem'
include 'stunnel.infra.perspica.io.cert.pem'
include 'techops.infra.perspica.io.key.pem'
include 'techops.infra.perspica.io.cert.pem'
include 'ca-chain.cert.pem'
include 'jssecacert'
into "${rootProject.buildDir}/install/config/"
}
*/
}

project(':framework-base') {
dependencies {
compile project(':framework-common')
compile group: 'io.tsdb.services', name: 'framework-common', version: '0.1.1-SNAPSHOT'
compile group: 'org.eclipse.jetty', name: 'jetty-server', version: "${rootProject.ext.jettyVersion}"
compile group: 'org.eclipse.jetty', name: 'jetty-servlet', version: "${rootProject.ext.jettyVersion}"
compile group: 'org.eclipse.jetty', name: 'apache-jsp', version: "${rootProject.ext.jettyVersion}"
Expand All @@ -181,6 +222,8 @@ project(':framework-base') {
compile group: 'org.jboss.resteasy', name: 'resteasy-guice', version: "${rootProject.ext.resteasyVersion}"
compile group: 'org.jboss.resteasy', name: 'resteasy-jackson-provider', version: "${rootProject.ext.resteasyVersion}"
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
compile group: 'io.dropwizard.metrics', name: 'metrics-servlets', version: "${rootProject.ext.dropwizardVersion}"
compile group: 'io.dropwizard.metrics', name: 'metrics-jetty9', version: "${rootProject.ext.dropwizardVersion}"
compile group: 'com.google.inject.extensions', name: 'guice-servlet', version: "${rootProject.ext.guiceVersion}"
compile group: 'com.google.inject.extensions', name: 'guice-assistedinject', version: "${rootProject.ext.guiceVersion}"
compile group: 'com.google.inject.extensions', name: 'guice-multibindings', version: "${rootProject.ext.guiceVersion}"
Expand All @@ -192,10 +235,16 @@ project(':framework-base') {
exclude group: 'com.google.inject.extensions', module: 'guice-assistedinject'
}
compile group: 'org.reflections', name: 'reflections', version: '0.9.11'
// https://mvnrepository.com/artifact/io.zipkin.brave/brave-http
compile group: 'io.zipkin.brave', name: 'brave-http', version: '4.13.4'
// https://mvnrepository.com/artifact/io.zipkin.java/zipkin
compile group: 'io.zipkin.java', name: 'zipkin', version: '2.5.0'
// https://mvnrepository.com/artifact/io.zipkin.zipkin2/zipkin-storage-elasticsearch
compile group: 'io.zipkin.zipkin2', name: 'zipkin-storage-elasticsearch', version: '2.5.0'
}
}

project(':framework-common') {
project ('framework-common') {
dependencies {
compile group: 'io.dropwizard.metrics', name: 'metrics-core', version: "${rootProject.ext.dropwizardVersion}"
compile group: 'io.dropwizard.metrics', name: 'metrics-jvm', version: "${rootProject.ext.dropwizardVersion}"
Expand All @@ -217,12 +266,4 @@ project(':framework-common') {
}
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
}
}

project('stats') {
apply plugin: 'application'
mainClassName = "io.tsdb.stats.main.Main"
dependencies {
compile project(':framework-base')
}
}
3 changes: 1 addition & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
#./gradlew clean build installDist assembleDistBin assembleDistLibs assembleDistConfig assembleDistWebRootProjectDir -x findbugsMain -x findbugsTest -x checkStyleMain -x checkStyleTest -x test
./gradlew clean build installDist assembleDistBin assembleDistLibs assembleDistConfig -x findbugsMain -x findbugsTest -x checkStyleMain -x checkStyleTest -x test
./gradlew clean build installDist assembleDistBin assembleDistLibs assembleDistConfig publishToMavenLocal -x findbugsMain -x findbugsTest -x checkStyleMain -x checkStyleTest -x test -x signArchives -x uploadArchives
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ protected void initializeInfrastructure() {
//TODO: Add Consul Service Discover here
}


/**
* Gets application path.
*
Expand Down Expand Up @@ -199,6 +200,25 @@ protected void addAdminServlets(final ServletContextHandler servletContextHandle
servletContextHandler.setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, Metrics.getHealthCheckRegistry());
servletContextHandler.addServlet(adminHolder, adminPath);
}
/*
public static List<StagemonitorServletContainerInitializer> getStagemonitorSCIs() {
List<StagemonitorServletContainerInitializer> sciPlugins = new ArrayList<StagemonitorServletContainerInitializer>();
for (StagemonitorServletContainerInitializer plugin : ServiceLoader
.load(StagemonitorServletContainerInitializer.class, ServletContainerInitializerUtil.class.getClassLoader())) {
sciPlugins.add(plugin);
}
return sciPlugins;
}
public static boolean avoidDoubleInit(StagemonitorServletContainerInitializer sci, ServletContext ctx) {
final String initializedAttribute = sci.getClass().getName() + ".initialized";
if (ctx.getAttribute(initializedAttribute) != null) {
// already initialized
return true;
}
ctx.setAttribute(initializedAttribute, true);
return false;
}*/

/**
* Creates instrumented handler for the handler instance passed in.
Expand Down Expand Up @@ -227,15 +247,41 @@ protected InstrumentedHandler getAdminHandler() {
/**
* Allows the developer to use dependency injection ot load dynamic servlets
*
* @param context the ServletContextHandler to configure
* @param servletContextHandler the ServletContextHandler to configure
* @param path the path for the added Servlets
*/
protected abstract void addDynamicServlets(final ServletContextHandler context, final String path);

protected abstract void addDynamicServlets(final ServletContextHandler servletContextHandler, final String path);

protected void addTracingFilter(final ServletContextHandler context) {

//OpenTracing
//TracingFilter filter = new TracingFilter(GlobalTracer.get());
//servletContextHandler.getServletContext().addFilter("tracingFilter", filter);

// Stagemonitor
/*servletContextHandler.addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener() {
@Override
public void lifeCycleStarting(LifeCycle event) {
//new ServletContainerInitializerUtil.registerStagemonitorServletContainerInitializers(servletContextHandler);
if (!Stagemonitor.getPlugin(CorePlugin.class).isStagemonitorActive()) {
return;
}
for (StagemonitorServletContainerInitializer sci : getStagemonitorSCIs()) {
try {
sci.onStartup(servletContextHandler.getServletContext());
} catch (ServletException e) {
LOGGER.warn("Ignored exception:", e);
}
}
}
});*/
}
/**
* Creates a instrumented servlet handler.
*
* @return InstrumentedHandler an instrumented handler instance
* @throws IOException throws this
* @throws URISyntaxException and this
*/
protected InstrumentedHandler getApplicationHandler() throws IOException, URISyntaxException {
LOGGER.info("Setting up Application Handler");
Expand All @@ -253,14 +299,15 @@ protected InstrumentedHandler getApplicationHandler() throws IOException, URISyn
addAdminServlets(context);
}

addTracingFilter(context);

setContextResourceBase(context, BASEROOT_INDEX);

// Enable JSP Support, used to serve authentication pages in the base
enableEmbeddedJspSupport(context);

addDynamicServlets(context, getApplicationPath());
addDefaultHandler(context, "/", getWebRootResourceUri(BASEROOT_INDEX));

return getInstrumentedHandler(context);
}

Expand All @@ -270,7 +317,7 @@ protected InstrumentedHandler getResourceHandler(final String resourceBase) thro

final ResourceHandler handler = new ResourceHandler();
handler.setDirectoriesListed(false);
handler.setWelcomeFiles(new String[]{"index.html"});
handler.setWelcomeFiles(new String[]{ "index.jsp", "index.html"});
handler.setResourceBase(resourceBaseUri);

return getInstrumentedHandler(handler);
Expand Down Expand Up @@ -324,6 +371,7 @@ protected void enableEmbeddedJspSupport(final ServletContextHandler servletConte
holderJsp.setInitParameter("compilerSourceVM", "1.8");
holderJsp.setInitParameter("keepgenerated", "true");
servletContextHandler.addServlet(holderJsp, "*.jsp");
servletContextHandler.setWelcomeFiles(new String[]{ "index.jsp", "index.html"});
}

protected void addDefaultHandler(final ServletContextHandler servletContextHandler, @SuppressWarnings("SameParameterValue") final String path, final String baseUri) {
Expand Down
Loading

0 comments on commit 9a83dfb

Please sign in to comment.