Skip to content

Commit 8900fe2

Browse files
committed
Initial SBT build
1 parent 07ea129 commit 8900fe2

File tree

37 files changed

+829
-251
lines changed

37 files changed

+829
-251
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ spring-scanner-cache.csv
3737
/Source/Integration/Moodle/moodle-2/mod/equella/version.properties
3838
/Source/Integration/Blackboard/bb9/public_html/WEB-INF/bb-manifest.xml
3939
/Source/Server/web/public_html/version.properties
40-
40+
.gradle
41+
.idea
42+
build/
43+
target/

.sbtopts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-mem 4096
2+

Dev/deps-convert/.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/bower_components/
2+
/node_modules/
3+
/.pulp-cache/
4+
/output/
5+
/generated-docs/
6+
/.psc*
7+
/.purs*
8+
/.psa*

Dev/deps-convert/bower.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "deps-convert",
3+
"ignore": [
4+
"**/.*",
5+
"node_modules",
6+
"bower_components",
7+
"output"
8+
],
9+
"dependencies": {
10+
"purescript-prelude": "^3.0.0",
11+
"purescript-console": "^3.0.0",
12+
"purescript-node-fs-aff": "^4.0.0",
13+
"purescript-yargs": "^3.0.0",
14+
"purescript-argonaut": "^3.0.0",
15+
"purescript-strings": "^3.0.0",
16+
"purescript-debug": "^3.0.0",
17+
"purescript-maps": "^3.0.0"
18+
},
19+
"devDependencies": {
20+
"purescript-psci-support": "^3.0.0"
21+
}
22+
}

