Skip to content

Commit

Permalink
Merge pull request #3151 from grandinj/sonatype_lift1
Browse files Browse the repository at this point in the history
Attemping to get sonatype lift working
  • Loading branch information
grandinj committed Aug 5, 2021
2 parents 4082c9d + c4420f9 commit 0ee51f5
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 132 deletions.
8 changes: 8 additions & 0 deletions .lift.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Config file for SonaType Lift analysis tool
#
# config reference here: https://help.sonatype.com/lift/configuration-reference
#

# Tell sonatype where our pom file lives, so it can build it again
#
build = "maven -f h2/pom.xml compile"
1 change: 0 additions & 1 deletion h2/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ test.out.txt
.idea/
*.log
target/
src/main/org/h2/res/help.csv
_tmp*
31 changes: 0 additions & 31 deletions h2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,37 +212,6 @@
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-files-exist</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireFilesExist>
<files>
<file>src/main/org/h2/res/help.csv</file>
</files>
<message>
<![CDATA[
--------------------------------------------------------------------------------
!!! Run "./build.cmd compile" or "./build.sh compile" first, !!!
!!! as described in MAVED.md !!!
--------------------------------------------------------------------------------
]]>
</message>
</requireFilesExist>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions h2/src/main/org/h2/bnf/Bnf.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

import org.h2.bnf.context.DbContextRule;
import org.h2.command.dml.Help;
import org.h2.tools.Csv;
import org.h2.util.StringUtils;
import org.h2.util.Utils;
Expand Down Expand Up @@ -93,7 +93,7 @@ private void parse(Reader reader) throws SQLException, IOException {
continue;
}
String topic = rs.getString("TOPIC");
syntax = rs.getString("SYNTAX").trim();
syntax = Help.stripAnnotationsFromSyntax(rs.getString("SYNTAX"));
currentTopic = section;
tokens = tokenize();
index = 0;
Expand Down
33 changes: 30 additions & 3 deletions h2/src/main/org/h2/command/dml/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,48 @@ public ResultInterface query(long maxrows) {
// TOPIC
ValueVarchar.get(topic, session),
// SYNTAX
ValueVarchar.get(rs.getString(3).trim(), session),
ValueVarchar.get(stripAnnotationsFromSyntax(rs.getString(3)), session),
// TEXT
ValueVarchar.get(rs.getString(4).trim(), session));
ValueVarchar.get(processHelpText(rs.getString(4)), session));
}
} catch (Exception e) {
throw DbException.convert(e);
}
result.done();
return result;
}

public static String stripAnnotationsFromSyntax(String s) {
// SYNTAX column - Strip out the special annotations we use to
// help build the railroad/BNF diagrams.
return s.replaceAll("@c@ ", "").replaceAll("@h2@ ", "")
.replaceAll("@c@", "").replaceAll("@h2@", "").trim();
}

/** process the help text column we load from help.csv */
public static String processHelpText(String s) {
int len = s.length();
int end = 0;
for (; end < len; end++) {
char ch = s.charAt(end);
if (ch == '.') {
end++;
break;
}
if (ch == '"') {
do {
end++;
} while (end < len && s.charAt(end) != '"');
}
}
s = s.substring(0, end);
return s.trim();
}

/**
* Returns HELP table.
*
* @return HELP table
* @return HELP table with columns SECTION,TOPIC,SYNTAX,TEXT
* @throws IOException
* on I/O exception
*/
Expand Down
8 changes: 4 additions & 4 deletions h2/src/main/org/h2/jdbc/meta/DatabaseMetaLocal.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ private String getFunctions(String section) {
if (builder.length() != 0) {
builder.append(',');
}
String f = rs.getString(2).trim();
int spaceIndex = f.indexOf(' ');
String topic = rs.getString(2).trim();
int spaceIndex = topic.indexOf(' ');
if (spaceIndex >= 0) {
// remove 'Function' from 'INSERT Function'
StringUtils.trimSubstring(builder, f, 0, spaceIndex);
StringUtils.trimSubstring(builder, topic, 0, spaceIndex);
} else {
builder.append(f);
builder.append(topic);
}
}
}
Expand Down
File renamed without changes.
32 changes: 24 additions & 8 deletions h2/src/main/org/h2/table/InformationSchemaTableLegacy.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.h2.command.Command;
import org.h2.command.Parser;
import org.h2.command.dml.Help;
import org.h2.constraint.Constraint;
import org.h2.constraint.Constraint.Type;
import org.h2.constraint.ConstraintActionType;
Expand Down Expand Up @@ -1164,25 +1165,40 @@ public ArrayList<Row> generateRows(SessionLocal session, SearchRow first, Search
case HELP: {
String resource = "/org/h2/res/help.csv";
try {
byte[] data = Utils.getResource(resource);
Reader reader = new InputStreamReader(
final byte[] data = Utils.getResource(resource);
final Reader reader = new InputStreamReader(
new ByteArrayInputStream(data));
Csv csv = new Csv();
final Csv csv = new Csv();
csv.setLineCommentCharacter('#');
ResultSet rs = csv.read(reader, null);
final ResultSet rs = csv.read(reader, null);
final int columnCount = rs.getMetaData().getColumnCount() - 1;
final String[] values = new String[5];
for (int i = 0; rs.next(); i++) {
for (int j = 0; j < columnCount; j++) {
String s = rs.getString(1 + j);
switch (j) {
case 2: // SYNTAX column
// Strip out the special annotations we use to help build
// the railroad/BNF diagrams
s = Help.stripAnnotationsFromSyntax(s);
break;
case 3: // TEXT column
s = Help.processHelpText(s);
}
values[j] = s.trim();
}
add(session,
rows,
// ID
ValueInteger.get(i),
// SECTION
rs.getString(1).trim(),
values[0],
// TOPIC
rs.getString(2).trim(),
values[1],
// SYNTAX
rs.getString(3).trim(),
values[2],
// TEXT
rs.getString(4).trim()
values[3]
);
}
} catch (Exception e) {
Expand Down
2 changes: 0 additions & 2 deletions h2/src/tools/org/h2/build/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ public void compile() {
exclude("*/package.html");
copy("temp", files, "src/test");

java("org.h2.build.doc.GenerateHelp", null);
javadoc("-sourcepath", "src/main", "org.h2.tools", "org.h2.jmx",
"-classpath",
"ext/lucene-core-" + LUCENE_VERSION + ".jar" +
Expand Down Expand Up @@ -348,7 +347,6 @@ public void docs() {
java("org.h2.build.code.CheckJavadoc", null);
java("org.h2.build.code.CheckTextFiles", null);
java("org.h2.build.doc.GenerateDoc", null);
java("org.h2.build.doc.GenerateHelp", null);
java("org.h2.build.indexer.Indexer", null);
java("org.h2.build.doc.MergeDocs", null);
java("org.h2.build.doc.WebSite", null);
Expand Down
81 changes: 0 additions & 81 deletions h2/src/tools/org/h2/build/doc/GenerateHelp.java

This file was deleted.

0 comments on commit 0ee51f5

Please sign in to comment.