Skip to content

Commit 17838a3

Browse files
committed
Removed jar from repository - pom will now build an artifact with
everything needed to run. improved jdbc.js (simplier + can handle path set to look for libs)
1 parent 3cb34cf commit 17838a3

File tree

6 files changed

+79
-22
lines changed

6 files changed

+79
-22
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ external_libs/
1111
# but some examples might have eclipse projects in them
1212
/.classpath
1313
/.project
14-
/.settings/
14+
/.settings/
15+
16+
# ignore jars in examples
17+
examples/**/*.jar

examples/studio_integration/jdbc.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,37 @@
88
// Before running this sample, please review and setup the following
99
//
1010

11-
// OPL_JDBC_DRIVER points to the jar for the jdbc driver you want to use.
12-
var jdbc_driver = IloOplGetEnv("OPL_JDBC_DRIVER");
13-
if (! jdbc_driver ) {
14-
jdbc_driver = "../../external_libs/mssql-jdbc-7.2.2.jre8.jar"; // default for this project
15-
}
11+
// EDIT: you want to change this for your actual driver
12+
var jdbc_driver = "mssql-jdbc-7.4.1.jre8.jar"
13+
// EDIT: specify where to look for the jdbc driver. Default is in . (besides this .js script) and in ../../external_libs
14+
var jdbc_driver_path = ".;../../external_libs"
1615

17-
// OPL_JDBC_LIBS points to the directory containing the library needed for this sample.
18-
// You want to put jdbc-custom-data-source.jar there.
19-
var libs = IloOplGetEnv("OPL_JDBC_LIBS");
20-
if (! libs ) {
21-
libs = "../../lib"; // default value use the lib at the root of this project
22-
}
2316

17+
// EDIT: specfify where jdbc-custom-data-source is of the github project.
18+
// default is to look in . and ../../lib
19+
var libs = ".;../../lib";
2420

2521
//
2622
// From this point, nothing is to be edited.
2723
//
2824

29-
// Update this to point to your jdbc driver.
30-
IloOplImportJava(jdbc_driver)
31-
25+
// import all drivers in jdbc_driver, separated by ;. This allows to be stored at different default locations.
26+
var drivers = jdbc_driver_path.split(";");
27+
for (var i=0; i < drivers.length; i++) {
28+
IloOplImportJava(drivers[i] + "/" + jdbc_driver)
29+
}
3230

31+
// load the driver specified by environment variable if this exists.
32+
var jdbc_driver_env = IloOplGetEnv("OPL_JDBC_DRIVER");
33+
if ( jdbc_driver_env ) {
34+
IloOplImportJava(jdbc_driver_env);
35+
}
3336

3437
// The jar containing the jdbc custom data source
35-
IloOplImportJava(libs + "/jdbc-custom-data-source.jar");
38+
var lib_locations = libs.split(";");
39+
for (var i=0; i < lib_locations.length; i++) {
40+
IloOplImportJava(lib_locations[i] + "/jdbc-custom-data-source.jar");
41+
}
3642

3743
function JDBCConnector(url) {
3844
// Now create JdbcConfiguration

lib/jdbc-custom-data-source.jar

-23.8 KB
Binary file not shown.

pom.xml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77

88
<groupId>com.ibm.optim.opl</groupId>
99
<artifactId>jdbc-custom-data-source</artifactId>
10-
<version>1.0-SNAPSHOT</version>
10+
<version>1.2-master</version>
1111
<packaging>jar</packaging>
1212

1313
<properties>
1414
<jdk.version>1.7</jdk.version>
15-
<cplex_home>${env.CPLEX_STUDIO_DIR128}</cplex_home>
16-
<cplex_version>12.8.0.0</cplex_version>
15+
<cplex_home>${env.CPLEX_STUDIO_DIR129}</cplex_home>
16+
<cplex_version>12.9.0.0</cplex_version>
1717
</properties>
1818

1919
<dependencies>
2020
<dependency>
2121
<!-- To install oplall.jar on your machine, do something like:
22-
mvn install:install-file "-Dfile=%CPLEX_STUDIO_DIR128%\opl\lib\oplall.jar" -DgroupId=com.ibm.ilog.optim -DartifactId=oplall -Dversion=12.8.0.0 -Dpackaging=jar
22+
mvn install:install-file "-Dfile=%CPLEX_STUDIO_DIR129%\opl\lib\oplall.jar" -DgroupId=com.ibm.ilog.optim -DartifactId=oplall -Dversion=12.9.0.0 -Dpackaging=jar
2323
-->
2424
<groupId>com.ibm.ilog.optim</groupId>
2525
<artifactId>oplall</artifactId>
@@ -62,11 +62,30 @@
6262
<archive>
6363
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
6464
<manifestEntries>
65-
<Specification-Version>${version}</Specification-Version>
65+
<Specification-Version>${project.version}</Specification-Version>
6666
</manifestEntries>
6767
</archive>
6868
</configuration>
6969
</plugin>
70+
71+
<plugin>
72+
<groupId>org.apache.maven.plugins</groupId>
73+
<artifactId>maven-assembly-plugin</artifactId>
74+
<executions>
75+
<execution>
76+
<phase>package</phase>
77+
<goals>
78+
<goal>single</goal>
79+
</goals>
80+
<configuration>
81+
<appendAssemblyId>true</appendAssemblyId>
82+
<descriptors>
83+
<descriptor>src/main/assembly/distrib.xml</descriptor>
84+
</descriptors>
85+
</configuration>
86+
</execution>
87+
</executions>
88+
</plugin>
7089
</plugins>
7190
</build>
7291
</project>

src/main/assembly/distrib.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
4+
<!-- This is the assembly descriptor for the whole docplex project (mp+cp) -->
5+
6+
<id>opl_jdbc</id>
7+
<baseDirectory>/</baseDirectory>
8+
<formats>
9+
<format>zip</format>
10+
</formats>
11+
12+
<includeBaseDirectory>false</includeBaseDirectory>component>
13+
14+
<fileSets>
15+
<fileSet>
16+
<directory>${project.basedir}/examples/studio_integration</directory>
17+
<outputDirectory>/opl_jdbc</outputDirectory>
18+
<includes>
19+
<include>jdbc.js</include>
20+
</includes>
21+
</fileSet>
22+
</fileSets>
23+
24+
<files>
25+
<file>
26+
<source>target/${project.artifactId}-${project.version}.jar</source>
27+
<destName>opl_jdbc/${project.artifactId}.jar</destName>
28+
</file>
29+
</files>
30+
</assembly>
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Specification-Title: JDBC custom data source for OPL
2-
Specification-Version: 1.1
32
Specification-Vendor: IBM

0 commit comments

Comments
 (0)