Add the following entry to gradle.properties:
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
Add the following entry to gradle.properties:
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
Download the gradle binary from the following address:
https://services.gradle.org/distributions/
For example gradle-7.4-all.zip.
Place the downloaded gradle binary to the gradle/wrapper directory of the gradle project.
Update the wrapper configuration (i.e. gradle/wrapper/gradle-wrapper.properties) like the following:
If you've downloaded gradle-7.4-all.zip binary from step 1.
distributionBase=PROJECT
distributionPath=wrapper/dists
distributionUrl=gradle-7.4-all.zip
zipStoreBase=PROJECT
zipStorePath=wrapper/dists
Create settings.gradle file with the following content:
rootProject.name = 'download-dependecies'
Create build.gradle file with the following content:
plugins {
id 'application'
}
group 'xyz.ronella.gradle'
version '1.0.0'
repositories {
mavenCentral()
}
dependencies {
//Add all the target dependencies here
implementation 'org.apache.poi:poi:3.5-FINAL'
}
task download(group: 'resolver') {
doFirst {
ant.delete(dir: 'libs')
ant.mkdir(dir: 'libs')
}
doLast {
copy {
from sourceSets.main.runtimeClasspath
into 'libs/'
}
def outputFile = "${project.buildDir}\\${project.name}-${version}.zip"
ant.zip(basedir: "${file('libs')}", destfile: "${outputFile}", excludes: '*.class')
println "Output: ${outputFile}"
ant.delete(dir: 'libs')
}
}
Run the following gradle command:
gradle download
If you are using the gradle wrapper, use the following command:
gradlew download
Maven | Gradle | Comment |
---|---|---|
compile | api if the dependency should be exposed to consumers. implementation if the dependency should not be exposed to consumers. |
|
provided | compileOnly | Maven provided is also available at runtime. Gradle compileOnly is limited to compile only. |
runtime | runtimeOnly | |
test | testImplementation |
compile group: 'org.apache.derby', name: 'derby', version: '10.15.1.3' compile group: 'org.apache.derby', name: 'derbyshared', version: '10.15.1.3'
requires org.apache.derby.engine; requires org.apache.derby.commons; requires java.sql;
final String DATABASE_NAME = "sample_table"; String connectionURL = String.format("jdbc:derby:%s;create=true", DATABASE_NAME); connection = DriverManager.getConnection(connectionURL);
connection.close(); boolean gotSQLExc = false; try { //shutdown all databases and the Derby engine DriverManager.getConnection("jdbc:derby:;shutdown=true"); } catch (SQLException se) { if ( se.getSQLState().equals("XJ015") ) { gotSQLExc = true; } } if (!gotSQLExc) { System.out.println("Database did not shut down normally"); }
A clean shutdown always throws SQL exception XJ015, which can be ignored.
nexusUsername=<SONATYPE_USERNAME> nexusPassword=<SONATYPE_PASSWORD> signing.keyId=<PGP_PUBLIC_KEY_ID> signing.password=<PGP_PASS_PHRASE> signing.secretKeyRingFile=<PGP_EXPORTED_PRIVATE_KEY>
plugins { id "java" id "com.bmuschko.nexus" version "2.3.1" // Gradle Sonatype Nexus Plugin }
modifyPom { project { name '<PROJECT_NAME>' description '<PROJECT_DESCRIPTION>' url '<PROJECT_WEBSITE>' inceptionYear '<PROJECT_INCEPTION_YEAR>' scm { url '<PROJECT_SCM_ADDRESS>' connection '<PROJECT_SCM_ADDRESS>' developerConnection '<PROJECT_SCM_ADDRESS>' } licenses { license { name '<PROJECT_LICENSE_NAME>' url '<PROJECT_LICENSE_ADDRESS>' distribution 'repo' } } developers { developer { id '<DEVELOPER_ID>' name '<DEVELOPER_NAME>' email '<DEVELOPER_EMAIL>' } } } } extraArchive { sources = true tests = true javadoc = true } nexus { sign = true repositoryUrl = '<SONATYPE_RELEASE_REPOSITORY>' snapshotRepositoryUrl = '<SONATYPE_SNAPSHOT_REPOSITORY>' }
plugins { id 'java' id "com.bmuschko.nexus" version "2.3.1" // Gradle Sonatype Nexux Plugin id "io.codearte.nexus-staging" version "0.21.1" // Gradle Nexus Staging Plugin }
gradlew getStagingProfile
nexusStaging { stagingProfileId = "<STAGING_PROFILE_ID>" }
Run the following command:
gradlew uploadArchives
Run the following command:
gradlew closeAndReleaseRepository
If there are any errors after running the preceding command
Do this error correction process until all the errors were corrected.
After around 10 minutes, navigate to your registered group id from sonatype, starting from the following address:
https://repo.maven.apache.org/maven2/
After around 2 hours, your artifact id may be searchable in maven central from the following address:
<USER_HOME>/.gradle
systemProp.http.proxyHost=<PROXY_HOST> systemProp.http.proxyPort=<PROXY_PORT> systemProp.http.proxyUser=<PROXY_USERNAME> systemProp.http.proxyPassword=<PROXY_PASSWORD> systemProp.http.nonProxyHosts=<NON_PROXY_HOSTS>
Note: <NON_PROXY_HOSTS> is delimited by pipe symbol (e.g. localhost|*.test.net)
Note: If https proxy configuration is needed use the same entries except that all http will must be replaced with https (e.g. systemProp.https.proxyHost).