Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
BZ1201154: KJARs deployed with mvn deploy:deploy-file are not being l…
Browse files Browse the repository at this point in the history
…isted in Workbench Artifact Repository
  • Loading branch information
manstis committed Mar 12, 2015
1 parent 202821f commit d770a5c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Expand Up @@ -28,8 +28,10 @@
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
Expand Down Expand Up @@ -459,12 +461,16 @@ public Collection<File> listFiles() {
* @return an collection of java.io.File with the matching files
*/
public Collection<File> listFiles( final String filters ) {
String wildcard = "*.jar";
if ( filters != null ) {
wildcard = "*" + filters + "*.jar";
final List<String> wildcards = new ArrayList<String>();
if ( filters == null ) {
wildcards.add( "*.jar" );
wildcards.add( "*.kjar" );
} else {
wildcards.add( "*" + filters + "*.jar" );
wildcards.add( "*" + filters + "*.kjar" );

This comment has been minimized.

Copy link
@psiroky

psiroky Mar 12, 2015

Contributor

I am probably missing context here, but I am wondering if we should support file extension "kjar"? Even though the kjars have some additional metadata, they are still ordinary jar files. Using "kjar" extension will confuse other tools for sure.

This comment has been minimized.

Copy link
@manstis

manstis Mar 12, 2015

Author Member

AFAIK the packaging of the KIE Maven Plugin is KJAR.. so we have files with the KJAR extension (that is most certainly what the User - reporting the BZ - expected too). That said, armed with what I believed to be true, I looked at the KIE Maven Plugin and cannot see that it creates files with the KJAR extension. Do you know what's meant to be happening (I see you've commited to the plugin in the past).

This comment has been minimized.

Copy link
@manstis

manstis Mar 12, 2015

Author Member

I am growing more convinced that I'm wrong.. I added the KIE Maven Plugin to the build/plugins for uf-playground/mortgages and a JAR was produced.. that said, I'm not entirely confident the KIE Plugin actually ran.. as the resulting JAR just contains the DRL sources - whereas I expected it to have pre-compiled the DRL and stored in somewhere (where, IDK).

This comment has been minimized.

Copy link
@manstis

manstis Mar 12, 2015

Author Member

Log for my compilation:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building mortgages 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ mortgages ---
[INFO] Deleting /home/manstis/Desktop/temp/uf-playground/mortgages/target
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ mortgages ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 13 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ mortgages ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 4 source files to /home/manstis/Desktop/temp/uf-playground/mortgages/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ mortgages ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 7 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ mortgages ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ mortgages ---
[INFO] Surefire report directory: /home/manstis/Desktop/temp/uf-playground/mortgages/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ mortgages ---
[INFO] Building jar: /home/manstis/Desktop/temp/uf-playground/mortgages/target/mortgages-0.0.1.jar
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ mortgages ---
[INFO] Installing /home/manstis/Desktop/temp/uf-playground/mortgages/target/mortgages-0.0.1.jar to /home/manstis/.m2/repository/mortgages/mortgages/0.0.1/mortgages-0.0.1.jar
[INFO] Installing /home/manstis/Desktop/temp/uf-playground/mortgages/pom.xml to /home/manstis/.m2/repository/mortgages/mortgages/0.0.1/mortgages-0.0.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.983s
[INFO] Finished at: Thu Mar 12 16:58:22 GMT 2015
[INFO] Final Memory: 18M/439M
[INFO] ------------------------------------------------------------------------


No sign of the KIE Plugin actually running.

This comment has been minimized.

Copy link
@manstis

manstis Mar 12, 2015

Author Member
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>mortgages</groupId>
  <artifactId>mortgages</artifactId>
  <version>0.0.1</version>
  <repositories>
    <repository>
      <id>guvnor-m2-repo</id>
      <name>Guvnor M2 Repo</name>
      <url>http://localhost/maven2/</url>
    </repository>
  </repositories>

<dependencies>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>6.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.kie</groupId>
        <artifactId>kie-maven-plugin</artifactId>
        <version>6.3.0-SNAPSHOT</version>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>

</project>

This comment has been minimized.

Copy link
@psiroky

psiroky Mar 12, 2015

Contributor

Yeah, this may be definitely confusing. The kjars have packaging "kjar", but the actual file extension "jar". The packaging does not always correspond to the actual file extension.

I have looked at the related BZ and they are using -Dpackaging=kjar so the maven deploy plugin uses that extension. I am not really sure why though. I would expect the file extension stays the same, but this seems to a special case with the deploy plugin.

Looking here https://github.com/guvnorngtestuser1/guvnorng-playground/blob/master/mortgages/pom.xml the project does not have the packaging set to "kjar" (+ the kie-maven-plugin needs to be defined under <build>), so Maven treats it as ordinary jar.

This comment has been minimized.

Copy link
@psiroky

This comment has been minimized.

Copy link
@psiroky

psiroky Mar 12, 2015

Contributor

I think the "kjar" extension should not be allowed, because it will break also other things. For example one can no longer easily depend on the kjars, since Maven by default does not know about this packaging. The jars are very universal on the other hand.

@etirelli, @mariofusco what do you think about this - using ".kjar" file extension (instead of plain ".jar") for kjars

This comment has been minimized.

Copy link
@psiroky

psiroky Mar 12, 2015

Contributor

One more example of different packaging X extension: drools-core is using packaging "bundle", but the final artifact is plain jar with OSGi metadata, see https://github.com/droolsjbpm/drools/blob/master/drools-core/pom.xml#L13

}
Collection<File> files = FileUtils.listFiles( new File( M2_REPO_DIR ),
new WildcardFileFilter( wildcard,
new WildcardFileFilter( wildcards,
IOCase.INSENSITIVE ),
DirectoryFileFilter.DIRECTORY );

Expand Down
Expand Up @@ -29,14 +29,12 @@
import org.guvnor.m2repo.backend.server.helpers.FormData;
import org.guvnor.m2repo.backend.server.helpers.HttpPostHelper;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.junit.Assert.*;

@Ignore
public class M2RepositoryTest {

private static final Logger log = LoggerFactory.getLogger( M2RepositoryTest.class );
Expand Down Expand Up @@ -68,7 +66,6 @@ public static boolean deleteDir( File dir ) {
}

@Test
@Ignore("Fails - ignored for Beta3")
public void testDeployArtifact() throws Exception {
GuvnorM2Repository repo = new GuvnorM2Repository();
repo.init();
Expand All @@ -90,7 +87,8 @@ public void testDeployArtifact() throws Exception {
if ( fileName.startsWith( "guvnor-m2repo-editor-backend-0.0.1" ) && fileName.endsWith( ".jar" ) ) {
found = true;
String path = file.getPath();
String pom = GuvnorM2Repository.loadPOMFromJar( path );
String jarPath = path.substring( GuvnorM2Repository.M2_REPO_DIR.length() + 1 );
String pom = GuvnorM2Repository.loadPOMFromJar( jarPath );
assertNotNull( pom );
break;
}
Expand Down

0 comments on commit d770a5c

Please sign in to comment.