Dev/deps-convert/src/Main.purs

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
module Main where
2+
3+
import Prelude
4+
import Control.Monad.Eff (Eff)
5+
import Control.Monad.Eff.Console (CONSOLE, error, log)
6+
import Control.Monad.Eff.Exception (EXCEPTION, throw)
7+
import Data.Argonaut (class DecodeJson, decodeJson, (.?), jsonParser)
8+
import Data.Argonaut.Decode.Combinators ((.??))
9+
import Data.Array (concat, filter, fromFoldable, groupBy, mapMaybe, sortWith)
10+
import Data.Either (Either(..), either)
11+
import Data.Foldable (any, find, maximum, traverse_)
12+
import Data.Function (on)
13+
import Data.Maybe (Maybe(..), fromMaybe)
14+
import Data.NonEmpty (NonEmpty(..))
15+
import Data.StrMap (StrMap, lookup, unions)
16+
import Data.String (Pattern(Pattern), joinWith, split, stripPrefix)
17+
import Data.Traversable (traverse)
18+
import Data.Tuple (Tuple(..), fst, snd)
19+
import Node.Encoding (Encoding(..))
20+
import Node.FS (FS)
21+
import Node.FS.Sync (readTextFile)
22+
import Node.Yargs.Applicative (class Arg, arg, runY, yarg)
23+
import Node.Yargs.Setup (usage)
24+
25+
data Format = SBT | Gradle
26+
instance formatArg :: Arg Format where
27+
arg n = fromStr <$> arg n
28+
where
29+
fromStr "gradle" = Gradle
30+
fromStr _ = SBT
31+
32+
newtype DepKey = DepKey {groupId :: String, artifactId :: String}
33+
34+
data BaseDep = BaseDep DepKey {
35+
version :: String
36+
, classifier :: Maybe String
37+
, excludes :: Array String
38+
}
39+
40+
derive instance depKeyEq :: Eq DepKey
41+
instance depKeyOrd :: Ord DepKey where
42+
compare (DepKey d1) (DepKey d2) = compare d1.groupId d2.groupId <> compare d1.artifactId d2.artifactId
43+
44+
instance showKey :: Show DepKey where
45+
show (DepKey {groupId,artifactId}) = groupId <> ":" <> artifactId
46+
47+
derive instance baseDepEq :: Eq BaseDep
48+
49+
type FullDep = {
50+
groupId:: String
51+
, artifactId:: String
52+
, version :: String
53+
, classifier :: Maybe String
54+
, jpfIncludes :: Array String
55+
, jpfExports :: Array String
56+
, excludes :: Array String
57+
}
58+
59+
data Error = NoVersion String
60+
61+
instance showError :: Show Error where
62+
show (NoVersion err) = "No version for '" <> err <> "'"
63+
64+
newtype Dep = Dep FullDep
65+
newtype DepsFile = DepsFile {exclusions::Array String, versions::StrMap String, dependencies::Array Dep}
66+
67+
instance depDecode :: DecodeJson Dep where
68+
decodeJson j = do
69+
o <- decodeJson j
70+
groupId <- o .? "groupId"
71+
artifactId <- o .? "artifactId"
72+
version <- o .? "version"
73+
jpfIncludes <- fromMaybe [] <$> o .?? "jpfIncludes"
74+
jpfExports <- fromMaybe [] <$> o .?? "jpfExports"
75+
excludes <- fromMaybe [] <$> o .?? "excludes"
76+
classifier <- o .?? "classifier"
77+
pure $ Dep {groupId,artifactId,version,jpfIncludes,jpfExports,excludes,classifier}
78+
79+
instance depsDecode :: DecodeJson DepsFile where
80+
decodeJson json = do
81+
o <- decodeJson json
82+
exclusions <- o .? "exclusions"
83+
versions <- o .? "versions"
84+
dependencies <- o .? "dependencies"
85+
pure $ DepsFile {exclusions,versions,dependencies}
86+
87+
keyOnly :: BaseDep -> DepKey
88+
keyOnly (BaseDep k _) = k
89+
90+
versionOnly :: BaseDep -> String
91+
versionOnly (BaseDep k {version}) = version
92+
93+
-- | Sort the dependencies and make sure we only use the highest version mentioned
94+
-- | and warn about the others
95+
mergeVersions :: Array BaseDep -> {warnings::Array String, merged::Array BaseDep}
96+
mergeVersions deps =
97+
let grouped = groupBy (on eq keyOnly) $ sortWith keyOnly deps
98+
allSelections = pickDep <$> grouped
99+
in {warnings: mapMaybe snd allSelections, merged: fst <$> allSelections }
100+
where
101+
pickDep (NonEmpty d others) | not $ any (notEq d) others = Tuple d Nothing
102+
pickDep ne@(NonEmpty df@(BaseDep k _) _) = fromMaybe (Tuple df Nothing) do
103+
let versions = fromFoldable $ versionOnly <$> ne
104+
maxVersion <- maximum versions
105+
maxDep <- find (versionOnly >>> eq maxVersion) ne
106+
let warning = "Ignoring versions '" <> joinWith ", " (filter (notEq maxVersion) versions)
107+
<> "' for dependency '" <> show k
108+
pure $ Tuple maxDep $ Just warning
109+
110+
toGradle :: StrMap String -> Array BaseDep -> Either Error String
111+
toGradle versions deps = pure $ joinWith "\n" $ toGDep <$> deps
112+
where
113+
toGStr s = "'" <> s <> "'"
114+
resolveVersion s | (Just v) <- stripPrefix (Pattern "$") s = fromMaybe "" $ lookup v versions
115+
resolveVersion s = s
116+
classifierStr (Just c) = ":" <> c
117+
classifierStr _ = ""
118+
excludesStr [] = ""
119+
excludesStr allEx = " {\n " <> joinWith "\n " (exclude <$> allEx) <> "\n}"
120+
where exclude e = "exclude group: " <> toGStr e
121+
toGDep (BaseDep (DepKey k) d) = "compile(" <> toGStr (k.groupId <> ":"
122+
<> k.artifactId <> ":"
123+
<> resolveVersion d.version
124+
<> classifierStr d.classifier) <> ")"
125+
<> excludesStr d.excludes
126+
127+
toSBT :: StrMap String -> Array BaseDep -> Either Error String
128+
toSBT versions deps = pure $ "libraryDependencies ++= Seq(" <> (joinWith ",\n" $ toGDep <$> deps) <> "\n)"
129+
where
130+
toStr s = "\"" <> s <> "\""
131+
resolveVersion s | (Just v) <- stripPrefix (Pattern "$") s = toStr $ fromMaybe "" $ lookup v versions
132+
resolveVersion s = toStr s
133+
classifierStr (Just c) = " classifier " <> toStr c
134+
classifierStr _ = ""
135+
excludesStr [] = ""
136+
excludesStr allEx = " excludeAll(\n " <> joinWith ",\n" (exclude <$> allEx) <> "\n)"
137+
where
138+
exclude e = "ExclusionRule(" <> case split (Pattern ":") e of
139+
[o] -> "organization=" <> toStr o
140+
[o,m] -> "organization=" <> toStr o <> ", name=" <> toStr m
141+
_ -> toStr e
142+
<> ")"
143+
toGDep (BaseDep (DepKey k) d) = toStr k.groupId <> " % "
144+
<> toStr k.artifactId <> " % "
145+
<> resolveVersion d.version
146+
<> classifierStr d.classifier <> ""
147+
<> excludesStr d.excludes
148+
149+
150+
collectDeps :: Array DepsFile -> {versions:: StrMap String, deps:: Array BaseDep}
151+
collectDeps files = {versions,deps}
152+
where
153+
versions = unions $ map (\(DepsFile {versions:v}) -> v) files
154+
deps = concat $ map (\(DepsFile {dependencies:d}) -> map doDep d) files
155+
doDep (Dep {groupId,artifactId,version,classifier,excludes}) = BaseDep (DepKey {groupId,artifactId}) {version,classifier,excludes}
156+
157+
outDeps :: forall e. Format -> Array String -> Eff (fs::FS, exception::EXCEPTION, console::CONSOLE|e) Unit
158+
outDeps format files = do
159+
depFiles <- traverse outDep files
160+
let {versions,deps} = collectDeps depFiles
161+
{warnings, merged} = mergeVersions deps
162+
traverse_ error warnings
163+
either (show >>> throw) log $ (writeOut format) versions merged
164+
where
165+
writeOut SBT = toSBT
166+
writeOut Gradle = toGradle
167+
outDep :: String -> Eff (fs::FS, exception::EXCEPTION, console::CONSOLE|e) DepsFile
168+
outDep fn = do
169+
depStr <- readTextFile UTF8 fn
170+
either throw pure do
171+
decodeJson =<< jsonParser depStr
172+
173+
174+
main :: forall e. Eff (fs::FS, console :: CONSOLE, exception::EXCEPTION | e) Unit
175+
main = do
176+
runY (usage "Convert deps.txt") (outDeps <$> yarg "format" [] Nothing (Left SBT) true <*> arg "_" )

