-
Notifications
You must be signed in to change notification settings - Fork 5
Startup Java Project Configuration #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f4a9810
Initial travis configuration
viniciusam 235c777
Fix docker cfg cache dir
viniciusam a67dcf5
Fix install script
viniciusam ab00b9c
Overriding default test parameters
viniciusam b0d21d7
Initial maven project config
viniciusam d86079e
Using default test cmd
viniciusam 0d4837a
Added oracle maven server config
viniciusam 7676add
Fix maven settings placeholder and added verbosity
viniciusam c0d2766
Making test cmd use custom settings.xml
viniciusam c31c681
Trying to setup oracle maven credentials
viniciusam e109009
Trying settings.xml with env vars
viniciusam 228d3dc
Adding some debug
viniciusam 45c88d0
Trying to use downloaded maven version
viniciusam 9162ffa
Using http-wagon recommended by oracle
viniciusam 6d3a9f8
Code cleanup
viniciusam 1e25bc5
Removing IDE files
viniciusam 8ca4248
Api development startup
viniciusam b04f4be
Calling right function to run tests and typo fix
viniciusam 9811c23
Small api changes
viniciusam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# IntelliJ | ||
*.iml | ||
.idea/ | ||
|
||
# Maven | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
|
||
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) | ||
!/.mvn/wrapper/maven-wrapper.jar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
sudo: required | ||
language: java | ||
|
||
services: | ||
- docker | ||
|
||
jdk: | ||
# - oraclejdk7 | ||
- oraclejdk8 | ||
|
||
env: | ||
global: | ||
- DOCKER_CFG=$HOME/.docker | ||
- DOCKER_REPO="viniciusam/oracledb" | ||
- MAVEN_HOME=/usr/local/maven | ||
- UTPLSQL_VERSION="v3.0.0-beta" | ||
- UTPLSQL_FILE="utPLSQLv3.0.0.562-beta" | ||
matrix: | ||
- ORACLE_VERSION="11g-xe-r2" CONNECTION_STR="127.0.0.1:1521/XE" DOCKER_OPTIONS="--shm-size=1g" | ||
|
||
cache: | ||
directories: | ||
- $DOCKER_CFG | ||
- $HOME/.m2 | ||
- $MAVEN_HOME/lib/ext # Used to cache wagon-http lib. | ||
|
||
install: | ||
- bash .travis/maven_cfg.sh | ||
- bash .travis/start_db.sh | ||
- bash .travis/install_utplsql.sh | ||
|
||
script: | ||
- mvn test -B |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
set -ev | ||
|
||
# Download the specified version of utPLSQL. | ||
curl -L -O "https://github.com/utPLSQL/utPLSQL/releases/download/$UTPLSQL_VERSION/$UTPLSQL_FILE.tar.gz" | ||
|
||
# Create a temporary install script. | ||
cat > install.sh.tmp <<EOF | ||
tar -xzf $UTPLSQL_FILE.tar.gz | ||
rm $UTPLSQL_FILE.tar.gz | ||
cd /$UTPLSQL_FILE/source | ||
sqlplus -S -L sys/oracle@//$CONNECTION_STR AS SYSDBA @install_headless.sql | ||
EOF | ||
|
||
# Copy utPLSQL files to the container and install it. | ||
docker cp ./$UTPLSQL_FILE.tar.gz $ORACLE_VERSION:/$UTPLSQL_FILE.tar.gz | ||
docker cp ./install.sh.tmp $ORACLE_VERSION:/install.sh | ||
|
||
# Remove temporary files. | ||
rm $UTPLSQL_FILE.tar.gz | ||
rm install.sh.tmp | ||
|
||
# Execute the utPLSQL installation inside the container. | ||
docker exec $ORACLE_VERSION bash install.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
set -ev | ||
cd $(dirname $(readlink -f $0)) | ||
|
||
mavenSettings=$HOME/.m2/settings.xml | ||
mavenCached=$HOME/.m2/.cached | ||
|
||
if [ -f $mavenCached ]; then | ||
echo "Using cached maven user config..." | ||
exit 0 | ||
fi | ||
|
||
if [ "$ORACLE_OTN_USER" == "" ] || [ "$ORACLE_OTN_PASSWORD" == "" ]; then | ||
echo "Oracle OTN username/password not specified." | ||
exit 1 | ||
fi | ||
|
||
# Download wagon-http recommended by Oracle. | ||
# On maven latest version this is not needed, but travis doesn't have it. | ||
curl -L -O "http://central.maven.org/maven2/org/apache/maven/wagon/wagon-http/2.8/wagon-http-2.8-shaded.jar" | ||
sudo mv wagon-http-2.8-shaded.jar $MAVEN_HOME/lib/ext/ | ||
|
||
# Create the settings file with oracle server config. | ||
cp settings.tmpl.xml $mavenSettings | ||
sed -i -e "s|###USERNAME###|$ORACLE_OTN_USER|g" $mavenSettings | ||
sed -i -e "s|###PASSWORD###|$ORACLE_OTN_PASSWORD|g" $mavenSettings | ||
|
||
touch $mavenCached |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
|
||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> | ||
|
||
<servers> | ||
<server> | ||
<id>maven.oracle.com</id> | ||
<username>###USERNAME###</username> | ||
<password>###PASSWORD###</password> | ||
<configuration> | ||
<basicAuthScope> | ||
<host>ANY</host> | ||
<port>ANY</port> | ||
<realm>OAM 11g</realm> | ||
</basicAuthScope> | ||
<httpConfiguration> | ||
<all> | ||
<params> | ||
<property> | ||
<name>http.protocol.allow-circular-redirects</name> | ||
<value>%b,true</value> | ||
</property> | ||
</params> | ||
</all> | ||
</httpConfiguration> | ||
</configuration> | ||
</server> | ||
</servers> | ||
|
||
</settings> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
|
||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> | ||
|
||
<servers> | ||
<server> | ||
<id>maven.oracle.com</id> | ||
<username>${env.ORACLE_OTN_USER}</username> | ||
<password>${env.ORACLE_OTN_PASSWORD}</password> | ||
<configuration> | ||
<basicAuthScope> | ||
<host>ANY</host> | ||
<port>ANY</port> | ||
<realm>OAM 11g</realm> | ||
</basicAuthScope> | ||
<httpConfiguration> | ||
<all> | ||
<params> | ||
<property> | ||
<name>http.protocol.allow-circular-redirects</name> | ||
<value>%b,true</value> | ||
</property> | ||
</params> | ||
</all> | ||
</httpConfiguration> | ||
</configuration> | ||
</server> | ||
</servers> | ||
|
||
</settings> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
set -ev | ||
|
||
# If docker credentials are not cached, do the login. | ||
if [ ! -f $DOCKER_CFG/config.json ]; then | ||
docker login -u "$DOCKER_USER" -p "$DOCKER_PASSWORD" | ||
else | ||
echo "Using docker login from cache..." | ||
fi | ||
|
||
# Pull the specified db version from docker hub. | ||
docker pull $DOCKER_REPO:$ORACLE_VERSION | ||
docker run -d --name $ORACLE_VERSION $DOCKER_OPTIONS -p 1521:1521 $DOCKER_REPO:$ORACLE_VERSION | ||
docker logs -f $ORACLE_VERSION | grep -m 1 "DATABASE IS READY TO USE!" --line-buffered |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
##### Configuring the Oracle Maven Repository ##### | ||
http://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9010 | ||
https://blogs.oracle.com/dev2dev/entry/how_to_get_oracle_jdbc#pom | ||
|
||
##### IntelliJ IDEA Maven Module ##### | ||
https://www.jetbrains.com/help/idea/2017.1/maven.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.github.utplsql</groupId> | ||
<artifactId>java-api</artifactId> | ||
<version>1.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>utPLSQL-java-api</name> | ||
<url>https://github.com/utPLSQL/utPLSQL-java-api</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.oracle.jdbc</groupId> | ||
<artifactId>ojdbc7</artifactId> | ||
<version>12.1.0.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<!--<build>--> | ||
<!--<plugins>--> | ||
<!--<plugin>--> | ||
<!--<groupId>net.orfjackal.retrolambda</groupId>--> | ||
<!--<artifactId>retrolambda-maven-plugin</artifactId>--> | ||
<!--<version>2.5.1</version>--> | ||
<!--<executions>--> | ||
<!--<execution>--> | ||
<!--<goals>--> | ||
<!--<goal>process-main</goal>--> | ||
<!--<goal>process-test</goal>--> | ||
<!--</goals>--> | ||
<!--</execution>--> | ||
<!--</executions>--> | ||
<!--</plugin>--> | ||
<!--</plugins>--> | ||
<!--</build>--> | ||
|
||
<repositories> | ||
<repository> | ||
<id>maven.oracle.com</id> | ||
<releases> | ||
<enabled>true</enabled> | ||
</releases> | ||
<snapshots> | ||
<enabled>false</enabled> | ||
</snapshots> | ||
<url>https://maven.oracle.com</url> | ||
<layout>default</layout> | ||
</repository> | ||
</repositories> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>maven.oracle.com</id> | ||
<url>https://maven.oracle.com</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package io.github.utplsql; | ||
|
||
import oracle.jdbc.OracleTypes; | ||
|
||
import java.sql.CallableStatement; | ||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by Vinicius on 13/04/2017. | ||
*/ | ||
public class OutputBuffer { | ||
|
||
private String reporterId; | ||
|
||
public OutputBuffer(String reporterId) { | ||
this.reporterId = reporterId; | ||
} | ||
|
||
public String getReporterId() { | ||
return reporterId; | ||
} | ||
|
||
public void setReporterId(String reporterId) { | ||
this.reporterId = reporterId; | ||
} | ||
|
||
public List<String> getLines() throws SQLException { | ||
PreparedStatement preparedStatement = null; | ||
ResultSet resultSet = null; | ||
try { | ||
preparedStatement = UTPLSQL.getConnection() | ||
.prepareStatement("SELECT * FROM TABLE(ut_output_buffer.get_lines(?, 1))"); | ||
|
||
preparedStatement.setString(1, getReporterId()); | ||
resultSet = preparedStatement.executeQuery(); | ||
|
||
List<String> outputLines = new ArrayList<>(); | ||
while (resultSet.next()) { | ||
outputLines.add(resultSet.getString(1)); | ||
} | ||
return outputLines; | ||
} finally { | ||
if (resultSet != null) | ||
resultSet.close(); | ||
if (preparedStatement != null) | ||
preparedStatement.close(); | ||
} | ||
} | ||
|
||
public List<String> getAllLines() throws SQLException { | ||
CallableStatement callableStatement = null; | ||
ResultSet resultSet = null; | ||
try { | ||
callableStatement = UTPLSQL.getConnection() | ||
.prepareCall("BEGIN ? := ut_output_buffer.get_lines_cursor(?); END;"); | ||
|
||
callableStatement.registerOutParameter(1, OracleTypes.CURSOR); | ||
callableStatement.setString(2, getReporterId()); | ||
callableStatement.execute(); | ||
|
||
resultSet = (ResultSet) callableStatement.getObject(1); | ||
|
||
List<String> outputLines = new ArrayList<>(); | ||
while (resultSet.next()) { | ||
outputLines.add(resultSet.getString("text")); | ||
} | ||
return outputLines; | ||
} finally { | ||
if (resultSet != null) | ||
resultSet.close(); | ||
if (callableStatement != null) | ||
callableStatement.close(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use java7 driver or go ahead with java8?
Maybe entire project should be build on java7?
Or do we want 2 separate builds with java7 and java8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to use Java 8 because of lambda expressions and try with resources. But if we want to support both drivers, we can't use those new features anyways.
We could start with the Java 7 and add support to the newest later.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me.
Probably for Java8 we will need a separate branch/project then :(