maven编译后的jar包排除java源文件

pom.xml

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
		  <configuration>
		    <excludes>
		      <exclude>/**.java</exclude>
		    </excludes>
		  </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.0.1</version>
		  <executions>
		 	 <execution>
		 		 <phase>package</phase>
		 		 <goals>
		 			 <goal>jar-no-fork</goal>
		 		 </goals>
		 	 </execution>
		  </executions>		  
        </plugin>

js ungzip

  1. 先安装好pako
    npm install -g pako
    在pako dist下找到pako_inflate.min.js,大概23k
  2. 自己写个js,然后gzip成1.js.gz
  3. index.html如下:
<!DOCTYPE html>
<html>
<body>
<script src="pako_inflate.min.js"></script>
<script>
	var aryBuffer = [];
fetch('1.js.gz').then(response => {
    var reader = response.body.getReader();
    var bytesReceived = 0;

    reader.read().then(function processResult(result) {
        if (result.done) {
            console.log("Fetch complete");
			var data = pako.inflate(aryBuffer[0]);
			console.log(data);
			var strData = String.fromCharCode.apply(null, new Uint16Array(data));
			console.log(strData);
			
			var sc = document.createElement('script');
			sc.innerHTML = strData;
			document.body.appendChild(sc);
            return;
        }

        bytesReceived += result.value.length;
		aryBuffer.push(result.value);
		
        console.log("Received", bytesReceived, "bytes of data so far");
        console.log(result.value);

        return reader.read().then(processResult);
    });
});

</script>
</body>

</html>

打开后就会运行1.js中的脚本啦!