Why does my jar file not not contain any class files?

Edward

I'm trying to add a task (gen or gen2) to my build.gradle that does exactly the same as the Jar-task:

version = "0.0.1"
apply plugin: 'java'

task('gen', type: Jar) {
}

task gen2(type: Jar)

Running

gradle jar

generates a JAR-file that contains .class-files, while running

gradle gen

or

gradle gen2

generate a JAR-file that does NOT contain any .class-files.

Whats wrong with my class definition?

RaGe

To build a jar with all the classes from main, as a default jar task would, do this:

task gen2(type: Jar){
    baseName = 'gen2Jar'
    from sourceSets.main.output
}

You can also do from(sourceSets.main.output){ include "package" } to customize what packages are included.

Alternatively, to copy settings from the default jar task:

task gen(type: Jar){
    baseName = 'genJar'
    with jar
}

Infact you can have both of these in the same build.gradle. Running gradle jar builds default jar. gradle gen builds genJar.jar and gradle gen2 builds gen2Jar.jar, all of which contain all the classes from java.main

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Jar doesn't contain my class files gitlab-ci

generated jar file does not contain $1 class file

Why are there no class files in the JAR file outputted by ProGuard?

Does a Jar File need .class files to be executable

Why does my SAMLresponse received from ADFS not contain any claims?

Why does my Dmgcanvas installer window contain additional files?

Why does the executable binary file contain paths of included header files?

why does my JSON file contain [object Object]?

Why there is no .class file in my jar file created by gradle?

Why JAR Files Do Not Contain Documentation?

Why does my executable jar not find the main class?

Why does my JAR file execute at CMD, but not on double-click?

Why does Eclipse export my entire project as runnable JAR file?

Does string contain any of the words in my list?

What exactly does a jar file contain?

Does jar file not contain imported packages and classes?

Why does a search engine summary contain text that is not in any of the static html files?

Why useSelector does not contain any data?

Why does my JavaScript file crash without any apparent errors?

Why does my file, sent through TCP, contain more data than the file it self contains?

Why does my pandas list contain duplicates?

Why does my List<Long> contain integers?

Why does my hashset contain duplicates?

Why does my output contain a 0?

Why my docker file does not copy the HTML files?

Why my .bat file for deleting these files does not work?

Why does my bundled file not include all jsx files?

Why does not Warble include .class files in war file?

Is there any way to bundle JSON files to Jar file?