migrated to sbt-misc-plugin
This commit is contained in:
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
||||
[submodule "nim/htmlutils"]
|
||||
path = nim/lib/htmlutils
|
||||
url = ssh://oggio88.soon.it:1122/mnt/git/htmlutils
|
||||
url = ssh://git@woggioni.net:1122/mnt/git/htmlutils
|
||||
|
117
build.sbt
117
build.sbt
@@ -1,6 +1,5 @@
|
||||
import java.nio.file.{Files, StandardCopyOption}
|
||||
|
||||
import xsbti.compile.CompileAnalysis
|
||||
import org.oggio88.sbt.{NimPlugin, WildflyPlugin}
|
||||
import org.oggio88.sbt.ConfigurationFile._
|
||||
|
||||
name := "jpacrepo"
|
||||
|
||||
@@ -9,93 +8,55 @@ organization := "com.oggio88"
|
||||
version := "2.0"
|
||||
|
||||
resolvers += Resolver.mavenLocal
|
||||
scalaVersion := "2.12.2"
|
||||
|
||||
libraryDependencies += "org.tukaani" % "xz" % "1.6"
|
||||
libraryDependencies += "org.apache.commons" % "commons-compress" % "1.14"
|
||||
libraryDependencies += "javax" % "javaee-api" % "7.0" % "provided"
|
||||
//libraryDependencies += "javax" % "javaee-api" % "7.0 "
|
||||
libraryDependencies += "javax" % "javaee-api" % "7.0" % Provided
|
||||
libraryDependencies += "org.hibernate" % "hibernate-jpamodelgen" % "5.3.6.Final" % Provided
|
||||
|
||||
libraryDependencies += "junit" % "junit" % "4.12" % "test"
|
||||
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"
|
||||
libraryDependencies += "com.thoughtworks.xstream" % "xstream" % "1.4.10" % "test"
|
||||
libraryDependencies += "commons-io" % "commons-io" % "2.5" % "test"
|
||||
libraryDependencies += "org.jboss" % "jboss-ejb-client" % "4.0.0.CR5" % "test"
|
||||
//libraryDependencies += "org.hibernate.javax.persistence" % "hibernate-jpa-2.0-api" % "1.0.1.Final"
|
||||
libraryDependencies += "junit" % "junit" % "4.12" % Test
|
||||
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test
|
||||
libraryDependencies += "com.thoughtworks.xstream" % "xstream" % "1.4.10" % Test
|
||||
libraryDependencies += "commons-io" % "commons-io" % "2.5" % Test
|
||||
libraryDependencies += "org.jboss" % "jboss-ejb-client" % "4.0.0.CR5" % Test
|
||||
|
||||
libraryDependencies += "org.hibernate" % "hibernate-jpamodelgen" % "5.2.10.Final" % "provided"
|
||||
|
||||
//libraryDependencies += "org.jboss.resteasy" % "resteasy-jaxrs" % "3.1.3.Final" % "test"
|
||||
//libraryDependencies += "org.jboss.resteasy" % "resteasy-client" % "3.1.3.Final"
|
||||
//libraryDependencies += "org.jboss.resteasy" % "resteasy-jackson-provider" % "3.1.3.Final" % "test"
|
||||
//libraryDependencies += "com.fasterxml.jackson.core" % "jackson-core" % "2.9.0.pr4"
|
||||
|
||||
//libraryDependencies += "org.jboss.resteasy" % "resteasy-jaxb-provider" % "3.1.3.Final" % "test"
|
||||
//libraryDependencies += "org.jboss.spec.javax.servlet" % "jboss-servlet-api_3.1_spec" % "1.0.0.Final" % "provided"
|
||||
//libraryDependencies += "org.jboss.spec.javax.ws.rs" % "jboss-jaxrs-api_2.0_spec" % "1.0.0.Final"
|
||||
|
||||
libraryDependencies += "org.jboss.resteasy" % "resteasy-jaxrs" % "3.0.11.Final"
|
||||
libraryDependencies += "org.jboss.resteasy" % "resteasy-client" % "3.0.11.Final"
|
||||
libraryDependencies += "org.jboss.resteasy" % "resteasy-jackson-provider" % "3.0.11.Final"
|
||||
libraryDependencies += "org.jboss.resteasy" % "resteasy-jaxb-provider" % "3.0.11.Final"
|
||||
libraryDependencies += "org.jboss.resteasy" % "resteasy-jaxrs" % "3.0.11.Final" % Test
|
||||
libraryDependencies += "org.jboss.resteasy" % "resteasy-client" % "3.0.11.Final" % Test
|
||||
libraryDependencies += "org.jboss.resteasy" % "resteasy-jackson-provider" % "3.0.11.Final" % Test
|
||||
libraryDependencies += "org.jboss.resteasy" % "resteasy-jaxb-provider" % "3.0.11.Final" % Test
|
||||
|
||||
enablePlugins(WarPlugin)
|
||||
enablePlugins(WildflyPlugin)
|
||||
enablePlugins(NimPlugin)
|
||||
|
||||
artifactName :=
|
||||
{ (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
|
||||
artifact.name + "-" + module.revision + "." + artifact.extension
|
||||
}
|
||||
nimCompilerParameters in CompileNim := Seq("-d:release", "-d:serverURL=")
|
||||
sources in CompileNim := Seq(baseDirectory.value / "nim" / "src" / "jpacrepo.nim")
|
||||
|
||||
//javacOptions += "-g"
|
||||
webappWebInfClasses := true
|
||||
|
||||
val compileNim = TaskKey[File]("compileNim", "Compile nim code of web interface", KeyRanks.ATask)
|
||||
compileNim :=
|
||||
webappPostProcess := {
|
||||
val baseDir = baseDirectory.value / "nim" / "static"
|
||||
val nimOutput = (compileNim in CompileNim).value
|
||||
println(nimOutput)
|
||||
webappDir: File =>
|
||||
{
|
||||
val result = new File("nim/nimcache/jpacrepo.js")
|
||||
val cmd = s"nim js -d:release -d:serverURL= nim/src/jpacrepo.nim"
|
||||
println(cmd)
|
||||
sys.process.stringToProcess(cmd).! match
|
||||
{
|
||||
case 0 =>
|
||||
case _ => throw new RuntimeException("Error occurred during deploy")
|
||||
}
|
||||
result
|
||||
IO.copyFile(baseDir / "index.html", webappDir / "index.html")
|
||||
IO.copyFile(baseDir / "jpacrepo.css", webappDir / "jpacrepo.css")
|
||||
nimOutput.foreach(file => IO.copyFile(file, webappDir / file.getName))
|
||||
}
|
||||
}
|
||||
|
||||
lazy val dataSourceJNDI = SettingKey[String]("datasource-jndi", "JNDI name of the application datasource")
|
||||
lazy val dataBaseAction = SettingKey[String]("database-action",
|
||||
"value of the property \"javax.persistence.schema-generation.database.action\" in the persistence unit")
|
||||
|
||||
webappPostProcess :=
|
||||
{
|
||||
val baseDir = baseDirectory.value / "nim" / "static"
|
||||
val nimOutput = compileNim.value
|
||||
webappDir: File =>
|
||||
{
|
||||
IO.copyFile(baseDir / "index.html", webappDir / "index.html")
|
||||
IO.copyFile(baseDir / "jpacrepo.css", webappDir / "jpacrepo.css")
|
||||
IO.copyFile(nimOutput, webappDir / "jpacrepo.js")
|
||||
}
|
||||
}
|
||||
dataSourceJNDI := "java:/PostgresDS"
|
||||
dataBaseAction := "none"
|
||||
|
||||
val wildflyUsername = SettingKey[String]("wildfly-username", "The account username to use to connect to wildfly with jboss-cli.sh")
|
||||
val wildflyPassword = SettingKey[String]("wildfly-password", "The account password to use to connect to wildfly with jboss-cli.sh")
|
||||
val wildflyURL = SettingKey[String]("wildfly-url", "The username to use to connect to wildfly with jboss-cli.sh")
|
||||
|
||||
wildflyUsername := "admin"
|
||||
wildflyPassword := "123456"
|
||||
wildflyURL := "localhost:1234"
|
||||
|
||||
val deploy2Wildfly = TaskKey[Unit]("deploy2Wildfly", "Deploy to a wildfly server instance", KeyRanks.ATask)
|
||||
|
||||
deploy2Wildfly :=
|
||||
{
|
||||
val cmd = s"/opt/wildfly/bin/jboss-cli.sh " +
|
||||
s"--controller='${wildflyURL.value}' " +
|
||||
s"--connect --user='${wildflyUsername.value}' " +
|
||||
s"--password='${wildflyPassword.value}' " +
|
||||
s"--command=\'deploy ${(packagedArtifact in(Compile, Keys.`package`)).value._2} --force\'"
|
||||
println(cmd)
|
||||
sys.process.stringToProcess(cmd).! match
|
||||
{
|
||||
case 0 =>
|
||||
case _ => throw new RuntimeException("Error occurred during deploy")
|
||||
}
|
||||
}
|
||||
resourceGenerators in Compile += Def.task({
|
||||
Seq(IO.configureFile(
|
||||
(sourceDirectory in Compile).value / "resources-template" / "persistence.xml",
|
||||
(resourceManaged in Compile).value / "META-INF" / "persistence.xml",
|
||||
Map("dataSourceJNDI" -> dataSourceJNDI.value,
|
||||
"dataBaseAction" -> dataBaseAction.value)))
|
||||
}).taskValue
|
Submodule nim/lib/htmlutils updated: c57338fc27...219509c910
@@ -1 +1 @@
|
||||
path="lib"
|
||||
path="lib/htmlutils/src"
|
||||
|
@@ -1,2 +1,2 @@
|
||||
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.0.0")
|
||||
|
||||
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.0.1")
|
||||
addSbtPlugin("org.oggio88" % "xsbt-misc-plugin" % "0.1")
|
||||
|
@@ -1,11 +0,0 @@
|
||||
package com.oggio88.jpacrepo.annotation;
|
||||
|
||||
import javax.ws.rs.NameBinding;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@NameBinding
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CORSManaged
|
||||
{
|
||||
}
|
@@ -8,6 +8,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -30,8 +31,6 @@ public class ApplicationContext
|
||||
|
||||
public boolean invalidateCache = true;
|
||||
|
||||
public boolean cors_enabled;
|
||||
|
||||
public ApplicationContext(String propertyFile)
|
||||
{
|
||||
systemProperties = new Properties();
|
||||
@@ -40,11 +39,10 @@ public class ApplicationContext
|
||||
try
|
||||
{
|
||||
input = new FileInputStream(propertyFile);
|
||||
// load a properties file
|
||||
systemProperties.load(input);
|
||||
// get the property value and print it out
|
||||
systemProperties.getProperty("RepoFolder");
|
||||
repoFolder = systemProperties.getProperty("RepoFolder");
|
||||
repoFolder = Optional.ofNullable(
|
||||
System.getProperty("com.oggio88.jpacrepo.RepoFolder")).orElse(
|
||||
systemProperties.getProperty("RepoFolder"));
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
@@ -64,10 +62,6 @@ public class ApplicationContext
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String prop = System.getProperty("org.oggio88.jpacrepo.cors");
|
||||
if (prop != null)
|
||||
cors_enabled = Boolean.parseBoolean(prop);
|
||||
}
|
||||
|
||||
public Properties getSystemProperties()
|
||||
|
@@ -24,7 +24,6 @@ public class ApplicationConfig extends Application
|
||||
{
|
||||
HashSet<Class<?>> c = new HashSet<>();
|
||||
c.add(PacmanWebService.class);
|
||||
c.add(CORSFilter.class);
|
||||
classes = Collections.unmodifiableSet(c);
|
||||
}
|
||||
|
||||
|
@@ -1,38 +0,0 @@
|
||||
package com.oggio88.jpacrepo.service;
|
||||
|
||||
import com.oggio88.jpacrepo.annotation.CORSManaged;
|
||||
import com.oggio88.jpacrepo.context.ApplicationContext;
|
||||
import com.oggio88.jpacrepo.context.DefaultConfiguration;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.container.ContainerRequestContext;
|
||||
import javax.ws.rs.container.ContainerResponseContext;
|
||||
import javax.ws.rs.container.ContainerResponseFilter;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Provider
|
||||
@CORSManaged
|
||||
public class CORSFilter implements ContainerResponseFilter
|
||||
{
|
||||
private final Logger log = Logger.getLogger(CORSFilter.class.getName());
|
||||
|
||||
@Inject
|
||||
@DefaultConfiguration
|
||||
ApplicationContext ctx;
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext containerRequestContext,
|
||||
ContainerResponseContext containerResponseContext) throws IOException
|
||||
{
|
||||
if (!ctx.cors_enabled)
|
||||
{
|
||||
MultivaluedMap<String, Object> headers = containerResponseContext.getHeaders();
|
||||
headers.add("Access-Control-Allow-Origin", "*");
|
||||
headers.add("Access-Control-Allow-Headers", "Accept, Accept-Language, Content-Language, Content-Type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,10 +13,10 @@ import java.util.Map;
|
||||
@Local
|
||||
public interface PacmanServiceView extends PacmanServiceRemote
|
||||
{
|
||||
public long countResults(String name, String version, String arch);
|
||||
long countResults(String name, String version, String arch);
|
||||
|
||||
public List<PkgData> searchPackage(String name, String version, String arch, int page, int pageSize);
|
||||
List<PkgData> searchPackage(String name, String version, String arch, int page, int pageSize);
|
||||
|
||||
public<T> List<T> listProperty(String property, Map<String,String> equalityConditions, Class<T> cls);
|
||||
<T> List<T> listProperty(String property, Map<String,String> equalityConditions, Class<T> cls);
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.oggio88.jpacrepo.service;
|
||||
|
||||
import com.oggio88.jpacrepo.annotation.CORSManaged;
|
||||
import com.oggio88.jpacrepo.context.ApplicationContext;
|
||||
import com.oggio88.jpacrepo.context.DefaultConfiguration;
|
||||
import com.oggio88.jpacrepo.model.PkgData;
|
||||
@@ -43,7 +42,6 @@ class PkgTuple
|
||||
public long size;
|
||||
}
|
||||
|
||||
@CORSManaged
|
||||
@Singleton
|
||||
@Path("/pkg")
|
||||
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
|
||||
|
@@ -17,14 +17,16 @@ import java.io.File;
|
||||
@WebServlet("/archive/*")
|
||||
public class FileServlet extends AbstractFileServlet
|
||||
{
|
||||
private String root;
|
||||
|
||||
@Inject
|
||||
@DefaultConfiguration
|
||||
private ApplicationContext ctx;
|
||||
public FileServlet(@DefaultConfiguration ApplicationContext ctx){
|
||||
root = ctx.getRepoFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File getFile(HttpServletRequest request) throws IllegalArgumentException
|
||||
{
|
||||
return new File(ctx.getSystemProperties().getProperty("RepoFolder"), request.getPathInfo().substring(1));
|
||||
protected File getFile(HttpServletRequest request) throws IllegalArgumentException {
|
||||
return new File(root, request.getPathInfo().substring(1));
|
||||
}
|
||||
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
package com.oggio88.jpacrepo.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Created by walter on 06/06/15.
|
||||
*/
|
||||
public class Utility
|
||||
{
|
||||
|
||||
public static String getTemplate(String filename)
|
||||
{
|
||||
return new String(readResource("/template/" + filename));
|
||||
}
|
||||
|
||||
public static byte[] readResource(String resourcePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
InputStream is = Utility.class.getClassLoader().getResourceAsStream(resourcePath);
|
||||
byte[] res = new byte[is.available()];
|
||||
if(is.read(res,0, res.length)!= res.length)
|
||||
{
|
||||
throw new IOException("Uncompleted read");
|
||||
}
|
||||
is.close();
|
||||
return res;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
21
src/main/resources-template/persistence.xml
Normal file
21
src/main/resources-template/persistence.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
|
||||
version="2.1">
|
||||
|
||||
<persistence-unit name="jpacrepo_pu" transaction-type="JTA">
|
||||
<jta-data-source>${dataSourceJNDI}</jta-data-source>
|
||||
<properties>
|
||||
<property name="javax.persistence.schema-generation.database.action" value="${dataBaseAction}"/>
|
||||
<property name="javax.persistence.schema-generation.create-source" value="script-then-metadata"/>
|
||||
<property name="javax.persistence.schema-generation.create-script-source"
|
||||
value="META-INF/sql/CreateSchema.sql"/>
|
||||
<property name="javax.persistence.schema-generation.drop-source" value="metadata-then-script"/>
|
||||
<property name="javax.persistence.schema-generation.drop-script-source"
|
||||
value="META-INF/sql/DropSchema.sql"/>
|
||||
<property name="eclipselink.logging.level" value="INFO"/>
|
||||
<property name="hibernate.default_schema" value="jpacrepo"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
|
||||
version="2.1">
|
||||
|
||||
<persistence-unit name="jpacrepo_pu" transaction-type="JTA">
|
||||
<jta-data-source>java:/PostgresDS</jta-data-source>
|
||||
<properties>
|
||||
<!--<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>-->
|
||||
<property name="javax.persistence.schema-generation.database.action" value="none"/>
|
||||
<!--<property name="javax.persistence.schema-generation.database.action" value="create"/>-->
|
||||
<property name="eclipselink.logging.level" value="INFO"/>
|
||||
<property name="hibernate.default_schema" value="jpacrepo"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
1
src/main/resources/META-INF/sql/CreateSchema.sql
Normal file
1
src/main/resources/META-INF/sql/CreateSchema.sql
Normal file
@@ -0,0 +1 @@
|
||||
CREATE SCHEMA IF NOT EXISTS jpacrepo;
|
Reference in New Issue
Block a user