Dev/deps-convert/writedeps.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /bin/bash
2+
3+
pulp run -- -format sbt ../../Source/dependencies/deps.txt ../../Platform/Plugins/ExternalPlatform/deps.txt > output/deps

Interface/Plugins/com.tle.common.interfaces/src/com/tle/common/interfaces/SimpleI18NString.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.tle.common.interfaces;
22

3-
import com.sun.istack.internal.Nullable;
3+
import javax.annotation.Nullable;
44

55
public class SimpleI18NString implements I18NString
66
{

Source/Plugins/Admin/com.tle.web.adminconsole/src/com/tle/web/plugin/download/PluginDownloadService.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ public List<PluginDetails> getAllPluginDetails(String pluginType)
6767
StringWriter manWriter = new StringWriter();
6868
try
6969
{
70-
CharStreams.copy(Resources.newReaderSupplier(location.getManifestLocation(), Charsets.UTF_8),
71-
manWriter);
70+
Resources.asCharSource(location.getManifestLocation(), Charsets.UTF_8).copyTo(manWriter);
7271

7372
URL jarUrl = location.getContextLocation();
7473
if( jarUrl.getProtocol().equals("jar") )
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
lazy val Hibernate = config("hibernate")
2+
3+
libraryDependencies := Seq(
4+
"org.hibernate" % "hibernate-core" % "3.6.8.Final",
5+
"org.hibernate" % "hibernate-validator" % "4.2.0.Final",
6+
"org.hibernate" % "hibernate-validator-annotation-processor" % "4.2.0.Final",
7+
"org.hibernate.javax.persistence" % "hibernate-jpa-2.0-api" % "1.0.1.Final",
8+
"org.springframework" % "spring-orm" % "2.5.5" excludeAll(
9+
ExclusionRule(organization = "com.oracle", name = "toplink-essentials"),
10+
ExclusionRule(organization = "org.springframework", name = "spring-beans"),
11+
ExclusionRule(organization = "org.springframework", name = "spring-tx"),
12+
ExclusionRule(organization = "org.springframework", name = "spring-core"),
13+
ExclusionRule(organization = "org.springframework", name = "spring-context")
14+
)).map(_ % Hibernate)
15+
16+
excludeDependencies ++= Seq(
17+
"org.slf4j" % "slf4j-api",
18+
"dom4j" % "dom4j",
19+
"commons-collections" % "commons-collections",
20+
"commons-logging" % "commons-logging",
21+
"aopalliance" % "aopalliance"
22+
)
23+
24+
ivyConfigurations := overrideConfigs(Hibernate)(ivyConfigurations.value)
25+
26+
jpfLibraryJars := Classpaths.managedJars(Hibernate, Set("jar"), update.value)

Source/Plugins/Generic/org.hibernate/plugin-jpf.xml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<import plugin-id="com.google.guava:guava" />
1313
</requires>
1414

15+
<runtime/>
16+
1517
<extension plugin-id="com.tle.common.licences" point-id="licenceExtension" id="hibernateLicenceName">
1618
<parameter id="thirdPartyName" value="Hibernate" />
1719
<parameter id="licenceName" value="LGPL v2.1" />

Source/Plugins/Harvester/com.tle.core.harvester/src/com/tle/core/harvester/AbstractTLFProtocol.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
import javax.inject.Inject;
1313

14+
import com.google.gdata.util.common.util.Base64;
1415
import org.apache.log4j.Logger;
1516

1617
import com.dytech.devlib.PropBagEx;
1718
import com.google.common.io.Closeables;
18-
import com.sun.org.apache.xml.internal.security.utils.Base64;
1919
import com.tle.beans.item.ItemStatus;
2020
import com.tle.common.Check;
2121
import com.tle.common.harvester.HarvesterProfile;
@@ -432,7 +432,7 @@ public void downloadLO(LearningObject lobject, String stagingID) throws Exceptio
432432
call.callWithSoapSAX(handler, getContentType());
433433
responseXml = new PropBagEx(handler.getElementResult());
434434
String base64Data = responseXml.getNode("retrieveContentResult");
435-
Base64.decode(base64Data, out);
435+
out.write(Base64.decode(base64Data));
436436
}
437437
catch( Exception ex )
438438
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
unmanagedSourceDirectories in Compile := (javaSource in Compile).value :: baseDirectory.value / "gensrc" :: Nil

Source/Plugins/REST/com.tle.web.remoting.rest/src/com/tle/web/remoting/resteasy/ISO8061DateFormatWithTZ.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
package com.tle.web.remoting.resteasy;
22

3-
import java.text.DateFormat;
4-
import java.text.DecimalFormat;
5-
import java.text.FieldPosition;
6-
import java.text.NumberFormat;
7-
import java.text.ParsePosition;
3+
import java.text.*;
84
import java.util.Calendar;
95
import java.util.Date;
106
import java.util.GregorianCalendar;
@@ -46,8 +42,11 @@ public Date parse(String source, ParsePosition pos)
4642
{
4743
toParse = toParse + "T00:00:00Z";
4844
}
49-
pos.setIndex(toParse.length());
50-
return ISO8601Utils.parse(toParse);
45+
try {
46+
return ISO8601Utils.parse(toParse, pos);
47+
} catch (ParseException e) {
48+
throw new RuntimeException(e);
49+
}
5150
}
5251

