convert maven jar and copy resources plugin to gradle -


i new gradle , trying convert pom gradle.build. have convert dependencies part , converting plugin part. have following in pom

<plugin>     <groupid>org.apache.maven.plugins</groupid>     <artifactid>maven-dependency-plugin</artifactid>     <version>${maven-dependency-plugin.version}</version>     <executions>         <execution>             <id>copy-dependencies</id>             <phase>package</phase>             <goals>                 <goal>copy-dependencies</goal>             </goals>             <configuration>                 <includegroupids>                     junit, org.apache.logging.log4j, org.springframework, aopalliance, org.springframework.data, javax.inject,                          org.hibernate, javax.el, com.microsoft.sqlserver, org.apache.commons, com.jcraft, com.sun.mail,                          org.apache.velocity, commons-lang, commons-logging, commons-collections, org.jboss.logging,                          org.jboss, org.javassist, dom4j, javax.transaction                 </includegroupids>                 <outputdirectory>${project.build.directory}/dependency-jars/</outputdirectory>                 <overwritereleases>false</overwritereleases>                 <overwritesnapshots>false</overwritesnapshots>                 <overwriteifnewer>true</overwriteifnewer>             </configuration>         </execution>      </executions> </plugin>  <plugin>     <groupid>org.apache.maven.plugins</groupid>     <artifactid>maven-jar-plugin</artifactid>     <version>${maven-jar-plugin.version}</version>     <configuration>         <excludes>             <exclude>**/*.properties</exclude>             <exclude>**/*.xml</exclude>             <exclude>**/*.vm</exclude>             <exclude>**/*.txt</exclude>         </excludes>         <archive>             <manifest>                 <addclasspath>true</addclasspath>                 <classpathprefix>dependency-jars/</classpathprefix>             <mainclass>com.softech.ls360.integration.batchimport</mainclass>                 </manifest>             <manifestentries>                 <class-path>conf/</class-path>             </manifestentries>          </archive>     </configuration> </plugin> <plugin>     <groupid>org.apache.maven.plugins</groupid>     <artifactid>maven-resources-plugin</artifactid>     <version>2.6</version>     <executions>         <execution>             <id>copy-resources</id>             <phase>install</phase>             <goals>                 <goal>copy-resources</goal>             </goals>             <configuration>                 <outputdirectory>${basedir}/target/conf</outputdirectory>                 <resources>                     <resource>                         <directory>src/main/resources</directory>                         <includes>                             <include>**/*.properties</include>                             <include>**/*.xml</include>                             <include>**/*.vm</include>                             <include>**/*.txt</include>                         </includes>                     </resource>                 </resources>             </configuration>         </execution>     </executions> </plugin> 

when ran pom got structure this

project structure

dependency-jars folder

conf folder

now tried following gradle jar task

apply plugin: 'application' // implicitly apply java , distribution plugin apply plugin: 'eclipse'  sourcecompatibility = 1.8 targetcompatibility = sourcecompatibility mainclassname = "com.softech.ls360.integration.batchimport" version = '1.0'  ext {     log4jgroupid = "org.apache.logging.log4j"     springframeworkgroupid = "org.springframework"     springframeworkversion = "4.2.4.release"     junitversion = "4.12"     .... }  dependencies {     compile group: log4jgroupid, name: 'log4j-api', version: log4jversion     ....     runtime group: 'org.jboss.logging', name: 'jboss-logging', version: jbossloggingversion     ....     testcompile group: 'junit', name: 'junit', version: junitversion }  jar {      // keep jar clean:     exclude '**/*.properties', '**/*.xml', '**/*.vm', '**/*.txt'      //from { configurations.compile.collect { it.isdirectory() ? : ziptree(it) } }     manifest {         attributes ('implementation-version': version,            'main-class': "$mainclassname",            'class-path': "conf/" + " " + configurations.runtime.files.collect {"dependency-jars/$it.name" }.join(' ')        )     } } 

then got following jar

enter image description here

it generate proper class path in jar. build/libs/ folder contain jar, there no dependency-jars , conf folders in it. how can create these folders, when run task jar, creates jar in build/libs/ folder, create dependency-jars folder jars in it. , conf folder in build/libs, .propeties, .xml, .vm, .txtfiles src/main/resources/ folder.

thanks

hhmm tried following , worked. don't know how approach is. if has better way please post answer too.

.... task wrapper(type: wrapper) {     gradleversion = '2.10' }  task copyjars(type: copy) {     configurations.runtime     "$builddir/libs/dependency-jars" }  task copyconfigurationfiles(type: copy) {     description 'copies configurations files src/main/resources directory (from) target directory(into).'     "src/main/resources"     "$builddir/libs/conf"     include '**/*.properties', '**/*.xml', '**/*.vm', '**/*.txt' }  task copyfiles(dependson: [copyjars, copyconfigurationfiles])  jar {      dependson copyfiles      // keep jar clean:     exclude '**/*.properties', '**/*.xml', '**/*.vm', '**/*.txt'      manifest {          attributes ('implementation-version': version,            'main-class': "$mainclassname",            'class-path': "conf/" + " " + configurations.runtime.files.collect {"dependency-jars/$it.name" }.join(' ')        )     } } 

after run task jar. , created jar, dependency-jars folder jars in , conf folder configuration files in it. when did maven install

thanks


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -