The default package '.' is not permitted by the Import-Package syntax

Hello,

I’m trying to package a plugin using the atlas-package command and I’m receiving the following error:

[ERROR] Manifest com.test.bitbucket:example-project:atlassian-plugin:1.0.0-SNAPSHOT : The default package '.' is not permitted by the Import-Package syntax.
This can be caused by compile errors in Eclipse because Eclipse creates
valid class files regardless of compile errors.
The following package(s) import from the default package [com.test.bitbucket.impl]
[ERROR] Error(s) found in manifest configuration

Here is the com.test.bitbucket.impl import packages for the two files which are in this path:

ExportServiceImpl

package com.test.bitbucket.impl

import com.atlassian.bitbucket.job.Job
import com.atlassian.bitbucket.migration.ExportRequest
import com.atlassian.bitbucket.migration.MigrationService
import com.atlassian.bitbucket.migration.RepositoriesExportRequest
import com.atlassian.bitbucket.migration.RepositorySelector
import com.atlassian.bitbucket.project.ProjectService
import com.atlassian.bitbucket.repository.RepositoryService
import com.atlassian.bitbucket.scope.Scope
import com.atlassian.bitbucket.util.PageRequest
import com.atlassian.bitbucket.util.PageRequestImpl
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport
import com.atlassian.sal.api.component.ComponentLocator
import com.test.bitbucket.api.ExportService
import com.test.bitbucket.util.Constants

import javax.inject.Inject
import javax.inject.Named
import javax.validation.constraints.NotNull
import java.util.stream.Collectors
import java.util.stream.Stream
ImportServiceImpl

package com.test.bitbucket.impl

import com.atlassian.bitbucket.job.Job
import com.atlassian.bitbucket.migration.ImportRequest
import com.atlassian.bitbucket.migration.MigrationService
import com.atlassian.sal.api.component.ComponentLocator
import com.test.bitbucket.api.ImportService
import com.test.bitbucket.util.Constants
import javax.inject.Named
 ExportService
 
 package com.test.bitbucket.api
 import com.atlassian.bitbucket.job.Job
 import com.atlassian.bitbucket.migration.ExportRequest
 import com.atlassian.bitbucket.scope.Scope
 import javax.validation.constraints.NotNull
 import java.util.stream.Stream
 ImportService
 
 package com.test.bitbucket.api
 
 import com.atlassian.bitbucket.job.Job