5352
// Sonar has trouble determining that superclass implements cloneable
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
lazy val Z3950 = config("z3950") describedAs("Z3950 jars")
2+
3+
libraryDependencies += "org.jafer" % "z3950" % "1.1" % Z3950
4+
5+
excludeDependencies := Seq(
6+
"commons-collections" % "commons-collections",
7+
"xalan" % "xalan",
8+
"xalan" % "serializer",
9+
"xml-apis" % "xml-apis"
10+
)
11+
12+
ivyConfigurations := overrideConfigs(Z3950)(ivyConfigurations.value)
13+
14+
jpfLibraryJars := Classpaths.managedJars(Z3950, Set("jar"), update.value)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
libraryDependencies += "org.dspace.oclc" % "oclc-srw" % "1.0.20080328"
2+

Source/Plugins/Server/com.tle.core.entity.services/src/com/tle/core/services/impl/XsltServiceImpl.java

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public XsltServiceImpl()
5252
xsltCache = new WeakHashMap<String, Pair<Long, Templates>>();
5353
stringXsltCache = new WeakHashMap<String, Templates>();
5454
factory = TransformerFactory.newInstance();
55-
factory.setAttribute("debug", true); //$NON-NLS-1$
5655
}
5756

5857
@Override

Source/Plugins/Server/com.tle.web.endpoint.srw-frag/.classpath

-7
This file was deleted.

Source/Plugins/Server/com.tle.web.endpoint.srw-frag/.project

-23
This file was deleted.

Source/Plugins/Server/com.tle.web.endpoint.srw-frag/build.xml

-5
This file was deleted.

0 commit comments

Comments
 (0)