The depencency:tree:

 [INFO] com.test.bitbucket:project-migrator:atlassian-plugin:1.0.0-SNAPSHOT
 [INFO] +- org.codehaus.groovy:groovy-all:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-ant:jar:2.5.8:compile
 [INFO] |  |  +- org.apache.ant:ant:jar:1.9.13:compile
 [INFO] |  |  +- org.apache.ant:ant-junit:jar:1.9.13:runtime
 [INFO] |  |  +- org.apache.ant:ant-launcher:jar:1.9.13:compile
 [INFO] |  |  \- org.apache.ant:ant-antlr:jar:1.9.13:runtime
 [INFO] |  +- org.codehaus.groovy:groovy-cli-commons:jar:2.5.8:compile
 [INFO] |  |  \- commons-cli:commons-cli:jar:1.4:compile
 [INFO] |  +- org.codehaus.groovy:groovy-cli-picocli:jar:2.5.8:compile
 [INFO] |  |  \- info.picocli:picocli:jar:4.0.1:compile
 [INFO] |  +- org.codehaus.groovy:groovy-console:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-datetime:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-docgenerator:jar:2.5.8:compile
 [INFO] |  |  \- com.thoughtworks.qdox:qdox:jar:1.12.1:compile
 [INFO] |  +- org.codehaus.groovy:groovy-groovydoc:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-groovysh:jar:2.5.8:compile
 [INFO] |  |  \- jline:jline:jar:2.14.6:compile
 [INFO] |  +- org.codehaus.groovy:groovy-jmx:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-json:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-jsr223:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-macro:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-nio:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-servlet:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-sql:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-swing:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-templates:jar:2.5.8:compile
 [INFO] |  +- org.codehaus.groovy:groovy-test:jar:2.5.8:compile
 [INFO] |  |  \- junit:junit:jar:4.12:compile
 [INFO] |  |     \- org.hamcrest:hamcrest-core:jar:1.3:compile
 [INFO] |  +- org.codehaus.groovy:groovy-test-junit5:jar:2.5.8:compile
 [INFO] |  |  +- org.junit.platform:junit-platform-launcher:jar:1.4.0:compile
 [INFO] |  |  |  \- org.junit.platform:junit-platform-engine:jar:1.4.0:compile
 [INFO] |  |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.4.0:runtime
 [INFO] |  +- org.codehaus.groovy:groovy-testng:jar:2.5.8:compile
 [INFO] |  |  \- org.testng:testng:jar:6.13.1:runtime
 [INFO] |  |     \- com.beust:jcommander:jar:1.72:runtime
 [INFO] |  \- org.codehaus.groovy:groovy-xml:jar:2.5.8:compile
 [INFO] +- com.atlassian.sal:sal-api:jar:4.0.0:provided
 [INFO] +- com.atlassian.bitbucket.server:bitbucket-api:jar:6.5.1:provided
 [INFO] |  +- com.atlassian.analytics:analytics-api:jar:5.7.2:provided
 [INFO] |  +- com.atlassian.annotations:atlassian-annotations:jar:2.2.1:provided
 [INFO] |  |  \- org.checkerframework:checker-qual:jar:2.8.1:provided
 [INFO] |  +- com.atlassian.crowd:embedded-crowd-api:jar:3.3.3-platform5-jdk11-m02:provided
 [INFO] |  +- com.atlassian.event:atlassian-event:jar:4.0.0:provided
 [INFO] |  +- com.atlassian.extras:atlassian-extras-api:jar:3.3.0:provided
 [INFO] |  +- com.atlassian.utils:atlassian-processutils:jar:1.8.3:provided
 [INFO] |  |  \- org.jvnet.winp:winp:jar:1.25:provided
 [INFO] |  +- com.google.code.findbugs:jsr305:jar:3.0.0:provided
 [INFO] |  +- com.google.guava:guava:jar:26.0-jre:provided
 [INFO] |  |  +- com.google.errorprone:error_prone_annotations:jar:2.1.3:provided
 [INFO] |  |  +- com.google.j2objc:j2objc-annotations:jar:1.1:provided
 [INFO] |  |  \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:provided
 [INFO] |  +- javax.activation:activation:jar:1.1.1:provided
 [INFO] |  +- org.apache.commons:commons-lang3:jar:3.8.1:provided
 [INFO] |  \- org.hibernate.validator:hibernate-validator:jar:6.0.14.Final:provided
 [INFO] |     +- javax.validation:validation-api:jar:2.0.1.Final:provided
 [INFO] |     +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:provided
 [INFO] |     \- com.fasterxml:classmate:jar:1.3.4:provided
 [INFO] +- com.atlassian.bitbucket.server:bitbucket-spi:jar:6.5.1:provided
 [INFO] |  +- com.atlassian.plugins:atlassian-plugins-core:jar:5.2.1:provided
 [INFO] |  |  +- com.atlassian.plugins:atlassian-plugins-api:jar:5.2.1:provided
 [INFO] |  |  |  \- io.atlassian.util.concurrent:atlassian-util-concurrent:jar:4.0.1:provided
 [INFO] |  |  +- dom4j:dom4j:jar:1.6.1:provided
 [INFO] |  |  +- io.atlassian.fugue:fugue:jar:4.7.1:provided
 [INFO] |  |  +- com.atlassian.security:atlassian-secure-xml:jar:3.2.13:provided
 [INFO] |  |  \- net.jcip:com.springsource.net.jcip.annotations:jar:1.0.0:provided
 [INFO] |  \- com.atlassian.profiling:atlassian-profiling:jar:3.2.0:provided
 [INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
 [INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.5.1:test
 [INFO] |  +- org.apiguardian:apiguardian-api:jar:1.1.0:compile
 [INFO] |  +- org.opentest4j:opentest4j:jar:1.2.0:compile
 [INFO] |  \- org.junit.platform:junit-platform-commons:jar:1.5.1:compile
 [INFO] +- com.atlassian.plugin:atlassian-spring-scanner-annotation:jar:2.1.3:provided
 [INFO] +- javax.inject:javax.inject:jar:1:provided
 [INFO] +- com.atlassian.plugins:atlassian-plugins-osgi-testrunner:jar:1.2.3:test
 [INFO] |  +- commons-io:commons-io:jar:2.6:provided
 [INFO] |  \- com.atlassian.upm:upm-api:jar:2.15:test
 [INFO] +- javax.ws.rs:jsr311-api:jar:1.1.1:provided
 [INFO] +- com.google.code.gson:gson:jar:2.8.0:compile
 [INFO] +- javax.servlet:servlet-api:jar:2.4:provided
 [INFO] +- org.slf4j:slf4j-api:jar:1.6.6:provided
 [INFO] +- org.apache.httpcomponents:httpclient:jar:4.1.1:test
 [INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.4.9:test
 [INFO] |  \- commons-codec:commons-codec:jar:1.10:test
 [INFO] +- org.mockito:mockito-all:jar:1.8.5:test
 [INFO] +- javax.xml.bind:jaxb-api:jar:2.1:provided
 [INFO] |  \- javax.xml.stream:stax-api:jar:1.0-2:provided
 [INFO] +- com.atlassian.templaterenderer:atlassian-template-renderer-api:jar:4.0.0:provided
 [INFO] +- com.atlassian.plugins.rest:atlassian-rest-common:jar:1.0.2:provided
 [INFO] |  +- com.atlassian.plugins.rest:com.atlassian.jersey-library:pom:6.0.2:provided
 [INFO] |  |  +- com.sun.jersey:jersey-core:jar:1.19.4:provided
 [INFO] |  |  +- com.sun.jersey:jersey-server:jar:1.19:provided
 [INFO] |  |  +- org.ow2.asm:asm:jar:7.1:provided
 [INFO] |  |  +- com.sun.jersey:jersey-servlet:jar:1.19.4:provided
 [INFO] |  |  +- com.sun.jersey:jersey-client:jar:1.19.4:provided
 [INFO] |  |  +- com.sun.jersey:jersey-json:jar:1.19.4:provided
 [INFO] |  |  |  \- org.codehaus.jettison:jettison:jar:1.1:provided
 [INFO] |  |  +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13-atlassian-2:provided
 [INFO] |  |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13-atlassian-2:provided
 [INFO] |  |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.13-atlassian-3:provided
 [INFO] |  |  +- org.codehaus.jackson:jackson-xc:jar:1.9.13-atlassian-3:provided
 [INFO] |  |  \- commons-fileupload:commons-fileupload:jar:1.3.3:provided
 [INFO] |  \- net.sourceforge.findbugs:jsr305:jar:1.3.2:provided
 [INFO] \- org.apache.wink:wink-client:jar:1.1.3-incubating:test
 [INFO]    +- org.apache.wink:wink-common:jar:1.1.3-incubating:test
 [INFO]    |  \- org.apache.geronimo.specs:geronimo-annotation_1.1_spec:jar:1.0:test
 [INFO]    \- com.sun.xml.bind:jaxb-impl:jar:2.2.1.1:test
 [INFO] ------------------------------------------------------------------------
 [INFO] BUILD SUCCESS
 [INFO] ------------------------------------------------------------------------
 [INFO] Total time: 1.296 s
 [INFO] Finished at: 2019-08-28T23:28:22+03:00

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.test.bitbucket</groupId>
    <artifactId>test-project</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <organization>
        <name>${organization.name}</name>
        <url>http://</url>
    </organization>
    <name>${app.name}</name>
    <description>${app.description}</description>
    <packaging>atlassian-plugin</packaging>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.atlassian.bitbucket.server</groupId>
                <artifactId>bitbucket-parent</artifactId>
                <version>${bitbucket.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>${groovy.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-spi</artifactId>
            <scope>provided</scope>
        </dependency>
<!--        <dependency>-->
<!--            <groupId>com.atlassian.bitbucket.server</groupId>-->
<!--            <artifactId>bitbucket-page-objects</artifactId>-->
<!--            <scope>provided</scope>-->
<!--        </dependency>-->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
<!--        <dependency>-->
<!--            <groupId>junit</groupId>-->
<!--            <artifactId>junit</artifactId>-->
<!--            <version>${junit.libversion}</version>-->
<!--            <scope>test</scope>-->
<!--        </dependency>-->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.5.1</version>
            <scope>test</scope>
        </dependency>

<!--        <dependency>-->
<!--            <groupId>org.apache.commons</groupId>-->
<!--            <artifactId>commons-lang3</artifactId>-->
<!--            <version>${commons.lang3.version}</version>-->
<!--            <scope>provided</scope>-->
<!--        </dependency>-->
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>${javax.inject.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- WIRED TEST RUNNER DEPENDENCIES -->
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
            <version>${plugin.testrunner.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>${jsr311.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>${gson.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.1.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.8.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.templaterenderer</groupId>
            <artifactId>atlassian-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-common</artifactId>
            <version>1.0.2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.wink</groupId>
            <artifactId>wink-client</artifactId>
            <version>1.1.3-incubating</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.7.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>execute</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-all</artifactId>
                        <version>${groovy.version}</version>
                        <scope>runtime</scope>

                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>bitbucket-maven-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <products>
                        <product>
                            <id>bitbucket</id>
                            <instanceId>bitbucket</instanceId>
                            <version>${bitbucket.version}</version>
                            <dataVersion>${bitbucket.data.version}</dataVersion>
                        </product>
                    </products>
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <!-- Add package to export here -->
                        <Export-Package>com.test.bitbucket.api.*</Export-Package>
                        <!-- Add package import here -->


                        <Import-Package>
                            org.springframework.osgi.*;resolution:="optional",
                            org.eclipse.gemini.blueprint.*;resolution:="optional",
                            *
                        </Import-Package>


                        <DynamicImport-Package>*</DynamicImport-Package>
                        <!-- Ensure plugin is Spring powered -->
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <version>${atlassian.spring.scanner.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>atlassian-spring-scanner</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <scannedDependencies>
                        <dependency>
                            <groupId>com.atlassian.plugin</groupId>
                            <artifactId>atlassian-spring-scanner-external-jar</artifactId>
                        </dependency>
                    </scannedDependencies>
                    <verbose>false</verbose>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <properties>
        <groovy.version>2.5.8</groovy.version>
        <bitbucket.data.version>6.0.0</bitbucket.data.version>
        <bitbucket.version>6.5.1</bitbucket.version>
        <amps.version>8.0.0</amps.version>
        <!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <atlassian.spring.scanner.version>2.1.3</atlassian.spring.scanner.version>
        <commons.lang3.version>3.5</commons.lang3.version>
        <gson.version>2.8.0</gson.version>
        <javax.inject.version>1</javax.inject.version>
        <jsr311.version>1.1.1</jsr311.version>
        <plugin.testrunner.version>1.2.3</plugin.testrunner.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

I would like to mention that I was able to package the plugin in the past.
I’ve searched the web and found a fix for this issue, but only if one was using JDOM and I’m not using, hence this topic.

Could you please help me in fixing this issue?

Regards,

Razvan

Hey mate,

I can’t see a smoking gun in the examples that you shared.
The problem seems to be that you might be using a Class from the unnamed package which cannot be used when the plugin generates the manifest.

There are quite some groovy dependencies in the code, can you check if groovy is maybe causing this issue? Maybe it is using a class of the unnamed package?

Hello @tkenis,

Thank you for your input. I’ll have a look and then reply here. This issue appeared after I created a trait as before that, the plugin was packaged easily/normally. I can still package the jar but not with atlas-package, however, this isn’t the route I want to go on.

Can this affect in some way? I would like to mention that I removed the trait and the error is still present.

Manifest com.test.bitbucket:test-project:atlassian-plugin:1.0.0-SNAPSHOT :  
Classes found in the wrong directory: 
{META-INF/versions/9/module-info.class=module-info, META-INF/versions/9/org/junit/platform/commons/util/ModuleUtils$ModuleReferenceScanner.class=org.junit.platform.commons.util.ModuleUtils$ModuleReferenceScanner, META-INF/versions/9/org/junit/platform/commons/util/ModuleUtils.class=org.junit.platform.commons.util.ModuleUtils}

Regards,

Razvan